<?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: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc... in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321956#M18406</link>
    <description>Hi Jeff&lt;BR /&gt;
&lt;BR /&gt;
I am finding that this is taking considerable time as all the lines, rectangles, etc are being looped through... and I have a relatively simple drawing...&lt;BR /&gt;
&lt;BR /&gt;
Am I doing something wrong?</description>
    <pubDate>Thu, 14 Aug 2008 21:40:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-08-14T21:40:05Z</dc:date>
    <item>
      <title>AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321952#M18402</link>
      <description>Hi everyone&lt;BR /&gt;
&lt;BR /&gt;
I was hoping someone could shed some light for me on what exactly constitutes the various Acad objects... for instance, what is an AcadBlock vs an AcadBlockReference vs etc?&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to read the attributes off of a block I inserted using this code&lt;BR /&gt;
&lt;BR /&gt;
                'Process EACH AutoCAD Block INCLUDING ModelSpace/PaperSpace&lt;BR /&gt;
                For Each AutoCAD_Block As AcadBlock In AutoCAD_CurrentDwg_Blocks&lt;BR /&gt;
&lt;BR /&gt;
                    Try&lt;BR /&gt;
&lt;BR /&gt;
                        'Process each REFERENCED AutoCAD Block&lt;BR /&gt;
                        For Each AutoCAD_Block_Reference As AcadBlockReference In AutoCAD_Block&lt;BR /&gt;
&lt;BR /&gt;
                            Dim strAutoCAD_Block_ReferenceAttributeValue As String = ""&lt;BR /&gt;
&lt;BR /&gt;
                            'Console.WriteLine(AutoCAD_Block.Name)&lt;BR /&gt;
&lt;BR /&gt;
                            'Console.WriteLine(AutoCAD_Block_Reference.Name)&lt;BR /&gt;
&lt;BR /&gt;
                            If (AutoCAD_Block_Reference.HasAttributes) Then&lt;BR /&gt;
&lt;BR /&gt;
but a block I know has attributes isn't an AcadBlockReference... how do I handle this?&lt;BR /&gt;
&lt;BR /&gt;
Many thanks!&lt;BR /&gt;
&lt;BR /&gt;
-Justin</description>
      <pubDate>Thu, 14 Aug 2008 13:30:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321952#M18402</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-14T13:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321953#M18403</link>
      <description>Here's a little more information... I've 'inserted' a block via the 'Insert' menu pick...when I try process that block with the above code, I get an 'InvalidCastException' exception on the "For each AutoCADBlockReference..."&lt;BR /&gt;
&lt;BR /&gt;
Any thoughts on what I'm doing wrong?</description>
      <pubDate>Thu, 14 Aug 2008 14:08:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321953#M18403</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-14T14:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321954#M18404</link>
      <description>A Block is the Block definition in the Blocks Table, the definition can hold &lt;BR /&gt;
any number, and any type, of Acad Entities.&lt;BR /&gt;
A BlockReference as an Inserted Block.&lt;BR /&gt;
&lt;BR /&gt;
Stepping through a Block Definition will likely have objects other than just &lt;BR /&gt;
inserts, this is why your code fails when trying to set an object to a &lt;BR /&gt;
BlockReference type.&lt;BR /&gt;
&lt;BR /&gt;
This would be more like what you want:&lt;BR /&gt;
&lt;BR /&gt;
For Each AutoCAD_Entity As AcadEntity In AutoCAD_Block&lt;BR /&gt;
    If AutoCAD_Entity.ObjectName = "AcDbBlockReference" Then&lt;BR /&gt;
        AutoCAD_Block_Reference As AcadBlockReference = AutoCAD_Entity&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"jsurpless" wrote in message news:6006542@discussion.autodesk.com...&lt;BR /&gt;
Here's a little more information... I've 'inserted' a block via the 'Insert' &lt;BR /&gt;
menu pick...when I try process that block with the above code, I get an &lt;BR /&gt;
'InvalidCastException' exception on the "For each AutoCADBlockReference..."&lt;BR /&gt;
&lt;BR /&gt;
Any thoughts on what I'm doing wrong?</description>
      <pubDate>Thu, 14 Aug 2008 16:51:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321954#M18404</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-14T16:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321955#M18405</link>
      <description>Hi Jeff&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the information... could you elaborate on what other 'entities' might be?</description>
      <pubDate>Thu, 14 Aug 2008 18:06:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321955#M18405</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-14T18:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321956#M18406</link>
      <description>Hi Jeff&lt;BR /&gt;
&lt;BR /&gt;
I am finding that this is taking considerable time as all the lines, rectangles, etc are being looped through... and I have a relatively simple drawing...&lt;BR /&gt;
&lt;BR /&gt;
Am I doing something wrong?</description>
      <pubDate>Thu, 14 Aug 2008 21:40:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321956#M18406</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-14T21:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321957#M18407</link>
      <description>if you're working in the editor and not dbx you can use filtered selection &lt;BR /&gt;
sets&lt;BR /&gt;
hth&lt;BR /&gt;
mark&lt;BR /&gt;
&lt;BR /&gt;
&lt;JSURPLESS&gt; wrote in message news:6007067@discussion.autodesk.com...&lt;BR /&gt;
Hi Jeff&lt;BR /&gt;
&lt;BR /&gt;
I am finding that this is taking considerable time as all the lines, &lt;BR /&gt;
rectangles, etc are being looped through... and I have a relatively simple &lt;BR /&gt;
drawing...&lt;BR /&gt;
&lt;BR /&gt;
Am I doing something wrong?&lt;BR /&gt;
&lt;BR /&gt;
we're supposed to guess what you're doing?&lt;BR /&gt;
:-)&lt;/JSURPLESS&gt;</description>
      <pubDate>Thu, 14 Aug 2008 22:01:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321957#M18407</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-14T22:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321958#M18408</link>
      <description>On large drawings this method would take a while. On relatively small &lt;BR /&gt;
drawings it should still be rather quick.&lt;BR /&gt;
&lt;BR /&gt;
In addition to the code you are trying to get to work, how about a brief &lt;BR /&gt;
description of what it is you want your program to do.&lt;BR /&gt;
&lt;BR /&gt;
As Mark said, if you are working in the drawing itself (i.e. it is loaded in &lt;BR /&gt;
Acad) you can use Filtered Selection Sets to get just those object types you &lt;BR /&gt;
want...but ONLY those in Model &amp;amp; Paper space (no objects in Blocks, those &lt;BR /&gt;
you still have to step thru each item).&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"jsurpless" wrote in message news:6007067@discussion.autodesk.com...&lt;BR /&gt;
Hi Jeff&lt;BR /&gt;
&lt;BR /&gt;
I am finding that this is taking considerable time as all the lines, &lt;BR /&gt;
rectangles, etc are being looped through... and I have a relatively simple &lt;BR /&gt;
drawing...&lt;BR /&gt;
&lt;BR /&gt;
Am I doing something wrong?</description>
      <pubDate>Thu, 14 Aug 2008 22:30:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321958#M18408</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-14T22:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321959#M18409</link>
      <description>Here's a brief summary of my project's goal...&lt;BR /&gt;
&lt;BR /&gt;
I have individual drawings with blocks in Model Space that has been 'tagged' with a reference attribute that corresponds to the primary key of a database... these blocks have various additional attributes that correspond to additional fields of the database... the program is to loop through the blocks of each drawing, locate the relevant record and import the attribute information...&lt;BR /&gt;
&lt;BR /&gt;
----&lt;BR /&gt;
&lt;BR /&gt;
Yeah, might have been useful to provide code example... just so I have it straight in my mind... every line, circle, rectangle, etc on the drawing is a block, correct?&lt;BR /&gt;
&lt;BR /&gt;
                'Process EACH AutoCAD Block INCLUDING ModelSpace/PaperSpace&lt;BR /&gt;
                For Each AutoCAD_Block As AcadBlock In AutoCAD_CurrentDwg_Blocks&lt;BR /&gt;
&lt;BR /&gt;
                    Try&lt;BR /&gt;
&lt;BR /&gt;
                        For Each AutoCAD_Entity As AcadEntity In AutoCAD_Block&lt;BR /&gt;
&lt;BR /&gt;
                            'Process each REFERENCED AutoCAD Block&lt;BR /&gt;
                            'For Each AutoCAD_Block_Reference As AcadBlockReference In AutoCAD_Block&lt;BR /&gt;
                            If (TypeOf AutoCAD_Entity Is AcadBlockReference) Then&lt;BR /&gt;
&lt;BR /&gt;
-------&lt;BR /&gt;
&lt;BR /&gt;
What is DBX? Is that the ObjectARX - the method where the drawing doesn't need to actually be opened? Actually, it seems like it's a .DLL similar to the .NET protocols?&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Fri, 15 Aug 2008 00:24:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321959#M18409</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-15T00:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321960#M18410</link>
      <description>Hi jsurpless,&lt;BR /&gt;
&lt;BR /&gt;
You are making it far too complex for yourself by confusing blocks with &lt;BR /&gt;
blockreferences.&lt;BR /&gt;
&lt;BR /&gt;
This is understandable because the programming terminology is different &lt;BR /&gt;
from the every day AutoCAD terminology.&lt;BR /&gt;
&lt;BR /&gt;
The blocks (with the exception of a few items like Modelspace and Layout &lt;BR /&gt;
spaces which are technically blocks) are an invisible part of the &lt;BR /&gt;
drawing database which can be called on to create a visible &lt;BR /&gt;
blockreference in the drawing.  The block contains a description of the &lt;BR /&gt;
objects and any attributes to be drawn when the block is inserted to &lt;BR /&gt;
create a blockreference&lt;BR /&gt;
&lt;BR /&gt;
The only thing you need deal with are the blockreferences.&lt;BR /&gt;
&lt;BR /&gt;
It is the blockreference which appears in the drawing and which holds &lt;BR /&gt;
values for any attribute data.&lt;BR /&gt;
&lt;BR /&gt;
So the code steps you need are:&lt;BR /&gt;
&lt;BR /&gt;
make a collection of all the block references in the drawing - if the &lt;BR /&gt;
ones you are interested in have known names, then filter the collection &lt;BR /&gt;
by name as well as by blockreference when creating the collection&lt;BR /&gt;
&lt;BR /&gt;
loop through your collection and for each block reference get its &lt;BR /&gt;
attributes.&lt;BR /&gt;
Use the value of the attribute with the database Key to query your &lt;BR /&gt;
database for the relevant data&lt;BR /&gt;
Assign the data to the attributes in the blockreference&lt;BR /&gt;
loop to the next blockreference.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
If you were coding in VBA (note you are in the VBA NG and displaying &lt;BR /&gt;
code from .NET) you would find all the code you need in the code samples &lt;BR /&gt;
supplied with AutoCAD.  For .NET, I haven't looked, but no doubt there &lt;BR /&gt;
are plenty of users around who could point you to sample code if you &lt;BR /&gt;
cannot find it yourself.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Laurie Comerford&lt;BR /&gt;
&lt;BR /&gt;
jsurpless wrote:&lt;BR /&gt;
&amp;gt; Here's a brief summary of my project's goal...&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I have individual drawings with blocks in Model Space that has been 'tagged' with a reference attribute that corresponds to the primary key of a database... these blocks have various additional attributes that correspond to additional fields of the database... the program is to loop through the blocks of each drawing, locate the relevant record and import the attribute information...&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; ----&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Yeah, might have been useful to provide code example... just so I have it straight in my mind... every line, circle, rectangle, etc on the drawing is a block, correct?&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;                 'Process EACH AutoCAD Block INCLUDING ModelSpace/PaperSpace&lt;BR /&gt;
&amp;gt;                 For Each AutoCAD_Block As AcadBlock In AutoCAD_CurrentDwg_Blocks&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;                     Try&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;                         For Each AutoCAD_Entity As AcadEntity In AutoCAD_Block&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;                             'Process each REFERENCED AutoCAD Block&lt;BR /&gt;
&amp;gt;                             'For Each AutoCAD_Block_Reference As AcadBlockReference In AutoCAD_Block&lt;BR /&gt;
&amp;gt;                             If (TypeOf AutoCAD_Entity Is AcadBlockReference) Then&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; -------&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; What is DBX? Is that the ObjectARX - the method where the drawing doesn't need to actually be opened? Actually, it seems like it's a .DLL similar to the .NET protocols?&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Thanks!</description>
      <pubDate>Fri, 15 Aug 2008 03:31:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321960#M18410</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-15T03:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321961#M18411</link>
      <description>&lt;JSURPLESS&gt; wrote &lt;BR /&gt;
&lt;BR /&gt;
&amp;gt;&amp;gt; could you elaborate on what other 'entities' might be?&lt;BR /&gt;
&lt;BR /&gt;
Everything you need to know about the object model and all the entities it provides objects for, is right there in the VBA/ActiveX developers guide that comes with AutoCAD.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2009&lt;BR /&gt;
Supporting AutoCAD 2000 through 2009&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Introducing AcadXTabs 2010:&lt;BR /&gt;
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm&lt;/JSURPLESS&gt;</description>
      <pubDate>Fri, 15 Aug 2008 03:56:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321961#M18411</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-15T03:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321962#M18412</link>
      <description>Hi Laurie&lt;BR /&gt;
&lt;BR /&gt;
I ended up making use of SelectionSets like this&lt;BR /&gt;
&lt;BR /&gt;
                Dim AutoCAD_CurrentDwg_SelectionSet As AcadSelectionSet = AutoCAD_CurrentDwg.SelectionSets.Add("Blocks_To_Modify")&lt;BR /&gt;
&lt;BR /&gt;
                Dim FilterType() As Int16 = {0}&lt;BR /&gt;
                Dim FilterData() As Object = {"Insert"}&lt;BR /&gt;
&lt;BR /&gt;
                AutoCAD_CurrentDwg_SelectionSet.Select(AcSelect.acSelectionSetAll, , , FilterType, FilterData)&lt;BR /&gt;
&lt;BR /&gt;
                For Each AutoCAD_Entity As AcadEntity In AutoCAD_CurrentDwg_SelectionSet&lt;BR /&gt;
&lt;BR /&gt;
                    Try&lt;BR /&gt;
&lt;BR /&gt;
                                           If (TypeOf AutoCAD_Entity Is AcadBlockReference) Then&lt;BR /&gt;
&lt;BR /&gt;
Seems to work a lot better...&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Fri, 15 Aug 2008 11:05:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321962#M18412</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-15T11:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: AutoCAD Newbie - AcadBlockReference vs AcadBlock vs etc...</title>
      <link>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321963#M18413</link>
      <description>Hi Tony&lt;BR /&gt;
&lt;BR /&gt;
I ended up finding this resource yesterday and as you said, it's most useful... I had just been looking in the wrong place (VS side, as I am used to)&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Fri, 15 Aug 2008 11:07:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/autocad-newbie-acadblockreference-vs-acadblock-vs-etc/m-p/2321963#M18413</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-08-15T11:07:04Z</dc:date>
    </item>
  </channel>
</rss>

