1 Reply Latest reply on Dec 21, 2016 4:57 AM by Yong Ning

    How to get coordinate of curve?

    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

        • Re: How to get coordinate of curve?
          Yong Ning

          Private Sub del20161221()

              Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                  Set SwApp = Application.SldWorks

                  Set SwModel = SwApp.ActiveDoc

              Dim SwDraw As DrawingDoc

                  Set SwDraw = SwModel

              Dim SwSelMgr As SelectionMgr

                  Set SwSelMgr = SwModel.SelectionManager

              Dim SwView As View

                  Set SwView = SwSelMgr.GetSelectedObject5(1)

              Dim vComponts, vEdges

              Dim SwEdge As Edge, SwCurve As Curve, SwEnt As Entity

              'Dim swCurveParaData As SldWorks.CurveParamData

              Dim vLineParam, xx As Double, yy As Double, zz As Double

                  vComponts = SwView.GetVisibleComponents

                  For ii = 0 To UBound(vComponts)

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

                      For jj = 0 To UBound(vEdges)

                           Set SwEdge = vEdges(jj)

                           Set SwCurve = SwEdge.GetCurve

                           If SwCurve.IsLine Then

                               vLineParam = SwCurve.LineParams

                               ''

                               xx = vLineParam(0)

                               yy = vLineParam(1)

                               zz = vLineParam(2)

                               Debug.Print 0.225 = Abs(yy),

                               ''

                               Debug.Print ii, jj, xx, yy, zz

                               'If Val(Abs(yy)) = 0.225 Then

                               Debug.Print IsNumeric(Abs(yy)), VarType(yy), VarType(Abs(yy))

                               If Abs(yy) = 0.225 Then

                                 Set SwEnt = SwEdge

                                 SwEnt.Select True

                               End If

                           End If

                      Next jj

                  Next ii

                  ''

                  SwDraw.InsertCenterLine2

          End Sub