Polyline vertices to list?

btlsp

Usenet Archive
Joined
Jul 20, 2003
Messages
30
Reaction score
0
(defun pver
(setq
   vl
   e (entget (car (entsel))) )
(while (/= (assoc 0 e) "SEQEND")
   (setq
      v2 (cdr (assoc 10 (setq e (entget (entnext (cdr (car e)))))))       vl (cons v2 vl) )))
 
How about....

; get list of vertex points from a heavy polyline
; [ename] - entity name, heavy polyline
; return: list of points
(defun getVertexPoints (ename)
(mapcar
'(lambda (x)
(cdr (assoc 10 (entget x))))
(nEnts ename "vertex")
)
)

; Jason Piercey . June 2nd, 2003
; get list of sub entity names
; [ename] - entity name or vla-object - block, insert or polyline ; [filter] - string, re: wcmatch ; return: list of enames or nil ; revised: July 10th, 2003 - accepts ename or vla-object (defun nEnts (ename filter / data ent rtn) (or (= 'ename (type ename)) (setq ename (vlax-vla-object->ename ename)) ) (setq filter (strcase filter)) (while (and ename (setq ename (entnext ename))) (setq data (entget ename)) (setq ent (cdr (assoc 0 data))) (if (wcmatch ent filter) (setq rtn (cons ename rtn)) ) (if (= "SEQEND" ent) (setq ename nil)) ) (reverse rtn)
)
 
I have been playing with picking a polyline and using it as a stretch fence, in a modified lisp routine. (note it returns a poline point list) Occasionally it was not working properly had to offset a polyline then use it. I have also turned osnaps off and back on, this may have fixed it. if you have any suggestions let me know. Not also i have added support to type in the handle number of the entity you wish to pick if nothing is selected. run command (c:ssp) for stretch and (c:mop) for move.
Any comments let me know.

Mick,
 
These may suit your needs:

;****************************************************************************************************

;routine to - return a consecutive list of XYZ WCS data from the AcDbPolyline(lwpolyline) ; entity refered to by the passed entity name ENTITYNAME ; - sample list = (X Y Z X Y Z X Y Z) ; - called using entity name as argument

(defun ACDBPOLYLINE2LIST (ENTITYNAME / vlaENTITYOBJECT vlaCOORDINATES listCOORDINATES                                        dblELEVATION XYZLIST X Y POINT1 )

(vl-load-com)

(setq vlaENTITYOBJECT (vlax-ename->vla-object ENTITYNAME)) ;convert to the vla ename of the entity   (setq vlaCOORDINATES (vlax-get-property vlaENTITYOBJECT 'Coordinates)) ;get the coordinates of the entity   (setq listCOORDINATES (vlax-safearray->list (vlax-variant-value vlaCOORDINATES))) ;convert variant to list

(setq dblELEVATION (vlax-get-property vlaENTITYOBJECT 'Elevation)) ;get the elevation of the entity

(setq XYZLIST nil) ;start a fresh XYZLIST

;convert list of 2D OCS coordinates to list of 3D WCS coordinates   (repeat (/ (length listCOORDINATES) 2)

(setq X (car listCOORDINATES))
    (setq listCOORDINATES (cdr listCOORDINATES))     (setq Y (car listCOORDINATES))     (setq listCOORDINATES (cdr listCOORDINATES))

(setq POINT1 (list X Y dblELEVATION))
    (setq POINT1 (trans POINT1 ENTITYNAME 0)) ;translate from OCS to WCS

(setq XYZLIST (append XYZLIST POINT1))

);end of "(repeat (/ (length listCOORDINATES) 2)"

(setq XYZLIST XYZLIST) ;ACDBPOLYLINE2LIST returns result of last function evaluated

);end of "defun ACDBPOLYLINE2LIST"

;**************************************************************************************************** ;**************************************************************************************************** ;****************************************************************************************************

;routine to - return a consecutive list of XYZ WCS data from the AcDb2dPolyline (old style polyline) ; entity refered to by the passed entity name ENTITYNAME ; - sample list = (X Y Z X Y Z X Y Z) ; - called using entity name as argument ;

(defun ACDB2DPOLYLINE2LIST (ENTITYNAME / vlaENTITYOBJECT vlaCOORDINATES listCOORDINATES                                          dblELEVATION XYZLIST X Y POINT1 )

(vl-load-com)

(setq vlaENTITYOBJECT (vlax-ename->vla-object ENTITYNAME)) ;convert to the vla ename of the entity   (setq vlaCOORDINATES (vlax-get-property vlaENTITYOBJECT 'Coordinates)) ;get the coordinates of the entity   (setq listCOORDINATES (vlax-safearray->list (vlax-variant-value vlaCOORDINATES))) ;convert variant to list

(setq dblELEVATION (vlax-get-property vlaENTITYOBJECT 'Elevation)) ;get the elevation of the entity

(setq XYZLIST nil) ;start a fresh XYZLIST

;convert list of 2D OCS coordinates to list of 3D WCS coordinates   (repeat (/ (length listCOORDINATES) 3)

(setq X (car listCOORDINATES))
    (setq listCOORDINATES (cdr listCOORDINATES))     (setq Y (car listCOORDINATES))     (setq listCOORDINATES (cdr listCOORDINATES))     (setq listCOORDINATES (cdr listCOORDINATES))

(setq POINT1 (list X Y dblELEVATION))
    (setq POINT1 (trans POINT1 ENTITYNAME 0)) ;translate from OCS to WCS

(setq XYZLIST (append XYZLIST POINT1))

);end of "(repeat (/ (length listCOORDINATES) 3)"

(setq XYZLIST XYZLIST) ;ACDBPOLYLINE2LIST returns result of last function evaluated

);end of "defun ACDB2DPOLYLINE2LIST"

;**************************************************************************************************** ;**************************************************************************************************** ;****************************************************************************************************

;routine to - return a consecutive list of XYZ WCS data from the AcDb3dPolyline ; entity refered to by the passed entity name ENTITYNAME ; - sample list = (X Y Z X Y Z X Y Z) ; - called using entity name as argument ; (defun ACDB3DPOLYLINE2LIST (ENTITYNAME / vlaENTITYOBJECT vlaCOORDINATES                                           listCOORDINATES XYZLIST X Y Z )

(vl-load-com)

(setq vlaENTITYOBJECT (vlax-ename->vla-object ENTITYNAME)) ;convert to the vla ename of the entity   (setq vlaCOORDINATES (vlax-get-property vlaENTITYOBJECT 'Coordinates)) ;get the coordinates of the entity   (setq listCOORDINATES (vlax-safearray->list (vlax-variant-value vlaCOORDINATES))) ;convert variant to list

(setq XYZLIST nil) ;start a fresh XYZLIST

(repeat (/ (length listCOORDINATES) 3)

(setq X (car listCOORDINATES))
    (setq listCOORDINATES (cdr listCOORDINATES))     (setq Y (car listCOORDINATES))     (setq listCOORDINATES (cdr listCOORDINATES))     (setq Z (car listCOORDINATES))     (setq listCOORDINATES (cdr listCOORDINATES))

(setq XYZLIST (append XYZLIST (list X Y Z)))

);end of "(repeat (/ (length listCOORDINATES) 3)"

(setq XYZLIST XYZLIST) ;ACDB3DPOLYLINE2LIST returns result of last function evaluated

);end of "defun ACDB3DPOLYLINE2LIST"

;****************************************************************************************************
 

Latest threads

Back
Top