Jump to content

From Centre of the Block draw a polyline to another polyline and to land at 30 degree.


Recommended Posts

Posted (edited)

@GLAVCVS When you phrase it like that it makes total sense! So I presume these will be the steps:

1) Add all blocks to a list (SelectedBlockList)

2) Add all polylines to a list (SelectedPolylineList)

3) Take one block at a time and find the closest polyline segment to it. Will the be a while loop?

4) Once found the nearest polyline, we can use GetClosestPoint to find the closest point

5) Since its a 45 degree angle we are looking at, the 45 degree point along the closest polyline would be equally to ClosestPoint + ClosestDistance. (See image below). So How do i write in lisp closest point on a polyline + a distance?

 

*Fool Proofing Idea: Would it be best to make sure the lisp can accept an angle from the user? So it can work on any given angle?

 

image.thumb.png.5f758d9958eda9dd79cd710c22eb272a.png

Edited by CivilTechSource
Posted

GetClosestPoint will look for the closest point on any polyline segment. But it won't return the passing point of the segment closest to the block's location. You'll need to ask the AI to suggest code to obtain that.

 

What GetClosestPoint can do is help you find the closest polyline by means of the nearest segment point. You could iterate over all the polylines to detect which one has the closest point.

Posted

My To do list is getting bigger, as I said before there are 3 choices a 45 line, a got to vertice or got to next segment. Will try to find some time look at image May 22, shows 2 possible solutions.

  • Like 1
  • 2 weeks later...
Posted (edited)

@BIGAL The code you wrote make absolute sense in theory. However, for whatever reason autocad decides randomly to either draw a perpendicular line or a line with a steeper angle. Before its starts doing the calculations I made sure I cleared all the values. But still sometimes it draws lines that should not be. When I debug it it seems to work fine, when I load it and run it without monitoring seems to not follow the structure. Is the vlax-curve-getpointatdist or vlax-curve-getclosestpointo? 

 

(defun c:gully46 ( / )
  (setq SelectedPolylines (vlax-ename->vla-object (car (entsel "\nPick Drainage Polyline:"))))
  (while (setq ent (car (entsel "\nSelect Gully:")))
    (setq ClosestDistance 0)
    (setq DistanceClosestPt 0)
    (setq ClosestPt nil)
    (setq IntersectionPt nil)
    (setq BlockPt nil)

    (setq SelectedObject (vlax-ename->vla-object ent))
    (setq BlockPt (vlax-get SelectedObject 'insertionpoint))
    (setq ClosestPt (vlax-curve-getclosestpointto SelectedPolylines BlockPt))
    (setq ClosestDistance (distance BlockPt ClosestPt))
    (print ClosestDistance)
    (setq DistanceClosestPt (vlax-curve-getdistatpoint SelectedPolylines ClosestPt))
    (print DistanceClosestPt)
    (setq IntersectionLength (+ DistanceClosestPt ClosestDistance))
    (print IntersectionLength)
    (setq IntersectionPt (vlax-curve-getpointatdist SelectedPolylines IntersectionLength))
    (command "pline" BlockPt IntersectionPt "")
)
(princ)
)

image.thumb.png.1eb44be97583aa7252f9b09bb9d7cadc.png

Edited by CivilTechSource
Posted

Can you post dwg it may be that the end point is on the next section of the pline and not working that out correct.

 

Yes need to go back to it and do some texting and add match to vertex.

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