Visual Basic for Applications (VBA)
...
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swTopLevelAssembly As SldWorks.AssemblyDoc
Dim swRoutingAssembly As SldWorks.AssemblyDoc
Dim rtRouteManager As SWRoutingLib.RouteManager
Dim swComponent As SldWorks.Component2
...
' Connect to SolidWorks
Set swApp = Application.SldWorks
' Get the active document
Set swModel = swApp.ActiveDoc
' Downcast from model document to assembly document
Set swTopLevelAssembly = swModel
' Select the component that represents a routing assembly
Set swComponent = swModel.SelectionManager.GetSelectedObject6(1, 0)
If swComponent Is Nothing Then
Debug.Print "No component selected"
Exit Sub
End If
' Get the assembly document for this component
Set swRoutingAssembly = swComponent.GetModelDoc
' Get the RouteManager from the routing assembly
Set rtRouteManager = swRoutingAssembly.GetRouteManager
If rtRouteManager Is Nothing Then
Debug.Print "No RouteManager found in sub-assembly document: " & swRoutingAssembly.GetPathName
Exit Sub
End If
...