<?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: Delete a block with attributes in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200504#M28009</link>
    <description>Ok, I figured it out, the purge question is moot.
I wasnt sure if I could do something like "pBlkTableRec-&amp;gt;erase()" cuz
erase is not a member of TableRecord per se, but if you stroll up the 
heirarchy chart it does eventually inherit the method from AcRxObject.
So I decided what the heck, give it a try, the worst that can happen is
crashing Acad or my computer bursting into flames and since I hate my 
computer...
Low and behold, it worked, effectively "purging" the block and I didnt 
have to mess with the attributes either.
My only question, does pBlkTableRec-&amp;gt;close() still need to be called on 
erased record?? havent tried commenting out that line yet.

Thanks for the input guys!
Perry</description>
    <pubDate>Wed, 08 Dec 2004 21:07:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2004-12-08T21:07:31Z</dc:date>
    <item>
      <title>Delete a block with attributes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200500#M28005</link>
      <description>I want to delete a block containing attributes, the following couple of 
lines (minus all the stardard peripheral code) will delete the block...

if ((blkRef = AcDbBlockReference::cast(pEnt)) != NULL)
{					pBlkTableRec-&amp;gt;getBlockReferenceIds(refEnts);
blkRef-&amp;gt;erase();
blkRef-&amp;gt;close();
}

You might ask why Im getting the RefID, because I want to purge the 
block after erasing so I can reinsert the block from an external file.
After the above code executes, the block indeed disappears from the 
screen, but my code to purge does not seem to work, heres how I did that...

AcDbDatabase* pDb = acdbHostApplicationServices()-&amp;gt;workingDatabase();
pDb-&amp;gt;purge(refEnts);

after this, the block def remains so my subsequent insert is not as 
expected.
Am I correct in assuming that deleting the block did NOT delete its 
attributes? are there now "orphan" attribute defs with no block?
If this is the case, then before deleting the blockref, do I need to 
iterate through its attributes and delete them first?
Lastly, is there an easier way of doing this??? :)

Thanks
Perry</description>
      <pubDate>Wed, 08 Dec 2004 17:06:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200500#M28005</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-12-08T17:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Delete a block with attributes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200501#M28006</link>
      <description>Why are you going through pDB-&amp;gt;purge()? If you don't have any block 
references to a block table record then just erase the block table record.

Are you trying to redefine a block so all your references are updated or are 
you wanting all references deleted and the block definition itself also 
purged?

- Jorge


"perry" &lt;PERRY_LEETS&gt; wrote in message 
news:41b73484$1_1@newsprd01...
&amp;gt;I want to delete a block containing attributes, the following couple of 
&amp;gt;lines (minus all the stardard peripheral code) will delete the block...
&amp;gt;
&amp;gt; if ((blkRef = AcDbBlockReference::cast(pEnt)) != NULL)
&amp;gt; { pBlkTableRec-&amp;gt;getBlockReferenceIds(refEnts);
&amp;gt; blkRef-&amp;gt;erase();
&amp;gt; blkRef-&amp;gt;close();
&amp;gt; }
&amp;gt;
&amp;gt; You might ask why Im getting the RefID, because I want to purge the block 
&amp;gt; after erasing so I can reinsert the block from an external file.
&amp;gt; After the above code executes, the block indeed disappears from the 
&amp;gt; screen, but my code to purge does not seem to work, heres how I did 
&amp;gt; that...
&amp;gt;
&amp;gt; AcDbDatabase* pDb = acdbHostApplicationServices()-&amp;gt;workingDatabase();
&amp;gt; pDb-&amp;gt;purge(refEnts);
&amp;gt;
&amp;gt; after this, the block def remains so my subsequent insert is not as 
&amp;gt; expected.
&amp;gt; Am I correct in assuming that deleting the block did NOT delete its 
&amp;gt; attributes? are there now "orphan" attribute defs with no block?
&amp;gt; If this is the case, then before deleting the blockref, do I need to 
&amp;gt; iterate through its attributes and delete them first?
&amp;gt; Lastly, is there an easier way of doing this??? :)
&amp;gt;
&amp;gt; Thanks
&amp;gt; Perry&lt;/PERRY_LEETS&gt;</description>
      <pubDate>Wed, 08 Dec 2004 17:58:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200501#M28006</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-12-08T17:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Delete a block with attributes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200502#M28007</link>
      <description>Jorge Lopez wrote:
&amp;gt;  Why are you going through pDB-&amp;gt;purge()? If you don't have any block 
&amp;gt; references to a block table record then just erase the block table record.
&amp;gt; 
&amp;gt; Are you trying to redefine a block so all your references are updated or are 
&amp;gt; you wanting all references deleted and the block definition itself also 
&amp;gt; purged?
&amp;gt; 
&amp;gt; - Jorge
The later Jorge, there should be only one reference, which I want to 
delete, then I want to delete the block definition so that I can insert
a new one without any collisions.

Perry</description>
      <pubDate>Wed, 08 Dec 2004 18:07:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200502#M28007</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-12-08T18:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Delete a block with attributes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200503#M28008</link>
      <description>AcDbDatabase::purge() does not purge anything.  All it does is determine 
what objects are safely purgeable.

As Jorge has already pointed out, if you know that the BlockTableRecord is 
not referenced by anything, then open it for write and call its erase() 
method to erase it.

"perry" &lt;PERRY_LEETS&gt; wrote in message 
news:41b73484$1_1@newsprd01...
&amp;gt;I want to delete a block containing attributes, the following couple of 
&amp;gt;lines (minus all the stardard peripheral code) will delete the block...
&amp;gt;
&amp;gt; if ((blkRef = AcDbBlockReference::cast(pEnt)) != NULL)
&amp;gt; { pBlkTableRec-&amp;gt;getBlockReferenceIds(refEnts);
&amp;gt; blkRef-&amp;gt;erase();
&amp;gt; blkRef-&amp;gt;close();
&amp;gt; }
&amp;gt;
&amp;gt; You might ask why Im getting the RefID, because I want to purge the block 
&amp;gt; after erasing so I can reinsert the block from an external file.
&amp;gt; After the above code executes, the block indeed disappears from the 
&amp;gt; screen, but my code to purge does not seem to work, heres how I did 
&amp;gt; that...
&amp;gt;
&amp;gt; AcDbDatabase* pDb = acdbHostApplicationServices()-&amp;gt;workingDatabase();
&amp;gt; pDb-&amp;gt;purge(refEnts);
&amp;gt;
&amp;gt; after this, the block def remains so my subsequent insert is not as 
&amp;gt; expected.
&amp;gt; Am I correct in assuming that deleting the block did NOT delete its 
&amp;gt; attributes? are there now "orphan" attribute defs with no block?
&amp;gt; If this is the case, then before deleting the blockref, do I need to 
&amp;gt; iterate through its attributes and delete them first?
&amp;gt; Lastly, is there an easier way of doing this??? :)
&amp;gt;
&amp;gt; Thanks
&amp;gt; Perry&lt;/PERRY_LEETS&gt;</description>
      <pubDate>Wed, 08 Dec 2004 18:56:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200503#M28008</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-12-08T18:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Delete a block with attributes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200504#M28009</link>
      <description>Ok, I figured it out, the purge question is moot.
I wasnt sure if I could do something like "pBlkTableRec-&amp;gt;erase()" cuz
erase is not a member of TableRecord per se, but if you stroll up the 
heirarchy chart it does eventually inherit the method from AcRxObject.
So I decided what the heck, give it a try, the worst that can happen is
crashing Acad or my computer bursting into flames and since I hate my 
computer...
Low and behold, it worked, effectively "purging" the block and I didnt 
have to mess with the attributes either.
My only question, does pBlkTableRec-&amp;gt;close() still need to be called on 
erased record?? havent tried commenting out that line yet.

Thanks for the input guys!
Perry</description>
      <pubDate>Wed, 08 Dec 2004 21:07:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200504#M28009</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-12-08T21:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Delete a block with attributes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200505#M28010</link>
      <description>Yes, close still needs to be called on an erased object.  If you don't, then 
at the very least, undo will have problems trying to open the object to undo 
the erase.

By the way, erase() comes from AcDbObject not AcRxObject.  Only objects that 
are database resident can be erased.

"perry" &lt;PERRY_LEETS&gt; wrote in message 
news:41b76d19$1_1@newsprd01...
&amp;gt; Ok, I figured it out, the purge question is moot.
&amp;gt; I wasnt sure if I could do something like "pBlkTableRec-&amp;gt;erase()" cuz
&amp;gt; erase is not a member of TableRecord per se, but if you stroll up the 
&amp;gt; heirarchy chart it does eventually inherit the method from AcRxObject.
&amp;gt; So I decided what the heck, give it a try, the worst that can happen is
&amp;gt; crashing Acad or my computer bursting into flames and since I hate my 
&amp;gt; computer...
&amp;gt; Low and behold, it worked, effectively "purging" the block and I didnt 
&amp;gt; have to mess with the attributes either.
&amp;gt; My only question, does pBlkTableRec-&amp;gt;close() still need to be called on 
&amp;gt; erased record?? havent tried commenting out that line yet.
&amp;gt;
&amp;gt; Thanks for the input guys!
&amp;gt; Perry&lt;/PERRY_LEETS&gt;</description>
      <pubDate>Wed, 08 Dec 2004 21:35:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200505#M28010</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-12-08T21:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Delete a block with attributes</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200506#M28011</link>
      <description>Art Cooney wrote:
&amp;gt; Yes, close still needs to be called on an erased object.  If you don't, then 
&amp;gt; at the very least, undo will have problems trying to open the object to undo 
&amp;gt; the erase.
&amp;gt; 
&amp;gt; By the way, erase() comes from AcDbObject not AcRxObject.  Only objects that 
&amp;gt; are database resident can be erased.
  Thanks Art!</description>
      <pubDate>Wed, 08 Dec 2004 21:42:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/delete-a-block-with-attributes/m-p/1200506#M28011</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-12-08T21:42:53Z</dc:date>
    </item>
  </channel>
</rss>

