View Full Version : List of points
cadconcepts
2005-01-12, 08:12 PM
Hi Everyone-
Try as I might, I am having difficulty trying to generate a list of points of a closed polyline. I would like to have the routine work on both polylines and lwpolylines. Thanks in advance.
(defun c:PTList ( / ename entlst)
(setq ename (entsel) ptlst nil)
(setq entlst (entget (car ename)))
(if (= (dxf 0 entlst) "POLYLINE")
(progn
(setq ename (cdr (assoc -1 entlst)))
(while (/= (cdr (assoc 0 entlst)) "SEQEND")
(setq ptlst (cons (cdr (assoc 10 entlst)) ptlst))
(setq entlst (entget (setq ename (entnext ename))))
)
)
)
(princ)
)
Manuel A. Ayala
CADmium
2005-01-12, 10:32 PM
see this:
(defun DT:PL-Coords->PKTLIST ( OBJEKT NODOUBLE? / OBJEKTDATEN DIMS ZAHLLISTE PKT PUNKTLISTE)
(vl-load-com)
(if (and(=(type OBJEKT) 'ENAME)
(member (cdr(assoc 0 (setq OBJEKTDATEN(entget OBJEKT)))) '("LWPOLYLINE" "POLYLINE"))
)
(progn
(setq DIMS (cond
((=(cdr(assoc 0 OBJEKTDATEN)) "LWPOLYLINE") 2)
((=(cdr(assoc 0 OBJEKTDATEN)) "POLYLINE") 3)
)
)
(setq ZAHLLISTE (vlax-safearray->list
(vlax-variant-value
(vlax-get-property (vlax-ename->vla-object OBJEKT) 'coordinates)
)
)
)
(repeat (/(length ZAHLLISTE)DIMS)
(cond
((= DIMS 2)
(setq PKT (list(car ZAHLLISTE)(cadr ZAHLLISTE) 0.0))
(setq ZAHLLISTE (cddr ZAHLLISTE))
)
((= DIMS 3)
(setq PKT (list(car ZAHLLISTE)(cadr ZAHLLISTE) (caddr ZAHLLISTE)))
(setq ZAHLLISTE (cdddr ZAHLLISTE))
)
)
(if NODOUBLE?
(if (not(member PKT PUNKTLISTE))
(setq PUNKTLISTE (cons PKT PUNKTLISTE))
)
(setq PUNKTLISTE (cons PKT PUNKTLISTE))
)
)
PUNKTLISTE
)
)
)
and for starting :
(setq PTlist (DT:PL-Coords->PKTLIST (car(entsel)) 'T))
without ActivX and for LW-Polys
(mapcar '(lambda (x) (cdr X))
(vl-remove-if-not
'(lambda(x) (=(car X) 10))
(entget(car(entsel)))
)
)
Greetings from Germany..
peter
2005-01-13, 04:53 PM
Here is another way to get the vertices from ANY curve object...
The syntax for calling the function is:
(getvertices (car (entsel "\nSelect curve object: ")))
Peter Jamtgaard
(defun GetVertices (objSelection / intCount lstVertices)
(if (= (type objSelection) 'ENAME)
(setq objSelection (vlax-ename->vla-object objSelection))
)
(repeat (1+ (setq intCount (fix (vlax-curve-getendparam objSelection))))
(if lstVertices
(setq lstVertices (cons (vlax-curve-getpointatparam objSelection intCount) lstVertices))
(setq lstVertices (list (vlax-curve-getpointatparam objSelection intCount)))
)
(setq intCount (1- intCount))
)
lstVertices
)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.