Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Accessing polyline vertices in AutoLisp

928 views
Skip to first unread message

Saurabh Manohar

unread,
Dec 4, 2002, 2:37:47 PM12/4/02
to
Hi everybody,
I am trying to access th vertices of a polyline in lisp. Earlier (upto r13)
I beleibve the method was (entnext e1) where e1 is my polyline entity got by
(car (entsel)) . But now in R14 and R2000 it give me nil. and (entget
(entnext e1)) give me an error ; error: bad argument type: lentityp nil
How do I access vertices of a polyline in R2000.
Also if I use AutoLISP to calculate some data, can I return a value to a VBA
call?

Thanks in advance.

Saurabh Manohar


Tom Berger

unread,
Dec 4, 2002, 3:28:57 PM12/4/02
to
Saurabh Manohar wrote:
> Hi everybody,
> I am trying to access th vertices of a polyline in lisp. Earlier
> (upto r13) I beleibve the method was (entnext e1) where e1 is my
> polyline entity got by (car (entsel)) . But now in R14 and R2000 it
> give me nil. and (entget (entnext e1)) give me an error ; error: bad
> argument type: lentityp nil How do I access vertices of a polyline in
> R2000.

With the POLYLINE entity it is still the same procedure as it was in R13
and earlier. For LWPOLYLINE entities you need to walk through the
multiple DXF-group entities for the vertices (there is a (10 x y z)
entry for each vertex, ASSOC only gives you the first entry).

Tom Berger

--
ArchTools: Architektur-Werkzeuge für AutoCAD (TM)
ArchDIM - architekturgerechte Bemaßung und Höhenkoten
ArchAREA - Flächenermittlung und Raumbuch nach DIN 277
Info und Demo unter http://www.archtools.de

TomD

unread,
Dec 5, 2002, 8:55:56 AM12/5/02
to
Here are the two routines I typically use for getting vertices out of
PLines. These should be carefully reviewed/tested if you're going to use
them. I believe they have some limitations, though I don't remember exactly
what they are. I wrote these, but I'm NOT a programmer.

;get Poly/LWPoly point list
(defun plplst ( plnam / plist subent vertex plist subent )
(setq subent (entnext plnam)
plist (list (dxfn 10 subent)) ;THIS LINE REVISED 12/2/97 by TLD
subent (entnext subent)
);setq
(while (/= (dxfn 0 subent) "SEQEND")
(setq vertex (trans (dxfn 10 subent) 0 1)
plist (append plist (list vertex))
subent (entnext subent)
);setq
);while
plist
);defun - returns list of all vertex coords of plnam (must be Heavy Poly)
(defun lwplplst ( plnam / elst plist )
(setq elst (entget plnam))
(while elst
(if (= (caar elst) 10)
(setq plist (append plist (list (cdar elst)))
elst (cdr elst)
);then
(setq elst (cdr elst));else
);if
);while
plist
);defun - returns list of all vertex coords of plnam (must be LWPoly)


As for returning lisp values to VBA, there isn't a *good* way. You might
want to check out the autodesk.autocad.customization.vba NG. There are some
real wizards there that can certainly point you in the right direction.

"Saurabh Manohar" <saurabh...@vsnl.net> wrote in message
news:asljcg$hn4$1...@news.vsnl.net.in...

0 new messages