Jump to content

how to ungroup multiple groups?


Recommended Posts

Try the following:

;; Ungroup Multiple  -  Lee Mac

(defun c:ungroupm ( / idx grp sel )
   (if (setq sel (ssget))
       (repeat (setq idx (sslength sel))
           (if (= "GROUP" (cdr (assoc 0 (entget (setq grp (cdr (assoc 330 (entget (ssname sel (setq idx (1- idx)))))))))))
               (entdel grp)
           )
       )
   )
   (princ)
)

Edited by Lee Mac
Changed vla-delete to entdel
  • Like 1
Link to post
Share on other sites
@Lee:

Why do you use vla-delete instead of entdel in your code?

 

Something in the back of my mind said that vla-delete would be necessary to remove the references to the deleted group from each object, but after some testing, it would appear that entdel is indeed equally successful - thank you for the suggestion, I have updated my above code. :thumbsup:

Link to post
Share on other sites

FYI you can toggle group selection off/on with Ctrl+h. Back in r12 DOS AutoCAD it was Ctrl+a and would display or at the command line.

I have

 "$(if,$(and,1,$(getvar,pickstyle)),Group) "

as part of my MODEMACRO string to display Group on the Status bar when it's toggled on.

Link to post
Share on other sites
Try the following:
;; Ungroup Multiple  -  Lee Mac

(defun c:ungroupm ( / idx grp sel )
   (if (setq sel (ssget))
       (repeat (setq idx (sslength sel))
           (if (= "GROUP" (cdr (assoc 0 (entget (setq grp (cdr (assoc 330 (entget (ssname sel (setq idx (1- idx)))))))))))
               (entdel grp)
           )
       )
   )
   (princ)
)

 

thank you so much! this would help me

Link to post
Share on other sites
  • 2 years later...

Hi Mr. Lee Mac, C.G. 

 

I was searching the web for a way to ungroup groups in a single stroke but usually stayed away from using lisp, etc.   Your ungroupm was only the 2nd lisp (is this correct?) or application I used, the first one being AutoCAD's tutorial lisp.  That was a great help.  Thank you.  I hope you don't mind me using it without your permission.  

 

Sincerely,

Joel

Link to post
Share on other sites
TerryDotson

For those that like dialog boxes and clicks, there is a free GroupManager tool.  Three clicks (select all, delete, OK) to delete all groups.  Provides additional group functionality not available in built-in CAD commands. There is also a command line version for scripts.

Link to post
Share on other sites
  • 2 months later...
On 11/16/2016 at 2:04 AM, Lee Mac said:

Try the following:


;; Ungroup Multiple  -  Lee Mac

(defun c:ungroupm ( / idx grp sel )
   (if (setq sel (ssget))
       (repeat (setq idx (sslength sel))
           (if (= "GROUP" (cdr (assoc 0 (entget (setq grp (cdr (assoc 330 (entget (ssname sel (setq idx (1- idx)))))))))))
               (entdel grp)
           )
       )
   )
   (princ)
)
 
Please show me know mean of "0" & "330" behind assoc? Thank you!

 

 

Link to post
Share on other sites
  • 4 weeks later...
On 11/15/2016 at 10:04 PM, Lee Mac said:

Try the following:


;; Ungroup Multiple  -  Lee Mac

(defun c:ungroupm ( / idx grp sel )
   (if (setq sel (ssget))
       (repeat (setq idx (sslength sel))
           (if (= "GROUP" (cdr (assoc 0 (entget (setq grp (cdr (assoc 330 (entget (ssname sel (setq idx (1- idx)))))))))))
               (entdel grp)
           )
       )
   )
   (princ)
)
Lee, you, as always, bring simple solutions to difficult problems 😉

 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...