dmaeda Posted May 26, 2021 Posted May 26, 2021 Hello, I found this code to get the coordinates x,y,z from a polyline. The return "l" variable looks like a list, but I'm not sure it is. CODE (setq en (car (entsel "\nselect pline:"))) (repeat (setq i (fix (1+ (vlax-curve-getEndParam en)))) (setq l (cons (trans (vlax-curve-getPointAtParam en (setq i (1- i))) 0 1) l)) ) OUTPUT EXAMPLE ((5042.86 123.33 5394.06) (3822.86 123.33 5394.06) (3842.86 123.33 5174.06) (3602.86 123.33 5174.06) (3622.86 123.33 4954.06) (3382.86 123.33 4954.06) (3402.86 123.33 4734.06) (3162.86 123.33 4734.06) (3182.86 123.33 4514.06) (2942.86 123.33 4514.06) (2962.86 123.33 4294.06) (2722.86 123.33 4294.06) (2742.86 123.33 4074.06) (2502.86 123.33 4074.06) (2522.86 123.33 3854.06) (2282.86 123.33 3854.06) (2302.86 123.33 3634.06) (2062.86 123.33 3634.06) (2082.86 123.33 3414.06) (1842.86 123.33 3414.06) (1862.86 123.33 3194.06) (1622.86 123.33 3194.06) (1642.86 123.33 2974.06) (17.8625 123.33 2974.06) . ) I tried to use the function length to get the number of items in the list and it returns in error. I tried atom and type functions and they both return empty. The nth function also returns empty. However, car, cadr and caddr returns the first, second and third sets of coordinate points. Any idea of what kind of variable this is and how can I retrieve all coordinates from it? Thanks Quote
Isaac26a Posted May 26, 2021 Posted May 26, 2021 I think this would work much better. (setq poly (car (entsel "\nSelect the polyline")) coords (vlax-safearray->list (variant-value (vla-get-coordinates (vlax-ename->vla-object poly)))) ) (repeat (/ (length coords) 2) (setq order (append order (list (list (car coords) (cadr coords)))) coords (cddr coords) order (reverse order) ) ) Quote
BIGAL Posted May 26, 2021 Posted May 26, 2021 This is what I use (setq plent (entsel "\nPick pline")) (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))) Yes (length co-ord) works Quote
dmaeda Posted May 26, 2021 Author Posted May 26, 2021 Thanks guys. The problem with both is that they don’t give the z coordinate, right? They both output only a pair of coordinates. Quote
BIGAL Posted May 26, 2021 Posted May 26, 2021 The answers were correct a LWPOLYLINE is 2d compared to a 3dpoly which does have Z. In saying that if you want Z a LWPOLYLINE has a property Elevation which is the Z value and its the same value for every point. Using this (setq obj (vlax-ename->vla-object (car (entsel "Pick obj")))) (setq lst (vlax-get obj 'coordinates)) Will return X Y X Y X Y or X Y Z X Y Z X Y Z X Y Z depending on the pline type Quote
Isaac26a Posted May 26, 2021 Posted May 26, 2021 6 minutes ago, dmaeda said: Thanks guys. The problem with both is that they don’t give the z coordinate, right? They both output only a pair of coordinates. Then maybe you're talking about 3dpoly Or if you are still talking about a lwpolyline you should look for the DXF code 38, which is constant in every vertex Quote
BIGAL Posted May 27, 2021 Posted May 27, 2021 Did you try what I posted ? "coordinates" it will give (X Y Z X Y Z). I have a convert to ((xyz)(xyz)...) but I know Lee-mac has a way better version will try to find it thought I had saved it. Quote
mhupp Posted May 27, 2021 Posted May 27, 2021 Just and quick FYI because this recently happened to me. If you are Feeding that point list into (ssget "WP" the corners are cut off at any curve. The circle and rectangle wouldn't be selected because they are outside the white (ssget "WP" point list of the blue polyline. To get a more accurate point list use this Entity to Point List https://www.cadtutor.net/forum/topic/42900-select-within-a-polyline-containing-arcs-and-splines/?do=findComment&comment=350171 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.