Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create a Selection from a Selection Set

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
534 Views, 6 Replies

How to create a Selection from a Selection Set

I am new to Vlisp so please forgive me if my question is too silly!

I have managed to build a Selection Set of objects selected using information obtained via entget. Now I would like use command "explode" to tell

Autocad to explode each of these objects. Like many other Autocad commands, EXPLODE operates on objects which have been selected. But, inspite of much searching, I have failed to find a way of telling Autocad to select an object identified by its entity name. Please can someone tell me the trick... Or is there a different approach to tell Autocad to select objects according to a criterion programmed in Vlisp?

Thank you for any help you can give me.

6 REPLIES 6
Message 2 of 7
Satoews
in reply to: Anonymous

(defun c:trythis ( / ss)
  (setq ss (ssget))
  (command "explode" ss "")
)

Unless I am misreading your question is this what you want?

Shawn T
Message 3 of 7
hmsilva
in reply to: Anonymous


@Anonymous wrote:

I am new to Vlisp so please forgive me if my question is too silly!

I have managed to build a Selection Set of objects selected using information obtained via entget. Now I would like use command "explode" to tell

Autocad to explode each of these objects. Like many other Autocad commands, EXPLODE operates on objects which have been selected. But, inspite of much searching, I have failed to find a way of telling Autocad to select an object identified by its entity name. Please can someone tell me the trick... Or is there a different approach to tell Autocad to select objects according to a criterion programmed in Vlisp?

Thank you for any help you can give me.


Hello ianmartin1941and welcome to the Autodesk Community!

 

(defun c:demo (/ *error* qflg ss)
   (defun *error* (msg)
      (if qflg
         (setvar 'QAFLAGS qflg)
      )
      (cond ((not msg))
            ((member msg '("Function cancelled" "quit / exit abort")))
            ((princ (strcat "\n** Error: " msg " ** ")))
      )
      (princ)
   )
   (if (setq ss (ssget))
      (progn
         (setq qflg (getvar 'QAFLAGS))
         (setvar 'QAFLAGS 1)
         (command "_.explode" ss "")
      )
   )
   (*error* nil)
   (princ)
)

(defun c:demo1 (/ ss)
   (if (setq ss (ssget))
      (repeat (setq i (sslength ss))
         (command "_.explode" (ssname ss (setq i (1- i))))
      )
   )
   (princ)
)

(defun c:demo2 (/ ss)
   (and (setq ss (ssget))
        (initcommandversion)
        (command "_.explode" ss "")
   )
   (princ)
)

 

Hope this helps,
Henrique

EESignature

Message 4 of 7
Kent1Cooper
in reply to: Anonymous

Just for a little additional clarification:  For some unknown reason, the EXPLODE command, when used in an ordinary AutoLisp (command) function [without going through related shenanigans], cannot Explode a selection set, but only one entity.  The various approaches in @hmsilva's Post are optional ways of getting around that limitation.  And when you have it Explode one entity, note that it does not take the typical Enter [""] that is normally needed to complete the selection in commands for which you can select more than one thing.

Kent Cooper, AIA
Message 5 of 7
Satoews
in reply to: Kent1Cooper

Thanks for the expanation!

Shawn T
Message 6 of 7
hmsilva
in reply to: Kent1Cooper


@Kent1Cooper wrote:

Just for a little additional clarification:  For some unknown reason, ...


Nice explanation!

 

Thank you,

Henrique

EESignature

Message 7 of 7
Anonymous
in reply to: Kent1Cooper

Thank you so much Shawn, Henrique and Kent. You have solved my problem; I have tried what you suggested and it works. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report