Jump to content

Create Line from Intersecting Point


Recommended Posts

Posted

Hi all,

 

I have three polylines. Two of these intersect and make something like an X. My third polyline does not intersect with these two. Now, I want to create a perpendicular line start point being the intersection point of these two lines.

 

Any help would be appreciated.

 

Thanks and Regards,

Priyanka

Posted

............

Command: line

Specify first point: int

of (select intersection)

Specify next point or [undo]: per

to (select third line)

Posted

I'm assuming you mean perpendicular to the third line that does not intersect the other two - like attached?

example.jpg

Posted

Do you really need a LISP to accomplish this - is it not just easier to draw the line yourself, as I have done in the example?

 

lpseifert has shown you how in his above post...

Posted

Yes i do need a code for it because i have hundereds of such points.. and actually i would need a VBA code for this...

 

 

and one more thing...

i wanted the coordinates where the lines intersect.. The code i was using is below.. The code was working perfectly well when all of a sudden i started getting this error

 

" Runtime-error '-2145320923(8021001c)

AutoCAD main window is invisible" .. How do i get rid of this error!

 

I am just 2 days old to AutoCAD VBA and i have no idea what does this error mean

 

 

Please Help!!

 

 

The code i am using is:

// Get INTERSECTION POINTS

 

Sub GetIntersectionPoints()

Dim SOS As AcadSelectionSet

Dim objSS As AcadSelectionSet

For Each SOS In ThisDrawing.SelectionSets

If SOS.Name = "MySS" Then

ThisDrawing.SelectionSets("MySS").Delete

Exit For

End If

Next

ThisDrawing.SelectionSets.Add ("MySS")

Set objSS = ThisDrawing.SelectionSets("MySS")

objSS.SelectOnScreen

'Filter Lines and polylines only

Dim ArrayToRemove() As AcadEntity

Dim objEnt As AcadEntity

Dim Num As Integer

Num = -1

For Each objEnt In objSS

If objEnt.ObjectName "AcDbLine" And objEnt.ObjectName "AcDbPolyline" Then

Num = Num + 1

If Num = 0 Then

ReDim ArrayToRemove(0)

Else

ReDim Preserve ArrayToRemove(Num)

End If

Set ArrayToRemove(Num) = objEnt

End If

Next

objSS.RemoveItems ArrayToRemove

If objSS.Count > 0 Then

Else

MsgBox "No lines and polylines selected!"

Exit Sub

End If

Dim ArrayWithCoordinates() As Double

Num = -1

Dim i As Integer

Dim j As Integer

Dim k As Integer

Dim Pts As Variant

For i = 0 To objSS.Count - 2

For j = i + 1 To objSS.Count - 1

Pts = objSS(i).IntersectWith(objSS(j), acExtendNone)

If UBound(Pts) > -1 Then

For k = 0 To UBound(Pts)

Num = Num + 1

If Num = 0 Then

ReDim ArrayWithCoordinates(0)

Else

ReDim Preserve ArrayWithCoordinates(Num)

End If

ArrayWithCoordinates(Num) = Pts(k)

Next

End If

Next

Next

'get the lines and polylines selected for beter user visualisation

For i = 0 To objSS.Count - 1

objSS(i).Highlight True

Next

 

'Display coordinates of all intersection points

Dim MessageArray As String

MessageArray = ""

If Num > -1 Then

For i = 0 To UBound(ArrayWithCoordinates) - 2 Step 3

MessageArray = MessageArray & ArrayWithCoordinates(i) & _

", " & ArrayWithCoordinates(i + 1) & ", " & ArrayWithCoordinates(i + 2) & vbCr

Next

MsgBox MessageArray, , "Coordinates of intersection points"

Else

MsgBox "No intersection points found"

End If

End Sub

 

 

 

Thanks and Regards,

Priyanka

Posted

Hi again..

I have found the solution to get rid of that idotic runtime error.. i just had to make that form non-modal

 

Anyways still i want a VBA code for creating perpendicular line from intersection point.

 

Thanks and Regards,

Priyanka

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...