Author Topic: update - using ssnamex for enames  (Read 2334 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
update - using ssnamex for enames
« on: August 27, 2006, 12:32:42 AM »
There is a catch to using this code to get a list of enames.
Code: [Select]
(setq ss (ssget))
(setq enames (mapcar 'cadr (ssnamex ss)))

When you use a Window selection an additional list is included in the list:

Code: [Select]
(<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:

Code: [Select]
((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

Code: [Select]
(mapcar '(lambda (ent) (vla-Delete (vlax-ename->vla-object Ent)))
(vl-remove-if-not '(lambda (x) (= (type x) 'ename)) (mapcar 'cadr (ssnamex ss))))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: update - using ssnamex for enames
« Reply #1 on: August 27, 2006, 12:46:57 AM »
Here's one way Alan --

Code: [Select]
(defun SS->Objects ( ss )
    (if (eq 'pickset (type ss))
        (mapcar 'cadr
            (vl-remove-if
               '(lambda (tuple) (minusp (car tuple)))
                (ssnamex ss)
            )
        )
    )
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: update - using ssnamex for enames
« Reply #2 on: August 27, 2006, 02:50:08 AM »
For deleting all ename in a choice, I - use:
Code: [Select]
(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:
Code: [Select]
(if (setq ss (ssget))
  (mapcar (function vlax-ename->vla-object)
          (vl-remove-if (function listp) (mapcar (function cadr) (ssnamex ss)))
  ) ;_  mapcar
) ;_  if

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: update - using ssnamex for enames
« Reply #3 on: August 27, 2006, 08:50:42 AM »
Thanks fellas :-)

This fits my condensed style perfectly.  :-)
I'm a happy camper.

Code: [Select]
  (if (setq ss (ssget))
    (mapcar 'entdel (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
  )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: update - using ssnamex for enames
« Reply #4 on: August 27, 2006, 09:39:26 AM »
Success to you!  :-)
I should consider every second...