2 Replies Latest reply on Oct 13, 2018 7:07 PM by Pavlo Palagut

    Macro Issue to make a selected Drawing View hidden component Show Hidden Edges

    Pavlo Palagut

      I am trying to make a macro which will be able to make a selected Drawing View hidden component to show hidden edges (Solidworks Snip below).

      I have managed to select the required component "FL-ANSI-10-P-CS-1" with the macro shown below, but my problem is that the line:     "swDrawComp.View.SetDisplayMode3 False, swDisplayMode_e.swHIDDEN_GREYED, True, False"

      is equivalent to the click of the "Hidden Lines Visible" in a Solidworks drawing for the whole selected view and not only for one required component "FL-ANSI-10-P-CS-1", which I select with the line:

           "swDrawComp.Select True, Nothing"

       

      Thank you in advance,

      I will appreciate any ideas or thoughts...

       

       

       

      Option Explicit

      Sub main()

          Dim swApp                       As SldWorks.SldWorks

          Dim swModel                     As SldWorks.ModelDoc2

          Dim swDraw                      As SldWorks.DrawingDoc

          Dim swSelMgr                    As SldWorks.SelectionMgr

          Dim swSelData                   As SldWorks.SelectData

          Dim swModelDocExt               As SldWorks.ModelDocExtension

          Dim swView                      As SldWorks.View

          Dim swRootDrawComp              As SldWorks.DrawingComponent

          Dim vDrawChildCompArr           As Variant

          Dim vDrawChildComp              As Variant

          Dim swDrawComp                  As SldWorks.DrawingComponent

          Dim swComp                      As SldWorks.Component2

          Dim swCompModel                 As SldWorks.ModelDoc2

          Dim status                      As Boolean

          Dim strCompToShowName           As String

       

          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

          Set swDraw = swModel

          Set swModelDocExt = swModel.Extension

          Set swSelMgr = swModel.SelectionManager

          Set swSelData = swSelMgr.CreateSelectData

       

          swDraw.ActivateView ("DrawingTopView")

          status = swModelDocExt.SelectByID2("DrawingTopView", "DRAWINGVIEW", 0.104008832128, 0.1163870710783, 0, False, 0, Nothing, 0)

          Set swView = swSelMgr.GetSelectedObject6(1, -1)

          Set swRootDrawComp = swView.RootDrawingComponent

          vDrawChildCompArr = swRootDrawComp.GetChildren

       

          For Each vDrawChildComp In vDrawChildCompArr

              Set swDrawComp = vDrawChildComp

              Set swComp = swDrawComp.Component

              strCompToShowName = swComp.Name2

          

              If strCompToShowName = "FL-ANSI-10-P-CS-1" Then

                  swDrawComp.Select True, Nothing

                 swDrawComp.View.SetDisplayMode3 False, swDisplayMode_e.swHIDDEN_GREYED, True, False

              Else

              End If

          Next

      End Sub

      HiddenComponents.png

        • Re: Macro Issue to make a selected Drawing View hidden component Show Hidden Edges
          Fifi Riri

          Hello, try this:

           

          Option Explicit

          Sub main()

              Dim swApp As SldWorks.SldWorks

              Dim swDraw As SldWorks.DrawingDoc

              Dim swView As SldWorks.View

              Dim swRootDrawComp As SldWorks.DrawingComponent

              Dim vDrawChildCompArr As Variant

              Dim vDrawChildComp As Variant

              Dim swDrawComp As SldWorks.DrawingComponent

              Dim swComp As SldWorks.Component2

           

              Set swApp = Application.SldWorks

              Set swDraw = swApp.ActiveDoc

              Set swView = swDraw.ActiveDrawingView

              Set swRootDrawComp = swView.RootDrawingComponent

              vDrawChildCompArr = swRootDrawComp.GetChildren

              For Each vDrawChildComp In vDrawChildCompArr

                  Set swDrawComp = vDrawChildComp

                  Set swComp = swDrawComp.Component

                  If swComp.Name2 = "FL-ANSI-10-P-CS-1" Then

                      swDrawComp.Select True, Nothing

                      swApp.RunCommand swCommands_e.swCommands_Popup_Show_Hidden, ""

                  End If

              Next

          End Sub