2 Replies Latest reply on May 14, 2015 1:36 PM by Hersh Sridhar Iyer

    How do I fetch the visible edge of a dome in a drawing view?

    Hersh Sridhar Iyer



      I am facing an issue while trying to retrieve the visible edges of a part containing a dome. The attached part has two bodies, one with a dome and without. When I take the bottom view of this part, I see two edges in the view as expected. However, when I query the view through GetVisibleEntities(), I get only 1 edge (which is the edge from the body without the dome). Is there any way to retrieve the edge of the dome in the view? I need this in order to dimension the dome width in the bottom view and to take a detail view around it.

      Part and drawing file attached.




        • Re: How do I fetch the visible edge of a dome in a drawing view?
          Simon Turner

          Sounds like you might need GetVisibleEntities2:


          The difference between this method and the now obsolete IView::GetVisibleEntities method is that this method supports silhouette edges (EntityType = swViewEntityType_e.swViewEntityType_SilhouetteEdge).

            • Re: How do I fetch the visible edge of a dome in a drawing view?
              Hersh Sridhar Iyer

              You are party correct. I had tried GetVisibleEntities2 with EntityType = swViewEntityType_e.swViewEntityType_SilhouetteEdge but that did return the dome edges as well.


              I posted this question to API Support as well and they (Abhay Kharade) got back with the right way to get this edge. The view display state is set to "Hidden Lines Removed" and this is preventing the Silhouette edges from being returned. To get the dome edges, the view display state should be set to "Wireframe". This will ensure that the dome edges are returned when the Entity type is swViewEntityType_SilhouetteEdge. Attaching a macro for reference.


              Dim swApp As Object

              Sub main()

              Dim swModel As SldWorks.ModelDoc2

              Set swApp = Application.SldWorks

                  Dim swSelMgr As SldWorks.SelectionMgr

                  Dim swDrawing As SldWorks.DrawingDoc

                  Dim drView As SldWorks.View

                  Dim Comp As SldWorks.Component2

                  Dim selData As SldWorks.SelectData

                  Dim ent As SldWorks.Entity

                  Dim itr As Long

                  Dim CompCount As Long

                  Dim vComps As Variant

                  Dim vEdges As Variant

                  Dim vHiddenEdges As Variant

                  Dim vVerts As Variant

                  Dim vFaces As Variant

                  Dim vSilhouetteEdges As Variant

                  Dim i As Long

                  Dim boolstatus As Boolean


                  Set swModel = swApp.ActiveDoc

                  Set swDrawing = swModel

                  Set swSelMgr = swModel.SelectionManager

                  Set drView = swDrawing.ActiveDrawingView



                  Debug.Assert Not drView Is Nothing

                  Debug.Print "Name of drawing view: "; drView.GetName2


                  CompCount = drView.GetVisibleComponentCount 

                  Debug.Assert CompCount <> 0

                  Debug.Print "Number of visible components = "; CompCount

                  vComps = drView.GetVisibleComponents

                   Debug.Assert Not IsEmpty(vComps)

                   For i = LBound(vComps) To UBound(vComps)

                      swModel.ClearSelection2 True

                      Debug.Print ""

                      Debug.Print "Component " & i & " name is " & vComps(i).Name2


                      Set Comp = vComps(i)


                      'Get all edges of this component that are visible in this drawing view

                      vEdges = drView.GetVisibleEntities2(Comp, swViewEntityType_Edge)

                      Set selData = swSelMgr.CreateSelectData

                      selData.View = drView

                      If IsEmpty(vEdges) Then

                          Debug.Print "   No edges."


                          Debug.Print "   This component has " & UBound(vEdges) + 1 & " visible edges in this view."

                          For itr = 0 To UBound(vEdges)

                              Set ent = vEdges(itr)

                              boolstatus = ent.Select4(False, selData)

                          Next itr

                      End If

                      'Get all silhouette edges of this component that are visible in this drawing view

                      vSilhouetteEdges = drView.GetVisibleEntities2(Comp, swViewEntityType_SilhouetteEdge)

                      Dim silEdge As SldWorks.SilhouetteEdge

                      If IsEmpty(vSilhouetteEdges) Then

                          Debug.Print "   No silhouette edges."


                          Debug.Print "   This component has " & UBound(vSilhouetteEdges) + 1 & " visible silhouette edges in this view."

                           For itr = 0 To UBound(vSilhouetteEdges)

                              Set silEdge = vSilhouetteEdges(itr)

                              boolstatus = silEdge.Select(False, selData)

                          Next itr

                      End If

                  Next i





              End Sub