DocumentNewFamilyInstance(Curve, FamilySymbol, Level, StructuralType) Method |
Inserts a new instance of a family into the document,
using a curve, type/symbol and reference level.
Namespace: Autodesk.Revit.CreationAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic FamilyInstance NewFamilyInstance(
Curve curve,
FamilySymbol symbol,
Level level,
StructuralType structuralType
)
Public Function NewFamilyInstance (
curve As Curve,
symbol As FamilySymbol,
level As Level,
structuralType As StructuralType
) As FamilyInstance
public:
FamilyInstance^ NewFamilyInstance(
Curve^ curve,
FamilySymbol^ symbol,
Level^ level,
StructuralType structuralType
)
member NewFamilyInstance :
curve : Curve *
symbol : FamilySymbol *
level : Level *
structuralType : StructuralType -> FamilyInstance
Parameters
- curve Curve
- The curve where the instance is based.
- symbol FamilySymbol
- A FamilySymbol object that represents the type of the instance that is to be inserted.
- level Level
- A Level object that is used as the base level for the object.
- structuralType StructuralType
- If structural then specify the type of the component.
Return Value
FamilyInstanceIf creation was successful then an instance to the new object is returned, otherwise
.
Exceptions
RemarksThis method is used to insert one family instance into another element along the geometry of a curve.
If the instance fails to be created an
exception may be thrown.
The type/symbol that is used must be loaded into the document before this
method is called. Families and their symbols can be loaded using the Document.LoadFamily or
Document.LoadFamilySymbol methods.
The host object must be one that supports insertion of
instances otherwise this method will fail. All levels within the document can be found by iterating
over the entire document and searching for objects of type Autodesk.Revit.Elements.Level.
Note: if the created family instance includes nested instances, the API framework will automatically regenerate
the document during this method call.
ExampleFamilyInstance CreateBeam(Autodesk.Revit.DB.Document document, View view)
{
Level level = document.GetElement(view.LevelId) as Level;
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_StructuralFraming);
FamilySymbol gotSymbol = collector.FirstElement() as FamilySymbol;
XYZ startPoint = new XYZ(0, 0, 0);
XYZ endPoint = new Autodesk.Revit.DB.XYZ(10, 0, 0);
Autodesk.Revit.DB.Curve beamLine = Line.CreateBound(startPoint, endPoint);
FamilyInstance instance = document.Create.NewFamilyInstance(beamLine, gotSymbol,
level, StructuralType.Beam);
return instance;
}
Private Function CreateBeam(document As Autodesk.Revit.DB.Document, view As View) As FamilyInstance
Dim level As Level = TryCast(document.GetElement(view.LevelId), Level)
Dim collector As New FilteredElementCollector(document)
collector.OfClass(GetType(FamilySymbol)).OfCategory(BuiltInCategory.OST_StructuralFraming)
Dim gotSymbol As FamilySymbol = TryCast(collector.FirstElement(), FamilySymbol)
Dim startPoint As New XYZ(0, 0, 0)
Dim endPoint As XYZ = New Autodesk.Revit.DB.XYZ(10, 0, 0)
Dim beamLine As Autodesk.Revit.DB.Curve = Line.CreateBound(startPoint, endPoint)
Dim instance As FamilyInstance = document.Create.NewFamilyInstance(beamLine, gotSymbol, level, StructuralType.Beam)
Return instance
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