TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CAB on August 27, 2006, 12:32:42 AM
-
There is a catch to using this code to get a list of enames.
(setq ss (ssget))
(setq enames (mapcar 'cadr (ssnamex ss)))
When you use a Window selection an additional list is included in the list:
(<Entity name: 1bc2ab8>
<Entity name: 1bc2a88>
<Entity name: 1bc2a50>
<Entity name: 1bc2b48>
<Entity name: 1bc2b18>
<Entity name: 1bc2ae8>
(0 (2041.3 215.161 0.0234375)) <-----<<<
)
To remove it i used this:
((vl-remove-if-not '(lambda (x) (= (type x) 'ename)) (mapcar 'cadr (ssnamex ss)))
there may be a better way, if so please share it.
I discovered the problem when developing this to delete a selection set ss
(mapcar '(lambda (ent) (vla-Delete (vlax-ename->vla-object Ent)))
(vl-remove-if-not '(lambda (x) (= (type x) 'ename)) (mapcar 'cadr (ssnamex ss))))
-
Here's one way Alan --
(defun SS->Objects ( ss )
(if (eq 'pickset (type ss))
(mapcar 'cadr
(vl-remove-if
'(lambda (tuple) (minusp (car tuple)))
(ssnamex ss)
)
)
)
)
-
For deleting all ename in a choice, I - use:
(if (setq ss (ssget))
(mapcar (function entdel)
(vl-remove-if (function listp) (mapcar (function cadr) (ssnamex ss)))
) ;_ mapcar
) ;_ if
To create list VLA-OBJECTS, I - use:
(if (setq ss (ssget))
(mapcar (function vlax-ename->vla-object)
(vl-remove-if (function listp) (mapcar (function cadr) (ssnamex ss)))
) ;_ mapcar
) ;_ if
-
Thanks fellas :-)
This fits my condensed style perfectly. :-)
I'm a happy camper.
(if (setq ss (ssget))
(mapcar 'entdel (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
)
-
Success to you! :-)
I should consider every second...