Open an Assembly in Large Design Review Mode Example (VB.NET)
This example shows how to open an assembly in Large Design Review mode.
'----------------------------------------------------------------------------
' Preconditions: Open a large assembly document in Large Design Review mode.
'
' Run macro: Click OK in the Name Snapshot dialog box.
'
' Postconditions:
' 1. A section view is created.
' 2. Four snapshots are created in DisplayManager:
' * Home
' * ASnap
' * Snap2
' * Snap3
' Inspect the Immediate window for snapshot information.
' 3. All of the components in the assembly are hidden.
' Inspect the Immediate window for the names of the hidden components.
'
---------------------------------------------------------------------------
Imports
SolidWorks.Interop.sldworks
Imports
SolidWorks.Interop.swconst
Imports
System.Runtime.InteropServices
Imports
System
Imports
System.Diagnostics
Partial
Class
SolidWorksMacro
Dim
Part As
AssemblyDoc
Dim
snap As
SnapShot
Dim
comps As
Object
Dim
snaps As
Object
Dim
snap1 As
SnapShot
Dim
snap2 As
SnapShot
Dim
snap3 As
SnapShot
Dim i
As
Long
Dim
boolstatus As
Boolean
Sub
main()
Part = swApp.ActiveDoc
' Create section view
Dim
sViewData As
SectionViewData
sViewData = Part.ModelViewManager.CreateSectionViewData()
sViewData.FirstPlane =
Nothing
sViewData.FirstReverseDirection
= False
sViewData.FirstOffset =
-0.00508
sViewData.FirstRotationX = 0
sViewData.FirstRotationY = 0
sViewData.FirstColor = 16711680
sViewData.ShowSectionCap =
True
sViewData.KeepCapColor =
True
Dim
mvmgr As
ModelViewManager
mvmgr = Part.ModelViewManager
boolstatus = mvmgr.CreateSectionView(sViewData)
Part.ClearSelection2(True)
Part.ShowNamedView2("*Front",
1)
Part.ShowNamedView2("*Dimetric",
9)
' Add a named snapshot
snap1 = mvmgr.AddSnapShot("ASnap")
' Open dialog box to name the next
snapshot
snap2 = mvmgr.AddSnapShot("?")
' Add a snapshot with the next
default name
snap3 = mvmgr.AddSnapShot("")
snap1.Comment = "<TS> This
is a comment for ASnap."
snaps = mvmgr.GetSnapShots
For
i = 0 To
UBound(snaps)
snap = snaps(i)
snap.Activate()
Debug.Print("Snapshot name: "
& snap.Name)
Debug.Print(" Comment: "
& snap.Comment)
Debug.Print(" ViewID: "
& snap.ViewId)
Next
Dim
comp As
Component2
comps = Part.GetComponents(False)
Debug.Print("")
Debug.Print("SelectByID names of
components:")
Debug.Print("")
For
i = 0 To
UBound(comps)
comp = comps(i)
If
comp.IsRoot Then
Debug.Print("Root
Component " & comp.GetSelectByIDString)
Else
Debug.Print("
" & comp.GetSelectByIDString)
' Hide each component in
the assembly
comp.Visible = 0
End
If
Next
'
OPTIONAL: At this point, select one or more components
'
in the FeatureManager design tree
'
'
Fully resolve only the selected components
Part.SelectiveOpen(True,
False)
End
Sub
Public
swApp As
SldWorks
End
Class