Jump to content

Recommended Posts

Posted

Is there a way to extend a horizonal line or lines to the nearest vertical line?

Basically here is my scenario in the image below.

You start the lisp, click at the Green point 1 then click at the green point 2.

The lisp then adds 2" to the length at pt2 then drops 4" then returns the length.

This part I can code using polar and the angles / lengths to draw the pline.

The part I dont know is how can I extend the pline at pt1 (in green) and the end of the pline to the closest vertical red line so it looks like the image below? The distance between pt1 (in green) and the vertical red line is an unknown variable distance.

image.png.3ea86101d5a1ba1ad7255bcfbed88ddf.png

 

Any thoughts to help me out would be great, thanks,

Posted

@BlackBox

Thanks for the suggestion.

To my understanding though, the IntersectWith method requires the user to select the line (in my case the red vertical line) to extend to.

I would prefer this to be seamless and extend after all pick points are complete to the first available line without having to select it.

Sort of like hitting enter twice after entering the extend command. 

 

Posted (edited)
33 minutes ago, Strydaris said:

@BlackBox

Thanks for the suggestion.

To my understanding though, the IntersectWith method requires the user to select the line (in my case the red vertical line) to extend to.

I would prefer this to be seamless and extend after all pick points are complete to the first available line without having to select it.

Sort of like hitting enter twice after entering the extend command. 

 

To extend an existing line, you must obtain it's ename/vla-object... which means it must be selected.

 

That said, consider (ssget "+.:E:S") or (ssget "_:E"), which will allow you to specify a point to select the line.

Edited by BlackBox
Posted

Hi @BlackBox

 

I am not looking to extend an existing line. I want to extend TO an existing line.

Posted (edited)
20 hours ago, Strydaris said:

The part I dont know is how can I extend the pline at pt1 (in green) and the end of the pline to the closest vertical red line so it looks like the image below? The distance between pt1 (in green) and the vertical red line is an unknown variable distance.

15 hours ago, Strydaris said:

Hi @BlackBox

 

I am not looking to extend an existing line. I want to extend TO an existing line.

You cannot extend a line that doesn't exist - you can only create a new line and extend that, if needed.

 

You've not posted any code, so hard to see where you're stuck. 

 

If P2 is on an existing vertical line, you can create a new line from P1 to P2 + 2" using polar and continue your routine. 

 

If P2 is on an existing vertical line, but not ortho-aligned with P1's Y, then after you prompt for P1, select the existing line using the above-mentioned ssget filters, calculate the point of intersection (P3) ** to create a line from P1 to P3 + 2" using polar and continue your routine. 

 

** [Edit] - or just extract the P2 X and use the P1 Y to calculate P3

 

HTH

Edited by BlackBox
Posted

If I understand correct, like @BlackBoxas suggested, you can pick a line/pline near an end, this in turn can be used to determine a direction to extend in, ok it is not that straight forward, you would use say a dummy line and get objects that cross that say horizontal line, look for say closest using intersectwith, ask is this OK, then if you want a left and right repeat for other side. And draw your Red rectang. You would just limit the length of the dummy line so you don't get to many other objects.

 

Ok for a line as it looks like you want a left and right easy draw a new line extending out from start and end points of the line picked. Then use (SSGET "F" pts...  to get the other line/plines. You may get more than one but you can do a sort on the distance from a say end to the new points and use correct one.

 

For a pline its a bit harder but you use get pline segment then again extend dummy line out from the two segment points. Again sort points.

 

Yes it can be done, really need a real dwg to give more hints and maybe some code. MM or feet is important.

 

image.png

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...