Hide Table of Contents

SOLIDWORKS API Help

Add Multibody Part Explode Step Example (VB.NET)

This example shows how to create an explode view of a multibody part.

'-----------------------------------------------------------------------------

' Preconditions:

' 1. Open public_documents\samples\tutorial\multibody\multi_Inter.sldprt.

' 2. Open an Immediate window.

'

' Postconditions:

' 1. Creates Exploded View1 in ConfigurationManager.

' 2. Adds Chain1 to Exploded View1.

' 3. Displays the Exploded View1 in its exploded state.

' 4. Inspect the Immediate window, the ConfigurationManager,

'    and the graphics area.

'

' Note: Because the model is used elsewhere, do not save any changes. 

'----------------------------------------------------------------------------

Imports SolidWorks.Interop.sldworks

Imports SolidWorks.Interop.swconst

Imports System.Runtime.InteropServices

Imports System

 

 

Partial Class SolidWorksMacro

 

    Sub main()

 

        Dim swModel As PartDoc

 

        Dim config As Configuration

 

        Dim configName As String

 

        Dim swMdl As ModelDoc2

 

        Dim explStep As PartExplodeStep

 

        Dim comp As Body2

 

        Dim var As Object

 

        Dim varViews As Object

 

        Dim configVar As Object

 

        Dim boolstatus As Boolean

 

        Dim i As Long

 

        Dim errCode As Long

 

        swModel = swApp.ActiveDoc

 

        swMdl = swModel

 

 

        configVar = swMdl.GetConfigurationNames

 

 

        Call swModel.CreateExplodedView

 

 

        varViews = swModel.GetExplodedViewNames(configVar(0))

 

        configName = swModel.GetExplodedViewConfigurationName(varViews(0))

 

        config = swMdl.GetConfigurationByName(configName)

 

 

        swModel.ShowExploded(True, varViews(0))

 

 

 

        'Select the bodies to move

 

        boolstatus = swMdl.Extension.SelectByID2("Extrude-Thin1", "SOLIDBODY", 0, 0, 0, True, 1, Nothing, 0)

 

 

 

        'Add an explode step without selecting an explode direction entity

 

        'Defaults to the Z-direction manipulator index

 

        explStep = config.AddPartExplodeStep("Exploded View1", 0.07, -1, False, True, errCode)

 

 

        Call swMdl.EditRebuild3

 

 

        'Get bodies moved in the explode step

 

        var = explStep.GetBodies()

 

 

        Debug.Print("Explode view: " & varViews(0))

 

        Debug.Print("Explode step: " & explStep.Name)

 

        Debug.Print("Explode distance (m): " & explStep.ExplodeDistance)

 

        Debug.Print("Reverse translation direction? " & explStep.ReverseTranslationDirection)

 

        Debug.Print("Automatically space components on drag? " & explStep.AutoSpaceBodiesOnDrag)

 

 

 

        Debug.Print("Bodies moved in the explode step:")

 

        For i = 0 To UBound(var)

 

            comp = var(i)

 

            Debug.Print("  " & comp.Name)

 

        Next

 

 

 

    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

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Add Multibody Part Explode Step Example (VB.NET)
*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) 2020 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.