mstb Posted September 8, 2020 Posted September 8, 2020 Hello every body how can i get to vertexes of 3dpoly? (setq en (entget (car (entsel)))) It doesn't provide any vertex. Thanks all. Quote
dlanorh Posted September 8, 2020 Posted September 8, 2020 Two methods other than diving deeper using (entnext) 1. Using vlax-curve functions (setq ent (car (entsel)) ep (vlax-curve-getendparam ent) ) (while (not (minusp ep)) (setq vlst (cons (vlax-curve-getpointatparam ent ep) vlst) ep (1- ep) ) );end_while 2. Using a grouping function and activex (defun group3 (lst / x) (repeat 3 (and lst (setq x (cons (car lst) x))) (setq lst (cdr lst)) x) (if lst (cons (reverse x) (group3 lst)) (list (reverse x))) ) (setq obj (vlax-ename->vla-object (car (entsel))) vlst (group3 (vlax-get obj 'coordinates)) ) Quote
mstb Posted September 8, 2020 Author Posted September 8, 2020 3 hours ago, dlanorh said: Two methods other than diving deeper using (entnext) 1. Using vlax-curve functions (setq ent (car (entsel)) ep (vlax-curve-getendparam ent) ) (while (not (minusp ep)) (setq vlst (cons (vlax-curve-getpointatparam ent ep) vlst) ep (1- ep) ) );end_while 2. Using a grouping function and activex (defun group3 (lst / x) (repeat 3 (and lst (setq x (cons (car lst) x))) (setq lst (cdr lst)) x) (if lst (cons (reverse x) (group3 lst)) (list (reverse x))) ) (setq obj (vlax-ename->vla-object (car (entsel))) vlst (group3 (vlax-get obj 'coordinates)) ) Thank you very very much. Quote
BIGAL Posted September 9, 2020 Posted September 9, 2020 This is my version look at object type and use correct 2 or 3. ; pline co-ords example ; By Alan H (defun getcoords (ent) (vlax-safearray->list (vlax-variant-value (vlax-get-property (vlax-ename->vla-object ent) "Coordinates" ) ) ) ) ; convert now to xyz (defun co-ords2xy (xyz / ) (setq co-ordsxy '()) (if (= xyz 2) (progn (setq I 0) (repeat (/ (length co-ords) 2) (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) )) (setq co-ordsxy (cons xy co-ordsxy)) (setq I (+ I 2)) ) ) ) (if (= xyz 3) (progn (setq I 0) (repeat (/ (length co-ords) 3) (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) )) (setq co-ordsxy (cons xy co-ordsxy)) (setq I (+ I 3)) ) ) ) ) (setq obj (vlax-ename->vla-object (car (entsel "Pick obj")))) (setq co-ords (vlax-get obj 'coordinates)) (cond (( = (vla-get-objectname obj) "AcDb2dPolyline")(co-ords2xy 2)) (( = (vla-get-objectname obj) "AcDb3dPolyline")(co-ords2xy 3)) ) (princ co-ordsxy) (princ) Quote
Lee Mac Posted September 10, 2020 Posted September 10, 2020 To provide a Vanilla AutoLISP solution: the vertices of a 3D polyline are represented using VERTEX subentities which follow the POLYLINE entity - you can access such subentities using the entnext function, e.g.: (defun c:test ( / e l v x ) (if (setq e (car (entsel "\nSelect 3D polyline: "))) (if (and (= "POLYLINE" (cdr (assoc 0 (setq x (entget e))))) (= 8 (logand 8 (cdr (assoc 70 x)))) ) (progn (setq v (entnext e) x (entget v) ) (while (= "VERTEX" (cdr (assoc 0 x))) (setq l (cons (cdr (assoc 10 x)) l) v (entnext v) x (entget v) ) ) (print (reverse l)) ) (princ "\nThe selected object is not a 3D polyline.") ) ) (princ) ) Quote
BIGAL Posted September 11, 2020 Posted September 11, 2020 Is the 8 check really necessary as if removed still get vertices but with XYZ compared to say get-coordinates XY for 2d XYZ for 3d. May use this method in future. Using Bricscad. 2D polyline: ((214.0 52.0 0.0) (157.408781350765 164.576347301707 0.0) (284.086155652032 244.905936122619 0.0) (347.378011556397 199.31930457146 0.0)) 3D polyline: ((348.0 42.0 0.0) (302.0 149.0 10.0) (436.0 170.0 15.0) (482.737423332648 107.229403773346 0.0)) Quote
mstb Posted September 11, 2020 Author Posted September 11, 2020 On 9/9/2020 at 8:05 AM, BIGAL said: This is my version look at object type and use correct 2 or 3. ; pline co-ords example ; By Alan H (defun getcoords (ent) (vlax-safearray->list (vlax-variant-value (vlax-get-property (vlax-ename->vla-object ent) "Coordinates" ) ) ) ) ; convert now to xyz (defun co-ords2xy (xyz / ) (setq co-ordsxy '()) (if (= xyz 2) (progn (setq I 0) (repeat (/ (length co-ords) 2) (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) )) (setq co-ordsxy (cons xy co-ordsxy)) (setq I (+ I 2)) ) ) ) (if (= xyz 3) (progn (setq I 0) (repeat (/ (length co-ords) 3) (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) )) (setq co-ordsxy (cons xy co-ordsxy)) (setq I (+ I 3)) ) ) ) ) (setq obj (vlax-ename->vla-object (car (entsel "Pick obj")))) (setq co-ords (vlax-get obj 'coordinates)) (cond (( = (vla-get-objectname obj) "AcDb2dPolyline")(co-ords2xy 2)) (( = (vla-get-objectname obj) "AcDb3dPolyline")(co-ords2xy 3)) ) (princ co-ordsxy) (princ) Thank you very very much Quote
mstb Posted September 11, 2020 Author Posted September 11, 2020 19 hours ago, Lee Mac said: To provide a Vanilla AutoLISP solution: the vertices of a 3D polyline are represented using VERTEX subentities which follow the POLYLINE entity - you can access such subentities using the entnext function, e.g.: (defun c:test ( / e l v x ) (if (setq e (car (entsel "\nSelect 3D polyline: "))) (if (and (= "POLYLINE" (cdr (assoc 0 (setq x (entget e))))) (= 8 (logand 8 (cdr (assoc 70 x)))) ) (progn (setq v (entnext e) x (entget v) ) (while (= "VERTEX" (cdr (assoc 0 x))) (setq l (cons (cdr (assoc 10 x)) l) v (entnext v) x (entget v) ) ) (print (reverse l)) ) (princ "\nThe selected object is not a 3D polyline.") ) ) (princ) ) Thank you very very much Quote
David Bethel Posted September 12, 2020 Posted September 12, 2020 Here's a similar approach using ssget ;;; Create List Of 3DPOLY Vertices (defun c:3dpv (/ en vl ss vn vd) (while (not en) (and (setq ss (ssget (list (cons 0 "POLYLINE") (cons -4 "&") (cons 70 8)))) (= (sslength ss) 1) (setq en (ssname ss 0)))) (setq vn (entnext en) vd (entget vn)) (while (= "VERTEX" (cdr (assoc 0 vd))) (setq vl (cons (cdr (assoc 10 vd)) vl) vn (entnext vn) vd (entget vn))) (prin1 (setq vl (reverse vl))) (prin1)) -David Quote
mstb Posted September 14, 2020 Author Posted September 14, 2020 On 9/12/2020 at 3:29 PM, David Bethel said: Here's a similar approach using ssget ;;; Create List Of 3DPOLY Vertices (defun c:3dpv (/ en vl ss vn vd) (while (not en) (and (setq ss (ssget (list (cons 0 "POLYLINE") (cons -4 "&") (cons 70 8)))) (= (sslength ss) 1) (setq en (ssname ss 0)))) (setq vn (entnext en) vd (entget vn)) (while (= "VERTEX" (cdr (assoc 0 vd))) (setq vl (cons (cdr (assoc 10 vd)) vl) vn (entnext vn) vd (entget vn))) (prin1 (setq vl (reverse vl))) (prin1)) -David Thank you very very much 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.