Combines multiple elements for tagging, filtering, scheduling and creating isolated assembly views.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.484.0)
Since:
2012
Syntax
Examples

// Create assembly instance, name the assembly, and create views of the assembly void CreateAssemblyAndViews(Autodesk.Revit.DB.Document doc, ICollection<ElementId> elementIds) { using (Transaction transaction = new Transaction(doc)) { ElementId categoryId = doc.GetElement(elementIds.First()).Category.Id; // use category of one of the assembly elements if (AssemblyInstance.IsValidNamingCategory(doc, categoryId, elementIds)) { transaction.Start("Create Assembly Instance"); AssemblyInstance assemblyInstance = AssemblyInstance.Create(doc, elementIds, categoryId); transaction.Commit(); // commit the transaction that creates the assembly instance before modifying the instance's name if (transaction.GetStatus() == TransactionStatus.Committed) { transaction.Start("Set Assembly Name"); assemblyInstance.AssemblyTypeName = "My Assembly Name"; transaction.Commit(); } if (assemblyInstance.AllowsAssemblyViewCreation()) // create assembly views for this assembly instance { if (transaction.GetStatus() == TransactionStatus.Committed) { transaction.Start("View Creation"); View3D view3d = AssemblyViewUtils.Create3DOrthographic(doc, assemblyInstance.Id); ViewSchedule partList = AssemblyViewUtils.CreatePartList(doc, assemblyInstance.Id); transaction.Commit(); } } } } }

' Create assembly instance, name the assembly, and create views of the assembly Private Sub CreateAssemblyAndViews(doc As Autodesk.Revit.DB.Document, elementIds As ICollection(Of ElementId)) Using transaction As New Transaction(doc) Dim categoryId As ElementId = doc.GetElement(elementIds.First()).Category.Id ' use category of one of the assembly elements If AssemblyInstance.IsValidNamingCategory(doc, categoryId, elementIds) Then transaction.Start("Create Assembly Instance") Dim assemblyInstance__1 As AssemblyInstance = AssemblyInstance.Create(doc, elementIds, categoryId) transaction.Commit() ' commit the transaction that creates the assembly instance before modifying the instance's name If transaction.GetStatus() = TransactionStatus.Committed Then transaction.Start("Set Assembly Name") assemblyInstance__1.AssemblyTypeName = "My Assembly Name" transaction.Commit() End If If assemblyInstance__1.AllowsAssemblyViewCreation() Then ' create assembly views for this assembly instance If transaction.GetStatus() = TransactionStatus.Committed Then transaction.Start("View Creation") Dim view3d As View3D = AssemblyViewUtils.Create3DOrthographic(doc, assemblyInstance__1.Id) Dim partList As ViewSchedule = AssemblyViewUtils.CreatePartList(doc, assemblyInstance__1.Id) transaction.Commit() End If End If End If End Using End Sub