FamilyItemFactoryNewExtrusion Method |
Add a new Extrusion instance into the Autodesk Revit family document.
Namespace: Autodesk.Revit.CreationAssembly: RevitAPI (in RevitAPI.dll) Version: 27.0.4.0 (27.0.4.0)
Syntaxpublic Extrusion NewExtrusion(
bool isSolid,
CurveArrArray profile,
SketchPlane sketchPlane,
double end
)
Public Function NewExtrusion (
isSolid As Boolean,
profile As CurveArrArray,
sketchPlane As SketchPlane,
end As Double
) As Extrusion
public:
Extrusion^ NewExtrusion(
bool isSolid,
CurveArrArray^ profile,
SketchPlane^ sketchPlane,
double end
)
member NewExtrusion :
isSolid : bool *
profile : CurveArrArray *
sketchPlane : SketchPlane *
end : float -> Extrusion Parameters
- isSolid Boolean
- Indicates if the Extrusion is Solid or Void.
- profile CurveArrArray
- The profile of the newly created Extrusion. This may contain more
than one curve loop. Each loop must be a fully closed curve loop and the loops may not
intersect. All input curves must lie in the same plane.
The loop can be a unbound circle or ellipse, but its geometry will be split in two in
order to satisfy requirements for sketches used in extrusions.
- sketchPlane SketchPlane
- The sketch plane for the extrusion. The direction of extrusion
is determined by the normal for the sketch plane. To extrude in the other direction set
the end value to negative.
- end Double
- The length of the extrusion.
Return Value
ExtrusionIf creation was successful the new Extrusion is returned,
otherwise an exception with failure information will be thrown.
Exceptions
RemarksThis method creates an extrusion in a family document. The extrusion will be
extended perpendicular to the sketch plane of the extrusion profile.
Exampleprivate Extrusion CreateExtrusion(Autodesk.Revit.DB.Document document, SketchPlane sketchPlane)
{
Extrusion rectExtrusion = null;
if (true == document.IsFamilyDocument)
{
CurveArrArray curveArrArray = new CurveArrArray();
CurveArray curveArray1 = new CurveArray();
CurveArray curveArray2 = new CurveArray();
CurveArray curveArray3 = new CurveArray();
XYZ p0 = XYZ.Zero;
XYZ p1 = new XYZ(10, 0, 0);
XYZ p2 = new XYZ(10, 10, 0);
XYZ p3 = new XYZ(0, 10, 0);
Line line1 = Line.CreateBound(p0, p1);
Line line2 = Line.CreateBound(p1, p2);
Line line3 = Line.CreateBound(p2, p3);
Line line4 = Line.CreateBound(p3, p0);
curveArray1.Append(line1);
curveArray1.Append(line2);
curveArray1.Append(line3);
curveArray1.Append(line4);
curveArrArray.Append(curveArray1);
rectExtrusion = document.FamilyCreate.NewExtrusion(true, curveArrArray, sketchPlane, 10);
if (null != rectExtrusion)
{
XYZ transPoint1 = new XYZ(-16, 0, 0);
ElementTransformUtils.MoveElement(document, rectExtrusion.Id, transPoint1);
}
else
{
throw new Exception("Create new Extrusion failed.");
}
}
else
{
throw new Exception("Please open a Family document before invoking this command.");
}
return rectExtrusion;
}
See Also