5 Replies Latest reply on Sep 13, 2018 2:37 PM by Niels Raahauge

    SWD  - View exploded?

    Niels Raahauge

      I need to check - is drawing containing a exploded view .

      With use of swView.ReferencedConfiguration i can get the configuration name in the view. How can I get information about "Show in exploded or model break state" ?

      (Write a code line with used object dim and set, please)

       

      Code to get configuration in view:

      http://help.solidworks.com/2016/english/api/sldworksapi/get_configurations_referenced_in_view_example_vb.htm

       

      SW2016SP4

        • Re: SWD  - View exploded?
          Niels Raahauge

          This code investigate the ref doc in a swd for exploded - I need to check the view on the drawing.

           

          ' open a drawing

          ' 1. Gets the name of the document referenced in drawing view.

          ' 2. Examine the referenced document for exploded configuration

           

           

          Option Explicit

           

          Sub main()

           

              Dim swApp As SldWorks.SldWorks

              Dim swModel As SldWorks.ModelDoc2

              Dim swSelMgr As SldWorks.SelectionMgr

              Dim swView As SldWorks.View

              Dim swDrawModel As SldWorks.ModelDoc2

              Dim swDraw  As SldWorks.DrawingDoc

              Dim sModelName  As String

           

           

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              Set swDraw = swModel

              Set swSelMgr = swModel.SelectionManager

              Set swView = swModel.GetFirstView 'first view

              Set swView = swView.GetNextView

              Set swDrawModel = swView.ReferencedDocument

           

           

              sModelName = swView.GetReferencedModelName

           

           

              Debug.Print "Drawing File              = " & swModel.GetPathName

              Debug.Print "  View                    = " & swView.Name

              Debug.Print " Referenced model name = " & sModelName

              Debug.Print "    Model path            = " & swDrawModel.GetPathName

           

           

             'Contain the referenced model exploded

           

           

             Dim swConfigurationMgr As SldWorks.ConfigurationManager

             Dim swConfiguration As SldWorks.Configuration

             Dim swExplodeStep As SldWorks.ExplodeStep

             Dim AssmContainExplodedViews As Boolean

           

           

              'Set swModel = swApp.ActiveDoc

             

              On Error GoTo errorHandler

             

              'Get explode step

              Set swConfigurationMgr = swDrawModel.ConfigurationManager  'WHY CAN I NOT REF TI REFERENCED DOCUMENT?

              Set swConfiguration = swConfigurationMgr.ActiveConfiguration

              Set swExplodeStep = swConfiguration.GetExplodeStep(0)

             

              Debug.Print "Name of explode step: " & swExplodeStep.Name

              AssmContainExplodedViews = True

              'Debug.Print "Number of components that move in this explode step: " & swExplodeStep.GetNumOfComponents

              'Debug.Print "Is the sub-assembly rigid? " & swExplodeStep.IsSubAssemblyRigid

             

          errorHandler:

              If Err = 91 Then

              AssmContainExplodedViews = False

              End If

             

              Debug.Print "exploded view in assm   :"; AssmContainExplodedViews

          End Sub

          • Re: SWD  - View exploded?
            Glenn Schroeder

            I'd suggest you move this Discussion to the API section of the forum.  The people that can help with code will be more likely to see it there.  Please don't start a new Discussion in that section.  There's a "Move" link at the top right of this page.