Hide Table of Contents

Get Exploded Views for Configuration Example (VB.NET)

This example shows how to get:

  • number of exploded views for a configuration.
  • name of each exploded view for a configuration.
  • name of the configuration for each exploded view.
  • name of the exploded view shown in the model.
' 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 number of exploded views for the active configuration.
' 4. Gets the name of:
'    * each exploded view for the active configuration
'    * configuration for each exploded view
'    and shows each exploded view.
' 5. Gets the name of the exploded view shown in the model.
' 6. Examine the Immediate window.
' NOTE: Because the assembly is used elsewhere, do not save changes.
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics
Partial Class SolidWorksMacro
    Public Sub main()
        Dim swModel As ModelDoc2
        Dim swModelDocExt As ModelDocExtension
        Dim swAssembly As AssemblyDoc
        Dim swConfigMgr As ConfigurationManager
        Dim swConfig As Configuration
        Dim activeConfigName As String
        Dim viewNames() As String
        Dim viewName As String
        Dim i As Integer
        swModel = swApp.ActiveDoc
        swAssembly = swModel
        'Get active configuration name
        swConfigMgr = swModel.ConfigurationManager
        swConfig = swConfigMgr.ActiveConfiguration
        activeConfigName = swConfig.Name
        Debug.Print("Active configuration name: " & activeConfigName)
        'Create five exploded views in the active configuration
        For i = 0 To 4
        Next i
        'Get the number of exploded views in the active configuration name
        Debug.Print("  Number of exploded views created: " & swAssembly.GetExplodedViewCount2(activeConfigName))
        'Get the name of each exploded view in the active configuration,
        'get the name of the configuration for each exploded view, and
        'show each exploded view
        viewNames = swAssembly.GetExplodedViewNames2(activeConfigName)
        For i = 0 To UBound(viewNames)
            viewName = viewNames(i)
            Debug.Print("    Exploded view name: " & viewName)
            Debug.Print("      Name of configuration for exploded view: " & swAssembly.GetExplodedViewConfigurationName(viewName))
            swAssembly.ShowExploded2(True, viewName)
        Next i
        'Get the name of exploded view shown in model
        viewName = ""
        swModelDocExt = swModel.Extension
        Debug.Print("Name of exploded view shown in model: " & viewName)
    End Sub
    ''' <summary>
    ''' The SldWorks swApp variable is pre-assigned for you.
    ''' </summary>
    Public swApp As SldWorks
End Class

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

Subject:   Feedback on Help Topics
Page:   Get Exploded Views for Configuration Example (VB.NET)
*   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:


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

Web Help Content Version: API Help (English only) 2018 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.