<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342952#M98046</link>
    <description>alright, alright, sorry I badmouthed the book a little, I know that it's&lt;BR /&gt;
pretty much all we have and I'd be completely lost without it.  I'm just&lt;BR /&gt;
saying that there are some areas where important topics like removing&lt;BR /&gt;
objects are somewhat glossed over and not explained well.&lt;BR /&gt;
okay, now that that's out of the way,  I tried Denis' code in with mine&lt;BR /&gt;
but it gives err's when it tries to delete stuff.&lt;BR /&gt;
Okay, so here's my deletion code.  Lets assume that in this group there&lt;BR /&gt;
is the acadblockreference for a block called Title_Bar.  Using the Block&lt;BR /&gt;
Title_Bar I added two boxes and several acadattributes and inserted the&lt;BR /&gt;
block into modelspace.  Everything, including my meta attributes and the&lt;BR /&gt;
3dsolids, I have appended to the group with name strName.  So, here's my&lt;BR /&gt;
deletion code.  All it's doing right now is removing everything from the&lt;BR /&gt;
group.  I added in Denis' code at the end while trying to delete the&lt;BR /&gt;
block.  but it's not working and the geometry stays visible.  The code&lt;BR /&gt;
is clearing out the group correctly though because at the end the count&lt;BR /&gt;
is 0.&lt;BR /&gt;
grpChart is the group I'm using.&lt;BR /&gt;
James&lt;BR /&gt;
&lt;BR /&gt;
      iIndex = grpChart.Count()&lt;BR /&gt;
&lt;BR /&gt;
      iAtCnt = 0&lt;BR /&gt;
      iSlCnt = 0&lt;BR /&gt;
      iBlCnt = 0&lt;BR /&gt;
       If iIndex &amp;gt; 0 Then&lt;BR /&gt;
        For i = 0 To iIndex - 1&lt;BR /&gt;
          'tell what the entity name is&lt;BR /&gt;
          MsgBox grpChart.Item(i).EntityName&lt;BR /&gt;
            'if the item is an attribute then add to attribute array&lt;BR /&gt;
            If grpChart.Item(i).EntityName = "AcDbAttributeDefinition"&lt;BR /&gt;
Then&lt;BR /&gt;
            If iAtCnt = 0 Then&lt;BR /&gt;
                    ReDim objAtts(iAtCnt)&lt;BR /&gt;
                Else&lt;BR /&gt;
                    ReDim Preserve objAtts(iAtCnt)&lt;BR /&gt;
                End If&lt;BR /&gt;
                Set objAtts(iAtCnt) = grpChart.Item(i)&lt;BR /&gt;
                iAtCnt = iAtCnt + 1&lt;BR /&gt;
            'else if the item is a 3dsolid then add to solid array&lt;BR /&gt;
            ElseIf grpChart.Item(i).EntityName = "AcDb3dSolid" Then&lt;BR /&gt;
                If iSlCnt = 0 Then&lt;BR /&gt;
                    ReDim objSols(iSlCnt)&lt;BR /&gt;
                Else&lt;BR /&gt;
                    ReDim Preserve objSols(iSlCnt)&lt;BR /&gt;
                End If&lt;BR /&gt;
                Set objSols(iSlCnt) = grpChart.Item(i)&lt;BR /&gt;
                iSlCnt = iSlCnt + 1&lt;BR /&gt;
            'else if the item is a block ref. then add to block array&lt;BR /&gt;
            ElseIf grpChart.Item(i).EntityName = "AcDbBlockReference"&lt;BR /&gt;
Then&lt;BR /&gt;
                If iBlCnt = 0 Then&lt;BR /&gt;
                    ReDim objBlks(iBlCnt)&lt;BR /&gt;
                Else&lt;BR /&gt;
                    ReDim Preserve objBlks(iBlCnt)&lt;BR /&gt;
                End If&lt;BR /&gt;
                Set objBlks(iBlCnt) = grpChart.Item(i)&lt;BR /&gt;
                iBlCnt = iBlCnt + 1&lt;BR /&gt;
            End If&lt;BR /&gt;
        Next i&lt;BR /&gt;
            'if there were attributes then remove them&lt;BR /&gt;
            If iAtCnt &amp;gt; 0 Then&lt;BR /&gt;
                grpChart.RemoveItems objAtts&lt;BR /&gt;
                If Err Then&lt;BR /&gt;
                MsgBox "error deleting attributes"&lt;BR /&gt;
                End If&lt;BR /&gt;
            End If&lt;BR /&gt;
           'if there were solids then remove them&lt;BR /&gt;
            If iSlCnt &amp;gt; 0 Then&lt;BR /&gt;
                grpChart.RemoveItems objSols&lt;BR /&gt;
                If Err Then&lt;BR /&gt;
                MsgBox "error deleting solids"&lt;BR /&gt;
                End If&lt;BR /&gt;
            End If&lt;BR /&gt;
            'if there were blocks then remove them&lt;BR /&gt;
            If iBlCnt &amp;gt; 0 Then&lt;BR /&gt;
                grpChart.RemoveItems objBlks&lt;BR /&gt;
                If Err Then&lt;BR /&gt;
                MsgBox "error deleting blocks"&lt;BR /&gt;
                End If&lt;BR /&gt;
                For Each objEnt In ThisDrawing.ModelSpace&lt;BR /&gt;
                    If TypeOf objEnt Is AcadBlockReference Then&lt;BR /&gt;
                        If objEnt.Name = "Title_Bar" Then&lt;BR /&gt;
                            objEnt.Delete&lt;BR /&gt;
                            If Err Then&lt;BR /&gt;
                                MsgBox "unable to delete blkref&lt;BR /&gt;
'Title_Bar'"&lt;BR /&gt;
                            Else&lt;BR /&gt;
                                MsgBox "block ref delete completed"&lt;BR /&gt;
                            End If&lt;BR /&gt;
                        End If&lt;BR /&gt;
                    End If&lt;BR /&gt;
                Next objEnt&lt;BR /&gt;
&lt;BR /&gt;
                ThisDrawing.Application.Update&lt;BR /&gt;
&lt;BR /&gt;
                For Each objBlock In ThisDrawing.Blocks&lt;BR /&gt;
                    If objBlock.Name = "Title_Bar" Then&lt;BR /&gt;
                        objBlock.Delete&lt;BR /&gt;
                        If Err Then&lt;BR /&gt;
                            MsgBox "unable to delete blk 'Title_Bar'"&lt;BR /&gt;
                        Else&lt;BR /&gt;
                            MsgBox "block delete completed"&lt;BR /&gt;
                        End If&lt;BR /&gt;
                    End If&lt;BR /&gt;
                Next objBlock&lt;BR /&gt;
            End If&lt;BR /&gt;
            'output number of items&lt;BR /&gt;
            MsgBox "Number of items " &amp;amp; grpChart.Count&lt;BR /&gt;
        End If</description>
    <pubDate>Wed, 08 Dec 1999 18:01:27 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>1999-12-08T18:01:27Z</dc:date>
    <item>
      <title>deleting graphical objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342945#M98039</link>
      <description>James,&lt;BR /&gt;
&lt;BR /&gt;
The ModelSpace collection may contain an AcadBlockReference&lt;BR /&gt;
object but not an AcadBlock.&lt;BR /&gt;
&lt;BR /&gt;
Denis&lt;BR /&gt;
&lt;BR /&gt;
James McElroy, Jr. a écrit dans le message&lt;BR /&gt;
&amp;lt;384857F6.7118CB48@integware.com&amp;gt;...&lt;BR /&gt;
&amp;gt;if I have a block with a few boxes in modelspace.  How can I then delete&lt;BR /&gt;
&amp;gt;the visible graphical boxes from the block and from modelspace.  How,&lt;BR /&gt;
&amp;gt;also, can I delete the block from modelspace?]&lt;BR /&gt;
&amp;gt;James&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;--&lt;BR /&gt;
&amp;gt;*********************************&lt;BR /&gt;
&amp;gt;*     James S. McElroy, Jr.     *&lt;BR /&gt;
&amp;gt;*      james@integware.com      *&lt;BR /&gt;
&amp;gt;*********************************&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;</description>
      <pubDate>Fri, 03 Dec 1999 23:12:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342945#M98039</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-12-03T23:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: deleting graphical objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342946#M98040</link>
      <description>When you delete an AcadBlockReference you also delete the&lt;BR /&gt;
graphical objects contained in your model space (or in a layout) but the&lt;BR /&gt;
Block definition (AcadBlock) which is stored in the AcadBlocks&lt;BR /&gt;
collection is kept for further use.&lt;BR /&gt;
&lt;BR /&gt;
I'm still not sure to understand what you want to delete.&lt;BR /&gt;
Is it all the AcadBlockReferences of particular name???&lt;BR /&gt;
Is it the block definition???&lt;BR /&gt;
&lt;BR /&gt;
Denis&lt;BR /&gt;
&lt;BR /&gt;
James McElroy, Jr. a écrit dans le message&lt;BR /&gt;
&amp;lt;38485E25.53A1DAB7@integware.com&amp;gt;...&lt;BR /&gt;
&amp;gt;Oop's, that's what I meant, my problem is that I can delete all the refs.&lt;BR /&gt;
&amp;gt;that I want but I need to know how to delete the graphical objects so that&lt;BR /&gt;
I&lt;BR /&gt;
&amp;gt;can completely get rid of a block and the objects&lt;BR /&gt;
&amp;gt;James&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;Denis Gagne wrote:&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;James,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;The ModelSpace collection may contain an AcadBlockReference&lt;BR /&gt;
&amp;gt;object but not an AcadBlock.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;Denis&lt;BR /&gt;
&amp;gt;--&lt;BR /&gt;
&amp;gt;*********************************&lt;BR /&gt;
&amp;gt;*     James S. McElroy, Jr.     *&lt;BR /&gt;
&amp;gt;*      james@integware.com      *&lt;BR /&gt;
&amp;gt;*********************************&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;</description>
      <pubDate>Fri, 03 Dec 1999 23:37:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342946#M98040</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-12-03T23:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: deleting graphical objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342947#M98041</link>
      <description>if I have a block with a few boxes in modelspace.  How can I then delete&lt;BR /&gt;
the visible graphical boxes from the block and from modelspace.  How,&lt;BR /&gt;
also, can I delete the block from modelspace?]&lt;BR /&gt;
James&lt;BR /&gt;
&lt;BR /&gt;
--&lt;BR /&gt;
*********************************&lt;BR /&gt;
*     James S. McElroy, Jr.     *&lt;BR /&gt;
*      james@integware.com      *&lt;BR /&gt;
*********************************</description>
      <pubDate>Fri, 03 Dec 1999 23:53:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342947#M98041</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-12-03T23:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: deleting graphical objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342948#M98042</link>
      <description>Oop's, that's what I meant, my problem is that I can delete all the refs.&lt;BR /&gt;
that I want but I need to know how to delete the graphical objects so that I&lt;BR /&gt;
can completely get rid of a block and the objects&lt;BR /&gt;
James&lt;BR /&gt;
&lt;BR /&gt;
Denis Gagne wrote:&lt;BR /&gt;
&lt;BR /&gt;
James,&lt;BR /&gt;
&lt;BR /&gt;
The ModelSpace collection may contain an AcadBlockReference&lt;BR /&gt;
object but not an AcadBlock.&lt;BR /&gt;
&lt;BR /&gt;
Denis&lt;BR /&gt;
--&lt;BR /&gt;
*********************************&lt;BR /&gt;
*     James S. McElroy, Jr.     *&lt;BR /&gt;
*      james@integware.com      *&lt;BR /&gt;
*********************************</description>
      <pubDate>Sat, 04 Dec 1999 00:19:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342948#M98042</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-12-04T00:19:49Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342949#M98043</link>
      <description>&lt;BR /&gt;
&lt;BR /&gt;
Sorry I'm not being clear, the whole block and block ref. thing is seriously&lt;BR /&gt;
confusing to me.&amp;nbsp; I'm having to teach myself this api and I've only&lt;BR /&gt;
got the one Joe Sutphin book to help me and that is vague and obscure and&lt;BR /&gt;
doesn't cover a lot of areas.&amp;nbsp; So, let me start from the beginning&lt;BR /&gt;
of what I'm doing and see if that helps&lt;BR /&gt;
&lt;P&gt;Okay,&amp;nbsp; I create a block in the document.blocks collection.&amp;nbsp;&lt;BR /&gt;
I take that block and do a few block.addbox to create some 3d solids.&amp;nbsp;&lt;BR /&gt;
then I do a modelspace.insert with the origin, blockname, scales and rotation.&amp;nbsp;&lt;BR /&gt;
When I insert it I set it to a blockreference which I insert into a group.&amp;nbsp;&lt;BR /&gt;
Also, when I created the 3dsolids I added them to the group as well.&lt;BR /&gt;
&lt;/P&gt;&lt;P&gt;Now, my objective here is to run a different function that has the block&lt;BR /&gt;
and the group names, and I want to get rid of &lt;U&gt;everything&lt;/U&gt;!&amp;nbsp;&lt;BR /&gt;
the blocks, refs, definitions, solids, whatever it is that I need to get&lt;BR /&gt;
rid of to destroy it all and leave me with a document that does not now&lt;BR /&gt;
have the aforementioned objects that I created and added.&lt;BR /&gt;
&lt;/P&gt;&lt;P&gt;Maybe I'm doing something wrong while creating them and if so feel free&lt;BR /&gt;
to tell me.&amp;nbsp; But that's what I need to know how to do and all the&lt;BR /&gt;
book tells me is that to delete a block I have to delete all references&lt;BR /&gt;
to said block but it doesn't explain any further.&lt;BR /&gt;
&lt;BR /&gt;James&lt;BR /&gt;
&lt;/P&gt;&lt;P&gt;Denis Gagne wrote:&lt;BR /&gt;
&lt;/P&gt;&lt;BLOCKQUOTE type="CITE"&gt;When you delete an AcadBlockReference you also delete&lt;BR /&gt;
the&lt;BR /&gt;
&lt;BR /&gt;graphical objects contained in your model space (or in a layout) but&lt;BR /&gt;
the&lt;BR /&gt;
&lt;BR /&gt;Block definition (AcadBlock) which is stored in the AcadBlocks&lt;BR /&gt;
&lt;BR /&gt;collection is kept for further use.&lt;BR /&gt;
&lt;P&gt;I'm still not sure to understand what you want to delete.&lt;BR /&gt;
&lt;BR /&gt;Is it all the AcadBlockReferences of particular name???&lt;BR /&gt;
&lt;BR /&gt;Is it the block definition???&lt;BR /&gt;
&lt;/P&gt;&lt;P&gt;Denis&lt;BR /&gt;
&lt;/P&gt;&lt;P&gt;James McElroy, Jr. a écrit dans le message&lt;BR /&gt;
&lt;BR /&gt;&amp;lt;38485E25.53A1DAB7@integware.com&amp;gt;...&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;Oop's, that's what I meant, my problem is that I can delete all the&lt;BR /&gt;
refs.&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;that I want but I need to know how to delete the graphical objects&lt;BR /&gt;
so that&lt;BR /&gt;
&lt;BR /&gt;I&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;can completely get rid of a block and the objects&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;James&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;Denis Gagne wrote:&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;James,&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;The ModelSpace collection may contain an AcadBlockReference&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;object but not an AcadBlock.&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;Denis&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;--&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;*********************************&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; James S. McElroy, Jr.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;
*&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; james@integware.com&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;
*&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;*********************************&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;&amp;gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P&gt;--&lt;BR /&gt;
&lt;BR /&gt;*********************************&lt;BR /&gt;
&lt;BR /&gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; James S. McElroy, Jr.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;
*&lt;BR /&gt;
&lt;BR /&gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; james@integware.com&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;
*&lt;BR /&gt;
&lt;BR /&gt;*********************************&lt;BR /&gt;
&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 1999 00:50:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342949#M98043</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-12-04T00:50:27Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342950#M98044</link>
      <description>I am very disappointed to hear that you do not appreciate&lt;BR /&gt;
AutoCAD 2000 vba programmer's reference and I hope&lt;BR /&gt;
your opinion will change in the future.&lt;BR /&gt;
&lt;BR /&gt;
It's difficult for me to find a solution to your problem without&lt;BR /&gt;
seeing your code.&lt;BR /&gt;
&lt;BR /&gt;
but here's a suggestion:&lt;BR /&gt;
&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Option Compare Text&lt;BR /&gt;
&lt;BR /&gt;
Public Function DeleteThis(NameOfBlockToDelete As String, _&lt;BR /&gt;
    NameOfGroupToDelete As String)&lt;BR /&gt;
Dim oEnt As AcadEntity&lt;BR /&gt;
Dim oBlock As AcadBlock&lt;BR /&gt;
Dim oGroup As AcadGroup&lt;BR /&gt;
&lt;BR /&gt;
Set oGroup = ThisDrawing.Groups(NameOfGroupToDelete)&lt;BR /&gt;
For Each oEnt In oGroup&lt;BR /&gt;
  oEnt.Delete&lt;BR /&gt;
Next&lt;BR /&gt;
oGroup.Delete&lt;BR /&gt;
&lt;BR /&gt;
For Each oEnt In ThisDrawing.ModelSpace&lt;BR /&gt;
  If TypeOf oEnt Is AcadBlockReference Then&lt;BR /&gt;
    If oEnt.Name = NameOfBlockToDelete _&lt;BR /&gt;
        Then oEnt.Delete&lt;BR /&gt;
  End If&lt;BR /&gt;
Next&lt;BR /&gt;
&lt;BR /&gt;
ThisDrawing.Application.Update&lt;BR /&gt;
&lt;BR /&gt;
For Each oBlock In ThisDrawing.Blocks&lt;BR /&gt;
  If oBlock.Name = NameOfBlockToDelete _&lt;BR /&gt;
    Then oBlock.Delete&lt;BR /&gt;
Next&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Denis&lt;BR /&gt;
&lt;BR /&gt;
    James McElroy, Jr. a écrit dans le message&lt;BR /&gt;
&amp;lt;38486552.76999782@integware.com&amp;gt;...&lt;BR /&gt;
    Sorry I'm not being clear, the whole block and block ref. thing is&lt;BR /&gt;
seriously confusing to me.  I'm having to teach myself this api and I've&lt;BR /&gt;
only got the one Joe Sutphin book to help me and that is vague and obscure&lt;BR /&gt;
and doesn't cover a lot of areas.  So, let me start from the beginning of&lt;BR /&gt;
what I'm doing and see if that helps&lt;BR /&gt;
    Okay,  I create a block in the document.blocks collection.  I take that&lt;BR /&gt;
block and do a few block.addbox to create some 3d solids.  then I do a&lt;BR /&gt;
modelspace.insert with the origin, blockname, scales and rotation.  When I&lt;BR /&gt;
insert it I set it to a blockreference which I insert into a group.  Also,&lt;BR /&gt;
when I created the 3dsolids I added them to the group as well.&lt;BR /&gt;
&lt;BR /&gt;
    Now, my objective here is to run a different function that has the block&lt;BR /&gt;
and the group names, and I want to get rid of everything!  the blocks, refs,&lt;BR /&gt;
definitions, solids, whatever it is that I need to get rid of to destroy it&lt;BR /&gt;
all and leave me with a document that does not now have the aforementioned&lt;BR /&gt;
objects that I created and added.&lt;BR /&gt;
&lt;BR /&gt;
    Maybe I'm doing something wrong while creating them and if so feel free&lt;BR /&gt;
to tell me.  But that's what I need to know how to do and all the book tells&lt;BR /&gt;
me is that to delete a block I have to delete all references to said block&lt;BR /&gt;
but it doesn't explain any further.&lt;BR /&gt;
    James&lt;BR /&gt;
&lt;BR /&gt;
    Denis Gagne wrote:&lt;BR /&gt;
&lt;BR /&gt;
        When you delete an AcadBlockReference you also delete the&lt;BR /&gt;
        graphical objects contained in your model space (or in a layout) but&lt;BR /&gt;
the&lt;BR /&gt;
        Block definition (AcadBlock) which is stored in the AcadBlocks&lt;BR /&gt;
        collection is kept for further use.&lt;BR /&gt;
        I'm still not sure to understand what you want to delete.&lt;BR /&gt;
        Is it all the AcadBlockReferences of particular name???&lt;BR /&gt;
        Is it the block definition???&lt;BR /&gt;
&lt;BR /&gt;
        Denis&lt;BR /&gt;
&lt;BR /&gt;
        James McElroy, Jr. a écrit dans le message&lt;BR /&gt;
        &amp;lt;38485E25.53A1DAB7@integware.com&amp;gt;...&lt;BR /&gt;
        &amp;gt;Oop's, that's what I meant, my problem is that I can delete all the&lt;BR /&gt;
refs.&lt;BR /&gt;
        &amp;gt;that I want but I need to know how to delete the graphical objects&lt;BR /&gt;
so that&lt;BR /&gt;
        I&lt;BR /&gt;
        &amp;gt;can completely get rid of a block and the objects&lt;BR /&gt;
        &amp;gt;James&lt;BR /&gt;
        &amp;gt;&lt;BR /&gt;
        &amp;gt;Denis Gagne wrote:&lt;BR /&gt;
        &amp;gt;&lt;BR /&gt;
        &amp;gt;James,&lt;BR /&gt;
        &amp;gt;&lt;BR /&gt;
        &amp;gt;The ModelSpace collection may contain an AcadBlockReference&lt;BR /&gt;
        &amp;gt;object but not an AcadBlock.&lt;BR /&gt;
        &amp;gt;&lt;BR /&gt;
        &amp;gt;Denis&lt;BR /&gt;
        &amp;gt;--&lt;BR /&gt;
        &amp;gt;*********************************&lt;BR /&gt;
        &amp;gt;*     James S. McElroy, Jr.     *&lt;BR /&gt;
        &amp;gt;*      james@integware.com      *&lt;BR /&gt;
        &amp;gt;*********************************&lt;BR /&gt;
        &amp;gt;&lt;BR /&gt;
        &amp;gt;&lt;BR /&gt;
&lt;BR /&gt;
    --&lt;BR /&gt;
    *********************************&lt;BR /&gt;
    *     James S. McElroy, Jr.     *&lt;BR /&gt;
    *      james@integware.com      *&lt;BR /&gt;
    *********************************</description>
      <pubDate>Sat, 04 Dec 1999 00:51:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342950#M98044</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-12-04T00:51:26Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342951#M98045</link>
      <description>&lt;DIV&gt;&lt;FONT color="#000000" size="2"&gt;James:&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT color="#000000" size="2"&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;why don't you post your &lt;BR /&gt;
code, so we know what is your problems!&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2"&gt;amy&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2"&gt;ps: without Joe Sutphine's book we are all in the &lt;BR /&gt;
dark!&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="BORDER-LEFT: #000000 solid 2px; MARGIN-LEFT: 5px; PADDING-LEFT: 5px"&amp;gt;&lt;BR /&gt;
    &lt;DIV&gt;James McElroy, Jr.&lt;JAMES&gt; wrote in message &amp;lt;&lt;A&gt;&lt;BR /&gt;
    href="mailto:38486552.76999782@integware.com"&amp;gt;38486552.76999782@integware.com&lt;/A&gt;&amp;gt;...&lt;/JAMES&gt;&lt;/DIV&gt;Sorry &lt;BR /&gt;
    I'm not being clear, the whole block and block ref. thing is seriously &lt;BR /&gt;
    confusing to me.&amp;nbsp; I'm having to teach myself this api and I've only got &lt;BR /&gt;
    the one Joe Sutphin book to help me and that is vague and obscure and &lt;BR /&gt;
    doesn't cover a lot of areas.&amp;nbsp; So, let me start from the beginning of &lt;BR /&gt;
    what I'm doing and see if that helps &lt;BR /&gt;
    &lt;P&gt;Okay,&amp;nbsp; I create a block in the document.blocks collection.&amp;nbsp; I &lt;BR /&gt;
    take that block and do a few block.addbox to create some 3d solids.&amp;nbsp; &lt;BR /&gt;
    then I do a modelspace.insert with the origin, blockname, scales and &lt;BR /&gt;
    rotation.&amp;nbsp; When I insert it I set it to a blockreference which I insert &lt;BR /&gt;
    into a group.&amp;nbsp; Also, when I created the 3dsolids I added them to the &lt;BR /&gt;
    group as well. &lt;BR /&gt;
    &lt;/P&gt;&lt;P&gt;Now, my objective here is to run a different function that has the block &lt;BR /&gt;
    and the group names, and I want to get rid of &lt;U&gt;everything&lt;/U&gt;!&amp;nbsp; the &lt;BR /&gt;
    blocks, refs, definitions, solids, whatever it is that I need to get rid of &lt;BR /&gt;
    to destroy it all and leave me with a document that does not now have the &lt;BR /&gt;
    aforementioned objects that I created and added. &lt;BR /&gt;
    &lt;/P&gt;&lt;P&gt;Maybe I'm doing something wrong while creating them and if so feel free &lt;BR /&gt;
    to tell me.&amp;nbsp; But that's what I need to know how to do and all the book &lt;BR /&gt;
    tells me is that to delete a block I have to delete all references to said &lt;BR /&gt;
    block but it doesn't explain any further. &lt;BR /&gt;James &lt;BR /&gt;
    &lt;/P&gt;&lt;P&gt;Denis Gagne wrote: &lt;BR /&gt;
    &lt;/P&gt;&lt;BLOCKQUOTE type="CITE"&gt;When you delete an AcadBlockReference you also &lt;BR /&gt;
        delete the &lt;BR /&gt;graphical objects contained in your model space (or in a &lt;BR /&gt;
        layout) but the &lt;BR /&gt;Block definition (AcadBlock) which is stored in the &lt;BR /&gt;
        AcadBlocks &lt;BR /&gt;collection is kept for further use. &lt;BR /&gt;
        &lt;P&gt;I'm still not sure to understand what you want to delete. &lt;BR /&gt;Is it &lt;BR /&gt;
        all the AcadBlockReferences of particular name??? &lt;BR /&gt;Is it the block &lt;BR /&gt;
        definition??? &lt;BR /&gt;
        &lt;/P&gt;&lt;P&gt;Denis &lt;BR /&gt;
        &lt;/P&gt;&lt;P&gt;James McElroy, Jr. a écrit dans le message &lt;BR /&gt;
        &lt;BR /&gt;&amp;lt;38485E25.53A1DAB7@integware.com&amp;gt;... &lt;BR /&gt;&amp;gt;Oop's, that's &lt;BR /&gt;
        what I meant, my problem is that I can delete all the refs. &lt;BR /&gt;&amp;gt;that &lt;BR /&gt;
        I want but I need to know how to delete the graphical objects so that &lt;BR /&gt;
        &lt;BR /&gt;I &lt;BR /&gt;&amp;gt;can completely get rid of a block and the objects &lt;BR /&gt;
        &lt;BR /&gt;&amp;gt;James &lt;BR /&gt;&amp;gt; &lt;BR /&gt;&amp;gt;Denis Gagne wrote: &lt;BR /&gt;&amp;gt; &lt;BR /&gt;
        &lt;BR /&gt;&amp;gt;James, &lt;BR /&gt;&amp;gt; &lt;BR /&gt;&amp;gt;The ModelSpace collection may contain an &lt;BR /&gt;
        AcadBlockReference &lt;BR /&gt;&amp;gt;object but not an AcadBlock. &lt;BR /&gt;&amp;gt; &lt;BR /&gt;
        &lt;BR /&gt;&amp;gt;Denis &lt;BR /&gt;&amp;gt;-- &lt;BR /&gt;&amp;gt;********************************* &lt;BR /&gt;
        &lt;BR /&gt;&amp;gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; James S. McElroy, &lt;BR /&gt;
        Jr.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * &lt;BR /&gt;&amp;gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
        james@integware.com&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * &lt;BR /&gt;
        &lt;BR /&gt;&amp;gt;********************************* &lt;BR /&gt;&amp;gt; &lt;BR /&gt;&amp;gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;
    &lt;P&gt;-- &lt;BR /&gt;********************************* &lt;BR /&gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
    James S. McElroy, Jr.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * &lt;BR /&gt;
    &lt;BR /&gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
    james@integware.com&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * &lt;BR /&gt;
    &lt;BR /&gt;********************************* &lt;BR /&gt;&amp;nbsp; &lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sun, 05 Dec 1999 10:25:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342951#M98045</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-12-05T10:25:19Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342952#M98046</link>
      <description>alright, alright, sorry I badmouthed the book a little, I know that it's&lt;BR /&gt;
pretty much all we have and I'd be completely lost without it.  I'm just&lt;BR /&gt;
saying that there are some areas where important topics like removing&lt;BR /&gt;
objects are somewhat glossed over and not explained well.&lt;BR /&gt;
okay, now that that's out of the way,  I tried Denis' code in with mine&lt;BR /&gt;
but it gives err's when it tries to delete stuff.&lt;BR /&gt;
Okay, so here's my deletion code.  Lets assume that in this group there&lt;BR /&gt;
is the acadblockreference for a block called Title_Bar.  Using the Block&lt;BR /&gt;
Title_Bar I added two boxes and several acadattributes and inserted the&lt;BR /&gt;
block into modelspace.  Everything, including my meta attributes and the&lt;BR /&gt;
3dsolids, I have appended to the group with name strName.  So, here's my&lt;BR /&gt;
deletion code.  All it's doing right now is removing everything from the&lt;BR /&gt;
group.  I added in Denis' code at the end while trying to delete the&lt;BR /&gt;
block.  but it's not working and the geometry stays visible.  The code&lt;BR /&gt;
is clearing out the group correctly though because at the end the count&lt;BR /&gt;
is 0.&lt;BR /&gt;
grpChart is the group I'm using.&lt;BR /&gt;
James&lt;BR /&gt;
&lt;BR /&gt;
      iIndex = grpChart.Count()&lt;BR /&gt;
&lt;BR /&gt;
      iAtCnt = 0&lt;BR /&gt;
      iSlCnt = 0&lt;BR /&gt;
      iBlCnt = 0&lt;BR /&gt;
       If iIndex &amp;gt; 0 Then&lt;BR /&gt;
        For i = 0 To iIndex - 1&lt;BR /&gt;
          'tell what the entity name is&lt;BR /&gt;
          MsgBox grpChart.Item(i).EntityName&lt;BR /&gt;
            'if the item is an attribute then add to attribute array&lt;BR /&gt;
            If grpChart.Item(i).EntityName = "AcDbAttributeDefinition"&lt;BR /&gt;
Then&lt;BR /&gt;
            If iAtCnt = 0 Then&lt;BR /&gt;
                    ReDim objAtts(iAtCnt)&lt;BR /&gt;
                Else&lt;BR /&gt;
                    ReDim Preserve objAtts(iAtCnt)&lt;BR /&gt;
                End If&lt;BR /&gt;
                Set objAtts(iAtCnt) = grpChart.Item(i)&lt;BR /&gt;
                iAtCnt = iAtCnt + 1&lt;BR /&gt;
            'else if the item is a 3dsolid then add to solid array&lt;BR /&gt;
            ElseIf grpChart.Item(i).EntityName = "AcDb3dSolid" Then&lt;BR /&gt;
                If iSlCnt = 0 Then&lt;BR /&gt;
                    ReDim objSols(iSlCnt)&lt;BR /&gt;
                Else&lt;BR /&gt;
                    ReDim Preserve objSols(iSlCnt)&lt;BR /&gt;
                End If&lt;BR /&gt;
                Set objSols(iSlCnt) = grpChart.Item(i)&lt;BR /&gt;
                iSlCnt = iSlCnt + 1&lt;BR /&gt;
            'else if the item is a block ref. then add to block array&lt;BR /&gt;
            ElseIf grpChart.Item(i).EntityName = "AcDbBlockReference"&lt;BR /&gt;
Then&lt;BR /&gt;
                If iBlCnt = 0 Then&lt;BR /&gt;
                    ReDim objBlks(iBlCnt)&lt;BR /&gt;
                Else&lt;BR /&gt;
                    ReDim Preserve objBlks(iBlCnt)&lt;BR /&gt;
                End If&lt;BR /&gt;
                Set objBlks(iBlCnt) = grpChart.Item(i)&lt;BR /&gt;
                iBlCnt = iBlCnt + 1&lt;BR /&gt;
            End If&lt;BR /&gt;
        Next i&lt;BR /&gt;
            'if there were attributes then remove them&lt;BR /&gt;
            If iAtCnt &amp;gt; 0 Then&lt;BR /&gt;
                grpChart.RemoveItems objAtts&lt;BR /&gt;
                If Err Then&lt;BR /&gt;
                MsgBox "error deleting attributes"&lt;BR /&gt;
                End If&lt;BR /&gt;
            End If&lt;BR /&gt;
           'if there were solids then remove them&lt;BR /&gt;
            If iSlCnt &amp;gt; 0 Then&lt;BR /&gt;
                grpChart.RemoveItems objSols&lt;BR /&gt;
                If Err Then&lt;BR /&gt;
                MsgBox "error deleting solids"&lt;BR /&gt;
                End If&lt;BR /&gt;
            End If&lt;BR /&gt;
            'if there were blocks then remove them&lt;BR /&gt;
            If iBlCnt &amp;gt; 0 Then&lt;BR /&gt;
                grpChart.RemoveItems objBlks&lt;BR /&gt;
                If Err Then&lt;BR /&gt;
                MsgBox "error deleting blocks"&lt;BR /&gt;
                End If&lt;BR /&gt;
                For Each objEnt In ThisDrawing.ModelSpace&lt;BR /&gt;
                    If TypeOf objEnt Is AcadBlockReference Then&lt;BR /&gt;
                        If objEnt.Name = "Title_Bar" Then&lt;BR /&gt;
                            objEnt.Delete&lt;BR /&gt;
                            If Err Then&lt;BR /&gt;
                                MsgBox "unable to delete blkref&lt;BR /&gt;
'Title_Bar'"&lt;BR /&gt;
                            Else&lt;BR /&gt;
                                MsgBox "block ref delete completed"&lt;BR /&gt;
                            End If&lt;BR /&gt;
                        End If&lt;BR /&gt;
                    End If&lt;BR /&gt;
                Next objEnt&lt;BR /&gt;
&lt;BR /&gt;
                ThisDrawing.Application.Update&lt;BR /&gt;
&lt;BR /&gt;
                For Each objBlock In ThisDrawing.Blocks&lt;BR /&gt;
                    If objBlock.Name = "Title_Bar" Then&lt;BR /&gt;
                        objBlock.Delete&lt;BR /&gt;
                        If Err Then&lt;BR /&gt;
                            MsgBox "unable to delete blk 'Title_Bar'"&lt;BR /&gt;
                        Else&lt;BR /&gt;
                            MsgBox "block delete completed"&lt;BR /&gt;
                        End If&lt;BR /&gt;
                    End If&lt;BR /&gt;
                Next objBlock&lt;BR /&gt;
            End If&lt;BR /&gt;
            'output number of items&lt;BR /&gt;
            MsgBox "Number of items " &amp;amp; grpChart.Count&lt;BR /&gt;
        End If</description>
      <pubDate>Wed, 08 Dec 1999 18:01:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342952#M98046</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-12-08T18:01:27Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342953#M98047</link>
      <description>okay, so let's try a simple one.  here's some code that I just wrote to test&lt;BR /&gt;
this.  now, how would I have to modify the delete function in order to&lt;BR /&gt;
destroy the block and erase the box from the drawing?&lt;BR /&gt;
&lt;BR /&gt;
Sub test_blocks()&lt;BR /&gt;
    Dim oblk As AcadBlock&lt;BR /&gt;
    Dim oblkr As AcadBlockReference&lt;BR /&gt;
    Dim obox As Acad3DSolid&lt;BR /&gt;
    Dim dorg(2) As Double&lt;BR /&gt;
    dorg(0) = 0: dorg(1) = 0: dorg(2) = 0&lt;BR /&gt;
&lt;BR /&gt;
On Error Resume Next&lt;BR /&gt;
    Set oblk = ThisDrawing.Blocks("hi")&lt;BR /&gt;
    If oblk Is Nothing Then&lt;BR /&gt;
        Set oblk = ThisDrawing.Blocks.Add(dorg, "hi")&lt;BR /&gt;
        Set obox = oblk.AddBox(dorg, 1, 0.5, 0.01)&lt;BR /&gt;
        Set oblkr = ThisDrawing.ModelSpace.InsertBlock(dorg, "hi", 1, 1, 0)&lt;BR /&gt;
    Else&lt;BR /&gt;
        Call delete&lt;BR /&gt;
    End If&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Sub delete()&lt;BR /&gt;
    Dim oblk As AcadBlock&lt;BR /&gt;
    Dim oblkr As AcadBlockReference&lt;BR /&gt;
    Dim oent As AcadEntity&lt;BR /&gt;
&lt;BR /&gt;
On Error Resume Next&lt;BR /&gt;
    For Each oent In ThisDrawing.ModelSpace&lt;BR /&gt;
        oent.delete&lt;BR /&gt;
        If Err Then&lt;BR /&gt;
            MsgBox "error deleting " &amp;amp; oent.EntityName&lt;BR /&gt;
        End If&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    Set oblkr = ThisDrawing.Blocks("hi")&lt;BR /&gt;
    If Not oblkr Is Nothing Then&lt;BR /&gt;
        oblkr.delete&lt;BR /&gt;
        If Err Then&lt;BR /&gt;
            MsgBox "error deleting blkr " &amp;amp; oblkr.EntityName&lt;BR /&gt;
        End If&lt;BR /&gt;
    Else&lt;BR /&gt;
        MsgBox "blkr doesn't exist"&lt;BR /&gt;
    End If&lt;BR /&gt;
&lt;BR /&gt;
    Set oblk = ThisDrawing.Blocks("hi")&lt;BR /&gt;
    If Not oblk Is Nothing Then&lt;BR /&gt;
        oblk.delete&lt;BR /&gt;
        If Err Then&lt;BR /&gt;
            MsgBox "error deleting blk " &amp;amp; oblk.EntityName&lt;BR /&gt;
        End If&lt;BR /&gt;
    Else&lt;BR /&gt;
        MsgBox "blk doesn't exist"&lt;BR /&gt;
    End If&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
*********************************&lt;BR /&gt;
*     James S. McElroy, Jr.     *&lt;BR /&gt;
*      james@integware.com      *&lt;BR /&gt;
*********************************</description>
      <pubDate>Wed, 08 Dec 1999 20:37:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/deleting-graphical-objects/m-p/342953#M98047</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>1999-12-08T20:37:57Z</dc:date>
    </item>
  </channel>
</rss>

