Jump to content

Recommended Posts

Posted

Hi All

 

first post as google & forum searches usually net what i'm chasing, but this is beyond me.

 

I have some code (previously posted by ASMI here) that returns the coordinates of each vertex in a polyline.

 

I now want to loop through this list and check for an an intersection between each segment of a polyline and 2 other points

 

what i have so far gets me the two endpoints, but from here i haven't a clue

 

(defun c:asdf (/ whoa pts ep1 ep2)
 (setq whoa (mapcar 'cdr(vl-remove-if '(lambda(x)(/= 10(car x)))(entget(car(entsel))))))
(setq pts (cdr whoa))
(setq ep1 (car pts))
(setq ep2 (cadr pts))
 (princ)
)

Posted

I'd suggest you use the 'nth' function to retrieve needed points from list. Get length of list with 'length' function. Set up a counter; first time through use pt1 & pt2; then pt2 & pt3; up through last point.

Posted

Thanks CarlB

 

you gave me an idea to use a 'while' in there with the length check

 


(defun c:asdf (/ whoa pts ep1 ep2)
 (setq pts (mapcar 'cdr(vl-remove-if '(lambda(x)(/= 10(car x)))(entget(car(entsel))))))
(while (>= (length pts) 2)
(setq ep1 (car pts))
(setq ep2 (cadr pts))
 	(setq pts (cdr pts))
(princ)
)
)

 

does this seem ok? i've never looped before

 

i also realised that my first lot of code stripped off the first vertex...oops

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