FamilyItemFactory.NewBlend
Description:
Add a new Blend instance into the Autodesk Revit family document.
Add a new Blend instance into the Autodesk Revit family document.
Remarks:
This method creates a blend in a family document. The blend will be extended between the two independent pieces of geometry. Revit will determine an appropriate default mapping for the vertices of the two profiles. The two input profiles must be parallel. If the input profile is to be a cyclic profile (curve or ellipse) it must be split into at least two segments, so that Revit can find vertices to use for mapping the blend.
This method creates a blend in a family document. The blend will be extended between the two independent pieces of geometry. Revit will determine an appropriate default mapping for the vertices of the two profiles. The two input profiles must be parallel. If the input profile is to be a cyclic profile (curve or ellipse) it must be split into at least two segments, so that Revit can find vertices to use for mapping the blend.
public Blend NewBlend(
bool isSolid,
CurveArray topProfile,
CurveArray baseProfile,
SketchPlane sketchPlane
)
-
isSolidIndicates if the Blend is Solid or Void.
-
topProfileThe top blend section. It should consist of only one curve loop. The input profile must be in one plane.
-
baseProfileThe base blend section. It should consist of only one curve loop. The input profile must be in one plane.
-
sketchPlaneThe sketch plane for the base profile. Use this to associate the base of the blend to geometry from another element. Optional, it can be nulla null reference (Nothing in Visual Basic) if you want Revit to derive a new sketch plane from the geometry of the base profile.
Return Value
Blend
If creation was successful the new blend is returned,
otherwise an exception with failure information will be thrown.
private Blend CreateBlend(UIApplication application, SketchPlane sketchPlane)
{
Blend blend = null;
// make sure we have a family document
Document familyDocument = application.ActiveUIDocument.Document;
if (true == familyDocument.IsFamilyDocument)
{
// Define top and base profiles for the blend
CurveArray topProfile = new CurveArray();
CurveArray baseProfile = new CurveArray();
// create rectangular base profile
XYZ p00 = XYZ.Zero;
XYZ p01 = new XYZ(10, 0, 0);
XYZ p02 = new XYZ(10, 10, 0);
XYZ p03 = new XYZ(0, 10, 0);
Line line01 = Line.CreateBound(p00, p01);
Line line02 = Line.CreateBound(p01, p02);
Line line03 = Line.CreateBound(p02, p03);
Line line04 = Line.CreateBound(p03, p00);
baseProfile.Append(line01);
baseProfile.Append(line02);
baseProfile.Append(line03);
baseProfile.Append(line04);
// create rectangular top profile
XYZ p10 = new XYZ(5, 2, 10);
XYZ p11 = new XYZ(8, 5, 10);
XYZ p12 = new XYZ(5, 8, 10);
XYZ p13 = new XYZ(2, 5, 10);
Line line11 = Line.CreateBound(p10, p11);
Line line12 = Line.CreateBound(p11, p12);
Line line13 = Line.CreateBound(p12, p13);
Line line14 = Line.CreateBound(p13, p10);
topProfile.Append(line11);
topProfile.Append(line12);
topProfile.Append(line13);
topProfile.Append(line14);
// now create solid rectangular blend
blend = familyDocument.FamilyCreate.NewBlend(true, topProfile, baseProfile, sketchPlane);
if (null != blend)
{
// move to proper place
XYZ transPoint1 = new XYZ(0, 11, 0);
ElementTransformUtils.MoveElement(familyDocument, blend.Id, transPoint1);
}
else
{
throw new Exception("Create new Blend failed.");
}
}
else
{
throw new Exception("Please open a Family document before invoking this command.");
}
return blend;
}
-
Thrown when the argument is invalid.
-
Thrown when creation is attempted in Conceptual Mass, 2D, or other family where blends cannot be created.
-
Thrown when the creation failed.