@Jonathan.Trostad wrote:
I don't have code as such, but I feel it helps to put what you want into a format with steps. so for this task:
1) use SSGET to grab the lw polylines in the drawing
2) convert your selection set to a list of entities for processing <- you might not need this step, but selection sets confuse me...
3) FOREACH entity, get the length of the polyline (possibly by grabbing the DXF 10 out of the entity and doing math)
3a) IF the length is too small, delete the entity (possibly use ENTDEL), else move on
As for your point 2) : You do indeed not need that step.
A selectionset IS a list of entities (for processing), so no need for conversion.
You should keep in mind that such a set only contains a reference to the entities, not the entities data (DXF groupcodes & values). To get to the data, its better to combine it with the FOREACH of point 3)
To explain:
(setq ss (ssget "X" (list '(0 . "LWPOLYLINE"))))
This will create a list (selection set) containing ALL lwpolyline entities found within the entire database of acad (that's what the "X" is for) and store it with the variable "ss"
Since acad handles selection sets as different from lists (although they are basically the same) you can not use functions for lists on selection sets.
So,
(foreach ent ss
; do stuff
)
Works only if ss where a list, but not when its a selection set.
Instead you need to step thru the selection set by 'entry id' (the nth entry of the set)
(setq i 0)
(while (< i (sslength ss)) ; keep going as long as "i" is smaller as the number of selected items.
(setq ent (entget (ssname ss i))) ; retrieve entity data for entry "i" (0 is first, 1 is second !!!)
The ssname function will retrieve the entities name from the selectionset.
entget retrieves the data (for a given entity name)
Now you have the entities data stored inside "ent", as a list! (a dotted pair / association list)
From here you can retrieve the values for each DXF groupcode, or change them (using entmod)
This includes retrieving the length.
(setq entLength (cdr (assoc 10 ent))) ; this will retrieve the value for DXF group code 10. (as each entry is a dotted pair list (key . value), you need cdr to retrieve the value.
(setq i (1+ i)) ; up the counter, for next entry
) ; end while
Check the links for more info on each function and how it works. For a complete list of selectionset functions, check the: Selection Set Manipulation Functions Reference.
Hope this helps (if even a little) to understand how to work with selection sets, as its realy one of the most powerfull (& most used) parts of AutoLISP.