John,
now I remember and I have found some discussions, but:
1) I think CDRS (Puckett's) is reasonable fast in all
situations
2) What I was trying is to optimize that code
or find a new solution with some new "Visual" Lisp
funtions to work in any kind of lists or in Lwpolines
lists but with no restrictions.
Thank for your contribution.
Cheers.
Marco
_____________________________________________________________________
From: Tony Tanzillo
Date: Sep/30/99 - 11:44 (GMT)
Not really. The documentation you're quoting is fairly ancient.
In fact, most post-R12 objects (the ones with the (100 . AcDbXxxxx)
subclass data markers in them), are largely order-dependent,
as there is no other way to interpret them in cases where multiple
fields with the same group code appear. One thing is certain, and
that is the group 10 vertices of objects like LWPolylines are always
order dependent, and you could count on that remaining the same.
Unfortunately, the whole DXF-based entget/entmod and entmake way
of doing things is a total mess, woefull inadequate, and confusing.
The fact that ActiveX can work up to 10X faster than (entxxxx)
functions, and is far easier to work with, would make the decision
to switch to it in cases where it would work, is a no-brainer.
Phil Kenewell wrote:
>
> Eugene,
>
> That's not a good idea. Here is a quote from the "AutoCAD Customization
> Guide" to explain:
>
> Note: Do not write programs that rely on the order shown in these DXF code
> tables. Although these tables show the order of group codes as they
usually
> appear, the order can change under certain conditions or in a future
AutoCAD
> release. The code that controls an entity should be driven by a case
> (switch) or a table so that it can process each group correctly even if
the
> order is unexpected."
>
> It's better to extract the vertices out first - before you query them. In
> "special conditions" or future releases Autodesk may decide to change the
> order in which (entget) returns the Entity List.
> > -- > Phillip Kenewell
From: Bill Wilkerson
Date: Sep/07/01 - 05:40 (GMT)
They are in order of fastest from the top down.
I realize this is an old post, "but"....
Since you seem comfortable with using superlatives here,
you can just put the following at the *top* of your list:
(defun get-vertices (data / vlist points)
(setq vlist (member (assoc 10 data) data))
(repeat (cdr (assoc 90 data))
(setq points (cons (cdar vlist) points) vlist (cddddr vlist))
)
(reverse points)
)
;; Usage: ;; ;; (get-vertices (entget (car (entsel "\nPolyline: "))))
According to my data (lwpolys with 1000 vertices),
it is at least 2X faster than the (cdrs) function quoted above.
Reason: When you know how many items you must fetch from a list,
and you know their relative location, you shouldn't use search
functions (like assoc or member) to locate them. In the case of
an LWPolyline's data list, the number of vertices is stored in
the 90 group and the vertices appear at a constant frequency
(every 4th element). So, we those assumptions can avoid the
(ASSOC) nonsense altogether, and simply use (CDDDDR) to skip
to each subsequent vertex. While the (cdrs) function you posted
may be efficient for generic association lists where these kind
of assumptions cannot be made, for getting an lwpolyline's
vertices it isn't nearly the most efficient solution.
Regards, Bill
From: Tony Tanzillo
Date: Apr/11/02 - 21:14 (GMT)
You can safely assume that the structure of the
list returned by (entget) for LWPOLYLINES will
not change any time in the near future (at least,
not the part that contains the vertex data).
The reason why you can count on the list structure
not changing is because (entget) is just a programmatic
way of doing a DXFOUT on a single entity, and just as
the DXF format is not likely to change for existing
entities, the same holds true for (entget).
If the format did change, it would break much more
than just your code, it would create widespread
incompatibility and wreak havoc on anything that
worked with DXF files.
Trust me, with all things considered, this is a
perfectly reasonable assumption.