使用SOLIDWORKS API显示装配体可视化页面
该示例使用SOLIDWORKS API显示装配体可视化页面的特征树页面。
{ width=320 height=291 }
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, ""
Else
MsgBox "请打开装配体"
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