Hide Table of Contents

Open an Assembly in Large Design Review Mode Example (VBA)

This example shows how to open an assembly in Large Design Review mode.

'----------------------------------------------------------------------------
' Preconditions: Specify in SldWorks::OpenDoc6 the name of a large
' assembly document to open 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.
' ---------------------------------------------------------------------------

Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.AssemblyDoc
Dim snap As SldWorks.snapShot
Dim comps As Variant
Dim snaps As Variant
Dim snap1 As SldWorks.snapShot
Dim snap2 As SldWorks.snapShot
Dim snap3 As SldWorks.snapShot
Dim i As Long
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Option Explicit

Sub main()
   

    Set swApp = _
    Application.SldWorks
   

    ' Open a large assembly in Large Design Review mode
    Set Part = swApp.OpenDoc6("large_assembly_document", swDocASSEMBLY, swOpenDocOptions_ViewOnly, "", longstatus, longwarnings)
    Set Part = swApp.ActiveDoc
   

    ' Wait for the FeatureManager design tree to synchronize
    sleep 5
   

    ' Create section view
    Dim sViewData As Object
    Set sViewData = Part.ModelViewManager.CreateSectionViewData()
    Set 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
    Set mvmgr = Part.ModelViewManager
    boolstatus = mvmgr.CreateSectionView(sViewData)
    Part.ClearSelection2 True
    Part.ShowNamedView2 "*Front", 1
    Part.ShowNamedView2 "*Dimetric", 9
   

    ' Add a named snapshot
    Set snap1 = mvmgr.AddSnapShot("ASnap")
    ' Open dialog box to name the next snapshot
    Set snap2 = mvmgr.AddSnapShot("?")
    ' Add a snapshot with the next default name
    Set snap3 = mvmgr.AddSnapShot("")
   

    snap1.Comment = "<TS> This is a comment for ASnap."
   

    snaps = mvmgr.GetSnapShots
   

    For i = 0 To UBound(snaps)
        Set 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)
        Set 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
Sub sleep(PauseTime As Integer)
    Dim Start, TotalTime as Integer
    Start = Timer    ' Set start time
    Do While Timer < Start + PauseTime
        DoEvents    ' Yield to other processes
    Loop
End Sub

 



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Open an Assembly in Large Design Review Mode Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:




x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2013 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.