+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Forum Newbie
    Discipline
    Electrical
    Using
    AutoCAD 2018
    Join Date
    Aug 2017
    Posts
    7

    Default List of intersection lines

    Registered forum members do not see this ad.

    Hello

    I know that ı am able to find a point where two lines are intersected eachother with this command '"object1.IntersectWith(IntersectObjects, ExtendOption)"


    Dim mainLine As AcadLine
    Dim line1, line2,line3 As AcadLine

    i have mainline information. ı want find other lines which are intersected with the main line .

    for example line1,line2 and line3 are intersected with main line, ı want to find these lines.



  2. #2
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    534

    Default

    Here's a quick one:
    Code:
    (vl-load-com)
    (defun c:foo (/ e)
      (and (setq e (car (entsel "\Pick your line: ")))
           (= "LINE" (cdr (assoc 0 (entget e))))
           (sssetfirst
    	 nil
    	 (ssget "_F" (list (vlax-curve-getstartpoint e) (vlax-curve-getendpoint e)) '((0 . "line")))
           )
      )
      (princ)
    )

  3. #3
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Oct 2012
    Posts
    293

    Default

    Sample
    Code:
    Public Sub TEST_SelectByIntersection()
      Dim objSS As AcadSelectionSet
      Dim objToCheck As AcadEntity
      Dim varPnt As Variant
      Dim objThatIntersects As AcadEntity
      ThisDrawing.Utility.GetEntity objToCheck, varPnt, "Select an object: "
      Set objSS = SelectByIntersection(objToCheck)
      For Each objThatIntersects In objSS
        objThatIntersects.Highlight True
      Next
      If MsgBox("Object " & CStr(objSS.Count) & _
                " Object." & vbCrLf & "Delete?", _
                vbQuestion + vbYesNo, "TEST_SelectByIntersection") = vbYes Then
        For Each objThatIntersects In objSS
          objThatIntersects.Delete
        Next
      Else
          For Each objThatIntersects In objSS
            objThatIntersects.Highlight False
          Next
      End If
    End Sub
    
    Public Function SelectByIntersection(objEnt As AcadEntity) As AcadSelectionSet
      
      On Error Resume Next
      Dim objGen As AcadEntity
      Dim objSelSet As AcadSelectionSet
      Dim objSelCol As AcadSelectionSets
      Dim objArray() As Object
      Dim strName As String
      Dim varMin As Variant
      Dim varMax As Variant
      Dim varIntPnt As Variant
      Dim intcnt As Integer
    
      objEnt.GetBoundingBox varMin, varMax
      strName = "vbdintersect"
      Set objSelCol = ThisDrawing.SelectionSets
        For Each objSelSet In objSelCol
          If objSelSet.Name = strName Then
            ThisDrawing.SelectionSets.Item(strName).Delete
            Exit For
          End If
        Next
      Set objSelSet = ThisDrawing.SelectionSets.Add(strName)
      objSelSet.Select acSelectionSetCrossing, varMin, varMax
      For Each objGen In objSelSet
        varIntPnt = objEnt.IntersectWith(objGen, acExtendNone)
        
        MsgBox "1 intersection point dedected." & vbCr & _
        "X= " & varIntPnt(0) & ", " & "Y= " & varIntPnt(1) & vbCr, _
        vbInformation, "Intersection Point Dedector"
        
        
        If UBound(varIntPnt) = -1 Then
          ReDim Preserve objArray(intcnt)
          Set objArray(intcnt) = objGen
          intcnt = intcnt + 1
        End If
        varIntPnt = Empty
      Next
      If IsEmpty(objArray) Then
        Set SelectByIntersection = objSelSet
      Else
        objSelSet.RemoveItems objArray
        Set SelectByIntersection = objSelSet
      End If
    Exit_Here:
      Exit Function
      MsgBox Err.Description
      Resume Exit_Here
    End Function

  4. #4
    Forum Newbie
    Discipline
    Electrical
    Using
    AutoCAD 2018
    Join Date
    Aug 2017
    Posts
    7

    Default

    this code very good working . but I do not understand the autolisp. How to write this code in vb.net / vba or C#.net

  5. #5
    Forum Newbie
    Discipline
    Electrical
    Using
    AutoCAD 2018
    Join Date
    Aug 2017
    Posts
    7

    Default

    Quote Originally Posted by ronjonp View Post
    Here's a quick one:
    Code:
    (vl-load-com)
    (defun c:foo (/ e)
      (and (setq e (car (entsel "\Pick your line: ")))
           (= "LINE" (cdr (assoc 0 (entget e))))
           (sssetfirst
    	 nil
    	 (ssget "_F" (list (vlax-curve-getstartpoint e) (vlax-curve-getendpoint e)) '((0 . "line")))
           )
      )
      (princ)
    )
    this code very good working. but I do not understand the autolisp. How to write this code in vb.net / vba or C#.net

  6. #6
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Oct 2012
    Posts
    293

    Default

    raise your eyes

  7. #7
    Forum Newbie
    Discipline
    Electrical
    Using
    AutoCAD 2018
    Join Date
    Aug 2017
    Posts
    7

    Default

    Quote Originally Posted by maratovich View Post
    raise your eyes
    Why did i say something wrong ?

  8. #8
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Oct 2012
    Posts
    293

    Default

    Quote Originally Posted by ursan View Post
    Why did i say something wrong ?
    I wrote an example for you VBA
    But you do not see my example ?

  9. #9
    Forum Newbie
    Discipline
    Electrical
    Using
    AutoCAD 2018
    Join Date
    Aug 2017
    Posts
    7

    Default

    Quote Originally Posted by maratovich View Post
    I wrote an example for you VBA
    But you do not see my example ?
    I saw your example. But when the lines have different angles they do not find all the lines.

  10. #10
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    534

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by ursan View Post
    this code very good working. but I do not understand the autolisp. How to write this code in vb.net / vba or C#.net
    Sorry .. don't know those languages.

Similar Threads

  1. List of points of intersection of polygons area
    By qualitysof in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 31st Oct 2016, 02:10 am
  2. Points Inserts at intersection of Lines & at End of lines
    By structo in forum AutoLISP, Visual LISP & DCL
    Replies: 19
    Last Post: 21st Oct 2016, 10:26 am
  3. List of Intersection stations of a long polyline
    By sivapathasunderam in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 20th Feb 2016, 03:07 pm
  4. Cant get intersection between 2 lines
    By lufc100 in forum AutoCAD Beginners' Area
    Replies: 7
    Last Post: 12th Feb 2013, 08:05 pm
  5. find intersection of 3D lines
    By giskumar in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 7th Jan 2013, 12:58 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts