FamilyItemFactoryNewBlend Method |
Add a new Blend instance into the Autodesk Revit family document.
Namespace: Autodesk.Revit.CreationAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic Blend NewBlend(
bool isSolid,
CurveArray profile1,
CurveArray profile2,
SketchPlane sketchPlane
)
Public Function NewBlend (
isSolid As Boolean,
profile1 As CurveArray,
profile2 As CurveArray,
sketchPlane As SketchPlane
) As Blend
public:
Blend^ NewBlend(
bool isSolid,
CurveArray^ profile1,
CurveArray^ profile2,
SketchPlane^ sketchPlane
)
member NewBlend :
isSolid : bool *
profile1 : CurveArray *
profile2 : CurveArray *
sketchPlane : SketchPlane -> Blend
Parameters
- isSolid Boolean
- Indicates if the Blend is Solid or Void.
- profile1 CurveArray
- The first blend section. It should represent a single, planar curve loop.
- profile2 CurveArray
- The second blend section. It should represent a single, planar curve loop
lying in a plane parallel to that of the first blend section.
- sketchPlane SketchPlane
- The sketch plane for the first profile. Use this to associate the
"base" of the blend to geometry from another element. Optional, it can be if you want Revit
to derive a new sketch plane from the geometry of the base profile.
Return Value
BlendIf creation was successful the new blend is returned,
otherwise an exception with failure information will be thrown.
Exceptions
RemarksThis method creates a blend in a family document. Revit will determine an appropriate
default mapping for the vertices of the two profiles.
A profile loop cannot contain just one closed curve - in such a case, the curve must be
split into at least two segments, so that Revit can find vertices to use for mapping the blend.
Caution: several aspects of the Blend are not (easily) predictable from the input arguments.
For example, the Blend's TopOffset may be less than its BottomOffset in some cases,
depending on the orientations of the profile loops and the orientation of the sketch plane
(if a sketch plane is provided). Also, such orientations can affect whether the first or
second profile lies in the sketch plane (if a sketch plane is provided).
Exampleprivate Blend CreateBlend(UIApplication application, SketchPlane sketchPlane)
{
Blend blend = null;
Document familyDocument = application.ActiveUIDocument.Document;
if (true == familyDocument.IsFamilyDocument)
{
CurveArray topProfile = new CurveArray();
CurveArray baseProfile = new CurveArray();
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);
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);
blend = familyDocument.FamilyCreate.NewBlend(true, topProfile, baseProfile, sketchPlane);
if (null != blend)
{
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;
}
Private Function CreateBlend(application As UIApplication, sketchPlane As SketchPlane) As Blend
Dim blend As Blend = Nothing
Dim familyDocument As Document = application.ActiveUIDocument.Document
If True = familyDocument.IsFamilyDocument Then
Dim topProfile As New CurveArray()
Dim baseProfile As New CurveArray()
Dim p00 As XYZ = XYZ.Zero
Dim p01 As New XYZ(10, 0, 0)
Dim p02 As New XYZ(10, 10, 0)
Dim p03 As New XYZ(0, 10, 0)
Dim line01 As Line = Line.CreateBound(p00, p01)
Dim line02 As Line = Line.CreateBound(p01, p02)
Dim line03 As Line = Line.CreateBound(p02, p03)
Dim line04 As Line = Line.CreateBound(p03, p00)
baseProfile.Append(line01)
baseProfile.Append(line02)
baseProfile.Append(line03)
baseProfile.Append(line04)
Dim p10 As New XYZ(5, 2, 10)
Dim p11 As New XYZ(8, 5, 10)
Dim p12 As New XYZ(5, 8, 10)
Dim p13 As New XYZ(2, 5, 10)
Dim line11 As Line = Line.CreateBound(p10, p11)
Dim line12 As Line = Line.CreateBound(p11, p12)
Dim line13 As Line = Line.CreateBound(p12, p13)
Dim line14 As Line = Line.CreateBound(p13, p10)
topProfile.Append(line11)
topProfile.Append(line12)
topProfile.Append(line13)
topProfile.Append(line14)
blend = familyDocument.FamilyCreate.NewBlend(True, topProfile, baseProfile, sketchPlane)
If blend IsNot Nothing Then
Dim transPoint1 As New XYZ(0, 11, 0)
ElementTransformUtils.MoveElement(familyDocument, blend.Id, transPoint1)
Else
Throw New Exception("Create new Blend failed.")
End If
Else
Throw New Exception("Please open a Family document before invoking this command.")
End If
Return blend
End Function
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also