kymba Posted January 29, 2009 Posted January 29, 2009 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) ) Quote
CarlB Posted January 29, 2009 Posted January 29, 2009 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. Quote
kymba Posted January 29, 2009 Author Posted January 29, 2009 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 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.