Display assembly visualization page using SOLIDWORKS API

Edit ArticleEdit Article

This example displays the feature tree page for Assembly Visualization using SOLIDWORKS API.

Assembly Visualization Feature Manager Tab
Assembly Visualization Feature Manager Tab

Dim swApp As SldWorks.SldWorks

Sub main()

    Set swApp = Application.SldWorks
    Dim swAssy As SldWorks.AssemblyDoc
    Set swAssy = TryGetActiveAssembly
    If Not swAssy Is Nothing Then
        swApp.RunCommand swCommands_VisualizationTool, ""
        MsgBox "Please open assembly"
    End If
End Sub

Function TryGetActiveAssembly() As SldWorks.AssemblyDoc
    Dim swModel As SldWorks.ModelDoc2
    Set swModel = swApp.ActiveDoc
    If Not swModel Is Nothing Then
        If swModel.GetType() = swDocumentTypes_e.swDocASSEMBLY Then
            Set TryGetActiveAssembly = swApp.ActiveDoc
        End If
    End If
End Function


All articles and code at CodeStack are now open-source and hosted on GitHub. If you want to contribute by modifying existing articles and code snippets, submitting new ones, reporting errors and bugs etc. please follow this blog post for more information. We appreciate any contribution.

Product of Xarial Product of Xarial