Delete groups and contents

Discussion in 'AutoCAD' started by DRW1975, Feb 1, 2005.

  1. DRW1975

    DRW1975 Guest

    I am trying to delete a group (and the contents of that group) by selecting the reference handle of that group... is this possible?
    I would have thought this an easy task, but I can't seem to get it to work...

    DRW
     
    DRW1975, Feb 1, 2005
    #1
  2. DRW1975

    DRW1975 Guest

    hmmm... I take it by the lack of response, there is no way to delete the contents of a group by selecting that particular group's handle...

    DRW
     
    DRW1975, Feb 8, 2005
    #2
  3. How are you "selecting that particular group's handle..."?

    If groups are on, you can select all members of a group by selecting a
    member of that group. Then all you have to do is delete the objects in that
    selection set.

    contents of a group by selecting that particular group's handle...
     
    Allen Johnson, Feb 9, 2005
    #3
  4. DRW1975

    DRW1975 Guest

    I was making an ACADobject = thisDrawing.HandleToObject(HANDLE-of-GROUP-i-WANT-to-DELETE)
    then trying delete ACADobject... but this seems to only delete the group itself, not the contents of the group...

    I have managed to code my way around this, but it required two subroutines, some new global variables and a bunch of my time... but if you know a quicker way (there must be one), I will gladly delete what i've done to make it work.

    DRW
     
    DRW1975, Feb 9, 2005
    #4
  5. DRW1975

    fantum Guest

    Dim ent As AcadEntity
    For Each ent In ACADobject
    ent.Delete
    Next ent
     
    fantum, Feb 9, 2005
    #5
  6. DRW1975

    DRW1975 Guest

    ArRrGgGg
    lordy lordy lordy...
    I've attached my code that i had to use for a laugh

    made the change - thanks fantum

    DRW

    ...

    Sub RemoveExistingSupport(Node)
    Dim LookForHandle As String
    Dim TotalSups As Integer
    Dim FirstValue As Long: Dim LastValue As Long
    Dim AutoObj As AcadObject
    Dim TempSupRef() As String
    LookForHandle = VarCoords(Node, 2)
    TotalSups = Val(SupRef(0, 0))
    For I = 1 To TotalSups
    If LookForHandle = SupRef(I, 0) Then
    FirstValue = Val("&H" & SupRef(I, 1))
    LastValue = Val("&H" & SupRef(I, 2))
    For j = FirstValue To LastValue
    Set AutoObj = ThisDrawing.HandleToObject(Hex(j))
    AutoObj.Delete
    Next j
    ReDim TempSupRef(TotalSups - 1, 2)
    For j = 0 To TotalSups - 1
    If j >= I Then
    For k = 0 To 2
    TempSupRef(j, k) = SupRef(j + 1, k)
    Next k
    Else
    For k = 0 To 2
    TempSupRef(j, k) = SupRef(j, k)
    Next k
    End If
    Next j
    ReDim SupRef(TotalSups - 1, 2)
    For j = 0 To TotalSups - 1
    For k = 0 To 2
    SupRef(j, k) = TempSupRef(j, k)
    Next k
    Next j
    SupRef(0, 0) = Str(Val(SupRef(0, 0) - 1))
    I = TotalSups ' to stop loop
    End If
    Next I
    VarCoords(Node, 2) = ""
    VarCoords(Node, 3) = 0
    End Sub

    Sub AddSupRef(GroupHandle, FirstHandle, LastHandle)
    Dim TempSupRef() As String
    Dim CountSup As Integer
    If SupRef(0, 0) = "" Or SupRef(0, 0) = " 0" Then
    ReDim SupRef(1, 2)
    SupRef(1, 0) = GroupHandle: SupRef(1, 1) = FirstHandle: SupRef(1, 2) = LastHandle
    SupRef(0, 0) = Str(Val(SupRef(0, 0)) + 1)
    Else
    CountSup = Val(SupRef(0, 0))
    ReDim TempSupRef(CountSup, 2)
    For I = 0 To CountSup
    For j = 0 To 2
    TempSupRef(I, j) = SupRef(I, j)
    Next j
    Next I
    ReDim SupRef(I, j)
    For I = 0 To CountSup
    For j = 0 To 2
    SupRef(I, j) = TempSupRef(I, j)
    Next j
    Next I
    SupRef(I, 0) = GroupHandle: SupRef(I, 1) = FirstHandle: SupRef(I, 2) = LastHandle
    SupRef(0, 0) = Str(CountSup + 1)
    End If
    End Sub
    ... and a bunch of other references
    :p
     
    DRW1975, Feb 9, 2005
    #6
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.