AnsweredAssumed Answered

How to get coordinate of curve?

Question asked by Yong Ning on Dec 19, 2016
Latest reply on Dec 20, 2016 by Yong Ning

Follow code ,select all line. result don't insert center line

Hope , select 2 line, insert center line

Design ideas

Choose two parallel straight lines

get line coordinate , select 2 line → insertcenterline2



Traverse Curve.jpg





Private Sub ll1()

   Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

      Set SwApp = Application.SldWorks

      Set SwModel = SwApp.ActiveDoc

   Dim SwDraw As DrawingDoc

      Set SwDraw = SwModel

   Dim SwView As View

      Set SwView = SwDraw.GetFirstView

      Set SwView = SwView.GetNextView

      SwDraw.ActivateView SwView.Name


   Dim vComps, vEdges, SwSketchLine As SketchLine

      vComps = SwView.GetVisibleComponents

      'vEdges = SwView.GetVisibleEntities(vComps(0), swViewEntityType_SilhouetteEdge)

   Dim SwEnt As Entity, SwEdge As Edge

   Dim SwCurve As Curve, SwLine



      For ii = 0 To UBound(vComps)

         vEdges = SwView.GetVisibleEntities(vComps(ii), swViewEntityType_Edge)

         For jj = 0 To UBound(vEdges)

            Set SwEdge = vEdges(jj)

            Set SwCurve = SwEdge.GetCurve

            Debug.Print SwEdge.GetID

            If SwCurve.IsLine Then

                Set SwEnt = SwEdge

                SwEnt.Select True

            End If

         Next jj

      Next ii

   Dim SwCenterLine As CenterLine

      Set SwCenterLine = SwDraw.InsertCenterLine2

End Sub