Explode groups w/ pick

Discussion in 'AutoCAD' started by Marcus, Jul 2, 2003.

  1. Marcus

    Marcus Guest

    I want to be able to create an icon so I can explode a group without going
    through the group dialog, finding out the name & then exploding it (this is
    really annoying with unamed groups). Does anybody know how I can extract
    the name of a picked group?

    Thanks!
     
    Marcus, Jul 2, 2003
    #1
  2. Marcus

    Marcus Guest

    On a related subject, how can I purge unused groups? I've got a file with
    up to "*A95" groups in it and I know that there are no groups being used in
    the file. This is one of those files that has been around (and around...and
    around) for a while, and as a result has accumulated a lot of trash. I know
    there are other ways to do this (eg. copy clip into a clean file) but as an
    exercise I wanted to do it with VBA. Any suggestions?

    Thanks!
     
    Marcus, Jul 2, 2003
    #2
  3. Marcus

    Mark Propst Guest

    here's one way - not good programming just an idea of how to do
    left the msgboxs in just to see what's happening
    don't run in dwg with 95 unnamed groups :)
    try in sample dwg with a few

    Option Explicit

    Public Sub TestDeleteGroups()
    Dim objGroup As AcadGroup
    Dim strname As String
    Dim i As Integer
    Dim delarray() As String


    'On Error Resume Next
    For i = 0 To ThisDrawing.Groups.Count - 1
    strname = ThisDrawing.Groups.Item(i).Name
    If Left(strname, 1) = "*" Then
    MsgBox "put " & strname & " in array"
    ReDim Preserve delarray(i)
    delarray(i) = strname
    MsgBox "Delarray has " & UBound(delarray) + 1 & " items"
    End If
    Next i

    For i = LBound(delarray) To UBound(delarray)
    MsgBox "Group " & ThisDrawing.Groups.Item(delarray(i)).Name & " will be
    deleted"
    ThisDrawing.Groups.Item(delarray(i)).Delete
    Next i
    End Sub

    probably don't need to put in array before deleting but I was having
    problems at first with it skipping items and I thought it was cause I was
    deleteing them from the group collection while iterating through the
    collection, thus messing up the index
    you can definitely improve on this one
     
    Mark Propst, Jul 2, 2003
    #3
  4. don't run in dwg with 95 unnamed groups :)
    When working on new subroutines I like to add a simple bailout in busy
    loops, in case I get into an infinite loop or just don't want to hit OK 95
    times. I've had to CTRL-ALT-DEL to kill ACAD before and lost some unsaved
    work. Now that I think about it, I remember that this happened when I had a
    MSGBOX in an infinite loop (that cycled quickly). I couldn't get the
    CTRL-BREAK to go to VBA because the msg box kept popping up before I could
    hit it.

    ---> If MsgBox ("put " & strname & " in array",vbokcancel) = vbcancel then
    exit sub

    James
     
    James Belshan, Jul 3, 2003
    #4
  5. Marcus

    Mark Propst Guest

    cool idea James,
    (as always)

    I never think about being able to put in the other buttons in a msb box,
    always use it like a dumb announer(got used to (alert "blah") in lisp)
    Thanks for jogging the brain cell.
    Mark
     
    Mark Propst, Jul 4, 2003
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.