FamilyItemFactory.NewExtrusionForm
Method
Description:
Create new Form element by Extrude operation, and add it into the Autodesk Revit family document.
Create new Form element by Extrude operation, and add it into the Autodesk Revit family document.
Examples
private Form CreateExtrusionForm(Autodesk.Revit.DB.Document document)
{
Form extrusionForm = null;
// Create one profile
ReferenceArray ref_ar = new ReferenceArray();
XYZ ptA = new XYZ(10, 10, 0);
XYZ ptB = new XYZ(90, 10, 0);
ModelCurve modelcurve = MakeLine(document, ptA, ptB);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
ptA = new XYZ(90, 10, 0);
ptB = new XYZ(10, 90, 0);
modelcurve = MakeLine(document, ptA, ptB);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
ptA = new XYZ(10, 90, 0);
ptB = new XYZ(10, 10, 0);
modelcurve = MakeLine(document, ptA, ptB);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
// The extrusion form direction
XYZ direction = new XYZ(0, 0, 50);
extrusionForm = document.FamilyCreate.NewExtrusionForm(true, ref_ar, direction);
int profileCount = extrusionForm.ProfileCount;
return extrusionForm;
}
public ModelCurve MakeLine(Document doc, XYZ ptA, XYZ ptB)
{
Autodesk.Revit.ApplicationServices.Application app = doc.Application;
// Create plane by the points
Line line = Line.CreateBound(ptA, ptB);
XYZ norm = ptA.CrossProduct(ptB);
if (norm.IsZeroLength()) norm = XYZ.BasisZ;
Plane plane = Plane.CreateByNormalAndOrigin(norm, ptB);
SketchPlane skplane = SketchPlane.Create(doc, plane);
// Create line here
ModelCurve modelcurve = doc.FamilyCreate.NewModelCurve(line, skplane);
return modelcurve;
}
Parameters
Parameter | Type | Description |
---|---|---|
isSolid | Boolean | Indicates if the Form is Solid or Void. |
profile | ReferenceArray | The profile of extrusion. It should consist of only one curve loop. |
direction | XYZ | The direction of extrusion, with its length the length of the extrusion. The direction must be perpendicular to the plane determined by profile. The length of vector must be non-zero. |
Return Value
Type | Description |
---|---|
Form | If creation was successful new form is returned. |
Exceptions
Exception | Condition |
---|---|
InvalidOperationException | Thrown when creation is attempted in Conceptual Mass, 2D, or other family where extrusions cannot be created. |