6 Replies Latest reply on Mar 7, 2017 5:10 PM by Ivana Kolin

    How to get the coordinate of the all line intersections in the 3d sketch?

    Frank Wu Frank Wu

      Hello,

                 How to get the coordinate of the all line intersections in the 3d sketch? Any ideas?

       

      1.png

        • Re: How to get the coordinate of the all line intersections in the 3d sketch?
          John Alexander

          What about using that "Fully Define Sketch" tool? I know it is virtually useless in my experience but I remember that it has the option of detecting constraints. It might recognize intersections and add coincident constraints. This would probably be limited to intersections between end points and line segments.

           

          Although, I'm not even sure if it is available in 3D sketches.

          • Re: How to get the coordinate of the all line intersections in the 3d sketch?
            S. Casale

            What John A. said may help... Although, not likely allowing you to control as freely as you may want for modification.

             

            That's a lot of lines to try to control. I would figure out which lines are the base lines fully define them, and then mate the additional lines as needed.

            • Re: How to get the coordinate of the all line intersections in the 3d sketch?
              Dan Pihlaja

              I assume you mean automatically get the coordinates, well, outside of a macro, I am not sure how.

               

              HOWEVER:

               

              If you select each intersection, the coordinates are listed at the bottom:

              • Re: How to get the coordinate of the all line intersections in the 3d sketch?
                Frank Wu Frank Wu

                In fact,i want to Break lines at intersection points with function "split entity",but I found that this can not be achieved, if anyone has any suggestions, please let me know, thank you!

                1.png

                  • Re: How to get the coordinate of the all line intersections in the 3d sketch?
                    Ivana Kolin

                    you mean this?

                    Option Explicit
                    Const numdecimalplaces                            As Integer = 3
                    Public Enum swSketchSegments_e
                        swSketchLINE = 0
                        swSketchARC = 1
                        swSketchELLIPSE = 2
                        swSketchSPLINE = 3
                        swSketchTEXT = 4
                        swSketchPARABOLA = 5
                    End Enum
                    Sub main()
                        Dim swApp                                     As SldWorks.SldWorks
                        Dim swModel                                   As SldWorks.ModelDoc2
                        Dim swSkMgr                                   As SldWorks.SketchManager
                        Dim swSketch                                  As SldWorks.Sketch
                        Dim i                                         As Long
                        Dim j                                         As Long
                        Dim vSketchSeg                                As Variant
                        Dim swSketchSegi                              As SldWorks.SketchSegment
                        Dim swSketchSegj                              As SldWorks.SketchSegment
                        Dim nDist                                     As Double
                        Dim vPoint1                                   As Variant
                        Dim vPoint2                                   As Variant
                        Dim swMathUtil                                As SldWorks.MathUtility
                        Set swApp = Application.SldWorks
                        Set swModel = swApp.ActiveDoc
                        Set swMathUtil = swApp.GetMathUtility
                        Set swSkMgr = swModel.SketchManager
                        Set swSketch = swSkMgr.ActiveSketch
                        If swSketch Is Nothing Then Exit Sub
                        vSketchSeg = swSketch.GetSketchSegments
                        For i = 0 To UBound(vSketchSeg) - 1
                            Set swSketchSegi = vSketchSeg(i)
                            ' Ignore construction lines and text
                            If swSketchTEXT <> swSketchSegi.GetType And swSketchSegi.ConstructionGeometry = False Then
                                For j = i + 1 To UBound(vSketchSeg)
                                    Set swSketchSegj = vSketchSeg(j)
                                    If swSketchTEXT <> swSketchSegj.GetType And swSketchSegj.ConstructionGeometry = False Then
                                        nDist = swModel.ClosestDistance(swSketchSegi, swSketchSegj, vPoint1, vPoint2)
                                        If Round(nDist * 1000, numdecimalplaces) = 0 Then
                                            swSketchSegi.Select4 False, Nothing
                                            swSkMgr.SplitOpenSegment vPoint1(0), vPoint1(1), vPoint1(2)
                                            swSketchSegj.Select4 False, Nothing
                                            swSkMgr.SplitOpenSegment vPoint1(0), vPoint1(1), vPoint1(2)
                                        End If
                                    End If
                                Next j
                            End If
                        Next i
                    End Sub