Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How to create a Selection from a Selection Set

Anonymous

How to create a Selection from a Selection Set

Anonymous
Not applicable

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.

0 Likes
Reply
574 Views
6 Replies
Replies (6)

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

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

Shawn T
0 Likes

hmsilva
Mentor
Mentor

@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

Kent1Cooper
Consultant
Consultant

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

Satoews
Advocate
Advocate

Thanks for the expanation!

Shawn T
0 Likes

hmsilva
Mentor
Mentor

@Kent1Cooper wrote:

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


Nice explanation!

 

Thank you,

Henrique

EESignature

0 Likes

Anonymous
Not applicable

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

0 Likes