Hide Table of Contents

Get Collapsed Transform of Component in Exploded View Example (VBA)

This example shows how to get the collapsed transform of a component in an exploded view.

'----------------------------------------------------------------------------
' Preconditions:
' 1. Open public_documents\samples\tutorial\pdmworks\speaker.sldasm.
' 2. Open the Immediate window.
'
' Postconditions:
' 1. Gets the name of the active configuration.
' 2. Creates five exploded views for the active configuration.
' 3. Gets the name of each exploded view for the active configuration
'    and shows each exploded view.
' 4. Gets the name of the exploded view shown in the model.
' 5. Selects a component and gets its collapsed transform.
' 6. Examine the Immediate window.
'
' NOTE: Because the assembly is used elsewhere, do not save changes.
'----------------------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swAssembly As SldWorks.AssemblyDoc
Dim swConfigMgr As SldWorks.ConfigurationManager
Dim swConfig As SldWorks.Configuration
Dim swComponent As SldWorks.Component2
Dim swSelectionMgr As SldWorks.SelectionMgr
Dim swTransform As SldWorks.MathTransform
Dim activeConfigName As String
Dim viewNames As Variant
Dim viewName As String
Dim i As Long
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swAssembly = swModel    
    'Get active configuration name
    Set swConfigMgr = swModel.ConfigurationManager
    Set swConfig = swConfigMgr.ActiveConfiguration
    activeConfigName = swConfig.Name    
    'Create five exploded views in the active configuration
    For i = 0 To 4
        swAssembly.CreateExplodedView
    Next i    
    'Get the name of each exploded view in the active configuration
    'and show each exploded view
    viewNames = swAssembly.GetExplodedViewNames2(activeConfigName)
    For i = 0 To UBound(viewNames)
        viewName = viewNames(i)
        swAssembly.ShowExploded2 True, viewName
    Next i    
    'Get the name of exploded view shown in model
    viewName = ""
    Set swModelDocExt = swModel.Extension
    swModelDocExt.IsExploded viewName
    Debug.Print "Name of exploded view shown in model: " & viewName    
    'Select a component and get its collapsed transform
    swModelDocExt.SelectByID2 "speaker_frame-1@speaker", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0
    Set swSelectionMgr = swModel.SelectionManager
    Set swComponent = swSelectionMgr.GetSelectedObjectsComponent4(1, -1)
    Debug.Print "  Name of component whose collapsed transform to get in the exploded view: " & swComponent.Name2
    Set swTransform = swComponent.GetSpecificTransform(True)
    Debug.Print "    Transform:"
    Debug.Print "      Rotate     = (" & swTransform.ArrayData(0) & ", " & swTransform.ArrayData(1) & ", " & swTransform.ArrayData(2) & ")"
    Debug.Print "                 = (" & swTransform.ArrayData(3) & ", " & swTransform.ArrayData(4) & ", " & swTransform.ArrayData(5) & ")"
    Debug.Print "                 = (" & swTransform.ArrayData(6) & ", " & swTransform.ArrayData(7) & ", " & swTransform.ArrayData(8) & ")"
    Debug.Print "      Translate  = (" & swTransform.ArrayData(9) & ", " & swTransform.ArrayData(10) & ", " & swTransform.ArrayData(11) & ")"
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:   Get Collapsed Transform of Component in Exploded View 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) 2024 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.