Author Topic: deleting unused groups  (Read 3276 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
deleting unused groups
« on: November 09, 2005, 12:09:05 PM »
is there a way to delete unused or deleted groups from a drawing. i have a coworker who i believe is having problems as a result of this?

paulmcz

  • Bull Frog
  • Posts: 202
Re: deleting unused groups
« Reply #1 on: November 09, 2005, 12:36:15 PM »
Code: [Select]
(defun C:PG ()
 (vlax-for FOR-ITEM
           (vla-get-groups
            (vla-get-activedocument
             (vlax-get-acad-object)
            )
           )
  (if (= (vla-get-count FOR-ITEM) 0)
   (vla-delete FOR-ITEM)
  )
 )
 (princ)
)

ELOQUINTET

  • Guest
Re: deleting unused groups
« Reply #2 on: November 09, 2005, 12:39:25 PM »
just a question i forgot to mention would it be possible to list all unused blocks and allow the user to only delete those selected. doe this routine delete all unused? thanks for posting i'll give it a try

ELOQUINTET

  • Guest
Re: deleting unused groups
« Reply #3 on: November 09, 2005, 12:44:16 PM »
by the way how can i test to see if it does purge the group as it is not evident to me it's gone?

Bob Wahr

  • Guest
Re: deleting unused groups
« Reply #4 on: November 09, 2005, 12:46:02 PM »
type GROUP look for it in the list.

ELOQUINTET

  • Guest
Re: deleting unused groups
« Reply #5 on: November 09, 2005, 12:59:21 PM »
i gotcha figured it out  :lol: now about the specifying given groups to delete would that be extremely difficult or no? works great regardless thanks

Bob Wahr

  • Guest
Re: deleting unused groups
« Reply #6 on: November 09, 2005, 01:06:23 PM »
I looked at it very briefly in VBA a while back and it didn't look like it would be at all difficult to specify groups.  Depending on how you want to specify though, you start getting pretty close to just using the groups dialog to remove them.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: deleting unused groups
« Reply #7 on: November 09, 2005, 01:12:55 PM »
I don't think that's practical Dan given that problems associated with too many groups typically emerge once the count is around 30000 (thirty thousand)+.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ELOQUINTET

  • Guest
Re: deleting unused groups
« Reply #8 on: November 09, 2005, 01:35:45 PM »
i know what you mean bob but a select all by default then deselction method would be alot faster if you have alot of them. mp i'm not a big group user so i don't know the numbers but i know that my coworker has nowhere near that amount and is having serious hang ups. i would think it would depend on the computer

Bob Wahr

  • Guest
Re: deleting unused groups
« Reply #9 on: November 09, 2005, 01:39:55 PM »
Then again, it would be fairly easy in VBA and probably in lisp as well.  I don't have time now, or probably even this week, to look at it but might be able to this evening.  My guess is that someone will have given you a lisp solution by then.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: deleting unused groups
« Reply #10 on: November 09, 2005, 01:43:43 PM »
Code: [Select]
(defun C:PG ()
 (vlax-for FOR-ITEM
           (vla-get-groups
            (vla-get-activedocument
             (vlax-get-acad-object)
            )
           )
  (if (= (vla-get-count FOR-ITEM) 0)
   (vla-delete FOR-ITEM)
  )
 )
 (princ)
)

Hey....this code is cool..

can I add it in to one of mine ?

also, is Paulmcz = paul mckenzie
Keep smile...

paulmcz

  • Bull Frog
  • Posts: 202
Re: deleting unused groups
« Reply #11 on: November 09, 2005, 02:05:22 PM »
Code: [Select]
(defun C:PG ()
 (vlax-for FOR-ITEM
           (vla-get-groups
            (vla-get-activedocument
             (vlax-get-acad-object)
            )
           )
  (if (= (vla-get-count FOR-ITEM) 0)
   (vla-delete FOR-ITEM)
  )
 )
 (princ)
)

Hey....this code is cool..

can I add it in to one of mine ?

also, is Paulmcz = paul mckenzie

No, paulmcz is not paul mckenzie.
This code was given to me by someone, when I was looking for the way to do it for R14. Unfortunately, I couldn't use it in R14. It was a long time ago. You can do anything you want with it, I guess. Just don't tell anyone.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: deleting unused groups
« Reply #12 on: November 09, 2005, 03:01:29 PM »
This should work in r14 --

Code: [Select]
(defun c:PurgeUnusedGroups ( / dictionary ename group )
    (setq ename
        (cdr
            (assoc -1   
                (setq dictionary
                    (dictsearch
                        (namedobjdict)
                        "acad_group"
                    )
                )   
            )
        )   
    )
    (foreach pair dictionary
        (if (eq 3 (car pair))
            (if
                (null
                    (assoc 340
                        (dictsearch ename
                            (setq group (cdr pair))
                        )
                    )
                )
                (entdel (dictremove ename group))
            )
        )
    )
    (princ)
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

paulmcz

  • Bull Frog
  • Posts: 202
Re: deleting unused groups
« Reply #13 on: November 09, 2005, 04:21:27 PM »
...now, you are telling me?

Excellent, MP! I thought it wasn't possible in plain lisp then.
Well, you learn something new every now and then.
Thanks for showing me MP.
paul


MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: deleting unused groups
« Reply #14 on: November 09, 2005, 04:33:35 PM »
Heh, I posted this 5 years ago.

 :-)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst