AssemblyViewUtils Class


Utilities that provide capabilities related to assembly view creation and validation.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 19.0.0.0 (19.0.0.405)
Since: 2012

Syntax

C#
public static class AssemblyViewUtils
Visual Basic
Public NotInheritable Class AssemblyViewUtils
Visual C++
public ref class AssemblyViewUtils abstract sealed

Examples

Copy C#
private ViewSchedule CreateScheduleForAssembly(Document doc, AssemblyInstance assemblyInstance, ElementId viewTemplateId)
{
    ViewSchedule schedule = null;
    if (assemblyInstance.AllowsAssemblyViewCreation()) // create assembly views for this assembly instance
    {
        using (Transaction transaction = new Transaction(doc))
        {
            transaction.Start("Create Schedule");

            // use naming category for the schedule
            if (ViewSchedule.IsValidCategoryForSchedule(assemblyInstance.NamingCategoryId))
            {
                schedule = AssemblyViewUtils.CreateSingleCategorySchedule(doc, assemblyInstance.Id, assemblyInstance.NamingCategoryId, viewTemplateId, false);
            }
            transaction.Commit();

            if (schedule != null && transaction.GetStatus() == TransactionStatus.Committed)
            {
                transaction.Start("Edit Schedule");
                schedule.Name = "AssemblyViewSchedule";
                transaction.Commit();
            }
        }
    }

    return schedule;
}
Copy VB.NET
Private Function CreateScheduleForAssembly(doc As Document, assemblyInstance As AssemblyInstance, viewTemplateId As ElementId) As ViewSchedule
    Dim schedule As ViewSchedule = Nothing
    If assemblyInstance.AllowsAssemblyViewCreation() Then
        ' create assembly views for this assembly instance
        Using transaction As New Transaction(doc)
            transaction.Start("Create Schedule")

            ' use naming category for the schedule
            If ViewSchedule.IsValidCategoryForSchedule(assemblyInstance.NamingCategoryId) Then
                schedule = AssemblyViewUtils.CreateSingleCategorySchedule(doc, assemblyInstance.Id, assemblyInstance.NamingCategoryId, viewTemplateId, False)
            End If
            transaction.Commit()

            If schedule IsNot Nothing AndAlso transaction.GetStatus() = TransactionStatus.Committed Then
                transaction.Start("Edit Schedule")
                schedule.ViewName = "AssemblyViewSchedule"
                transaction.Commit()
            End If
        End Using
    End If

    Return schedule
End Function

Inheritance Hierarchy

System Object
Autodesk.Revit.DB AssemblyViewUtils

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →