CivilTechSource Posted June 8 Author Posted June 8 (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? Edited June 8 by CivilTechSource Quote
GLAVCVS Posted June 8 Posted June 8 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. Quote
BIGAL Posted June 8 Posted June 8 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. 1 Quote
CivilTechSource Posted June 21 Author Posted June 21 (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) ) Edited June 21 by CivilTechSource Quote
BIGAL Posted June 21 Posted June 21 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. Quote
Recommended Posts
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.