<?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: c# and DWG Attributes in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452878#M55634</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, sorry. I mistake copy pasting the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if (String.Compare(myBlkName.ToLower(), "BOTTOMBLK_2") == 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The thing is, with my code (without the typos), and as I explaines in the first post, I'm able to scan and reach the block BOTTOMBLK_2.&amp;nbsp;When scanning the atributes inside this block, I can see the tag name, the prompt string, but no the value string of this attribute. These 3 attributes I can see them in the autocad app (the real autocad I mean).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to reach to these attributes, and I need the value. Maybe eventually I will need to edit some value. That's what I was trying to do. Do I need the blockreference then?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 10 May 2012 19:58:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-05-10T19:58:03Z</dc:date>
    <item>
      <title>c# and DWG Attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452718#M55631</link>
      <description>&lt;P&gt;Hello Guys!&lt;/P&gt;&lt;P&gt;I'm new to autocad and visual studio. I'm trying to build a simple aplication that uses com interop with autocad. It creates an acad aplication. uses it to open a file, get the blocks and finally its attributes.&lt;/P&gt;&lt;P&gt;My problem is that on the attributes, i'm not able to get the value of the attribute. When i try att.textvalue I get and empty string.&amp;nbsp; Can anyone help me on this one?&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;P&gt;Here is my very simple code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Autodesk.AutoCAD.Interop.AcadDocument doc = _acad.Documents.Open(dwgpath, true, string.Empty);&lt;BR /&gt;Autodesk.AutoCAD.Interop.Common.AcadDatabase myDB = doc.Database;&lt;BR /&gt;Autodesk.AutoCAD.Interop.Common.AcadBlocks blocks = myDB.Blocks;&lt;BR /&gt;&lt;BR /&gt;Autodesk.AutoCAD.Interop.Common.AcadBlock selblk = null;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;foreach (Autodesk.AutoCAD.Interop.Common.AcadBlock myblock in blocks)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String myBlkName = myblock.Name.ToString();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (String.Compare(myBlkName.ToLower(), "BOTTOMBLK_2") == 0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selblk = myblock;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;if (selblk == null)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;foreach (Autodesk.AutoCAD.Interop.Common.AcadEntity ent in selblk)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Autodesk.AutoCAD.Interop.Common.AcadAttribute att = ent as Autodesk.AutoCAD.Interop.Common.AcadAttribute;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (att != null)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("EntityName = " + att.TextString);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("EntityName = " + att.TagString);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("EntityName = " + att.TagString +&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "\n Entity Prompt String = " + att.PromptString +&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "\n Entity Text String = " + att.TextString.ToCharArray() +&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "\n Entity Text String = " + att.TextString);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 18:48:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452718#M55631</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-10T18:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: c# and DWG Attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452826#M55632</link>
      <description>&lt;P&gt;Just a hint,&lt;/P&gt;&lt;P&gt;Compare with your code:&lt;/P&gt;&lt;PRE&gt;      foreach (Autodesk.AutoCAD.Interop.Common.AcadBlock myblock in blocks)
            {
                String myBlkName = myblock.Name.ToString();

                if (String.Compare(myBlkName.ToUpper(), "BOTTOMBLK_2") == 0)
                {
                    selblk = myblock;
                }

            }

            if (selblk == null)
            {
                return;
            }

            foreach (Autodesk.AutoCAD.Interop.Common.AcadEntity ent in selblk)
            {
                Autodesk.AutoCAD.Interop.Common.AcadAttribute att = ent as Autodesk.AutoCAD.Interop.Common.AcadAttribute;

                if (att != null)
                {
                    Autodesk.AutoCAD.Interop.AcadUtility util = doc.Utility;
                    util.Prompt("\n" + att.TextString + "\t" + att.TagString);

                }
            }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You write ToLower() might be ToUpper()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 19:31:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452826#M55632</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-05-10T19:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: c# and DWG Attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452830#M55633</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First check that codeline:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;if (String.Compare(myBlkName.&lt;FONT color="#FF6600"&gt;ToLower&lt;/FONT&gt;(), "&lt;FONT color="#FF6600"&gt;BOTTOMBLK_2&lt;/FONT&gt;") == 0)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Using .ToLower and compare it with uppercase characters does not make that sense (even if the comparision is set to see uppercase equal to lowercase) &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next I'm not sure you see the difference between BLOCK and BLOCKREFERENCE?&lt;/P&gt;&lt;P&gt;If you really want to have the block-definitions (&lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;Interop.Common.AcadBlock&lt;/FONT&gt;) then your code does mistyping when scaning through the elements of the block-definition:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;ent as Autodesk.AutoCAD.Interop.Common.AcadAttribute;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Within your block-definition there may be objects like AcadLine, AcadCircle, ..... and also AcadAttribute.&lt;/P&gt;&lt;P&gt;You try to cast every object of type AcadEntity to AcadAttribtue and that does not work and at least it needs to be handled by some error-handler (better is to check the type of &lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;ent&lt;/FONT&gt; before casting it).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you thought more about AcadBlockReference (the inserted Blocks in ModelSpace or PaperSpace) then let us know that, because then you are on the wrong way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 19:34:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452830#M55633</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-05-10T19:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: c# and DWG Attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452878#M55634</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, sorry. I mistake copy pasting the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if (String.Compare(myBlkName.ToLower(), "BOTTOMBLK_2") == 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The thing is, with my code (without the typos), and as I explaines in the first post, I'm able to scan and reach the block BOTTOMBLK_2.&amp;nbsp;When scanning the atributes inside this block, I can see the tag name, the prompt string, but no the value string of this attribute. These 3 attributes I can see them in the autocad app (the real autocad I mean).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to reach to these attributes, and I need the value. Maybe eventually I will need to edit some value. That's what I was trying to do. Do I need the blockreference then?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 19:58:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452878#M55634</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-10T19:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: c# and DWG Attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452888#M55635</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; I can see the tag name, the prompt string, but no the value string of this attribute&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Are you sure that you have a predefined value in the definition of the attribute (within the block-definition)? Otherwise you won't see a value. Verify that by starting the blockeditor with that blockdefinition and double-click the attribute-definition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 20:02:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452888#M55635</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-05-10T20:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: c# and DWG Attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452942#M55636</link>
      <description>&lt;P&gt;I will check this out,&lt;/P&gt;&lt;P&gt;meanwhile, you talk about of doing it using blockreference. How should I do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 20:29:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452942#M55636</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-10T20:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: c# and DWG Attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452962#M55637</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; meanwhile, you talk about of doing it using blockreference. How should I do it?&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I'm not sure about what you want to do, and as long as this is not clear I don't want to spend time in "&lt;EM&gt;&lt;FONT color="#666699"&gt;I will check this out, meanwhile ....&lt;/FONT&gt;&lt;/EM&gt;". &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you are sure if you want to have the value of an attribute within a block-defintion or you want to have the value of an attribute within a block-insertion in modelspace or paperspace. In second case you would also have to be prepared that there may be more than one insertion and so more than just one attribute-value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 20:35:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3452962#M55637</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-05-10T20:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: c# and DWG Attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3453020#M55638</link>
      <description>&lt;P&gt;which are the difference between&amp;nbsp;&lt;SPAN&gt;attribute within a block-defintion and an attribute within a block-insertion in modelspace or paperspace?&amp;nbsp;&lt;/SPAN&gt;I though the block I created &amp;amp; filled in the autocad application, was the one I found in the code above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your replies and time.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 21:03:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3453020#M55638</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-10T21:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: c# and DWG Attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3453100#M55639</link>
      <description>&lt;P&gt;When you loop through the BlockTable looking at objects of type AcadBlock, those are Block definitions, there is only on of each name, and they may contain geometric objects, and/or AcadAttributes (Attribute Definitions).&amp;nbsp; When a Block is Inserted into the model or paper space, this definition is what AutoCAD looks at to tell it what is supposed to be drawn for that block, and what AcadAttributeReferences should be added to the AcadBlockReference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The smallest change that needs to made to your code, is that you don't want to loop through the BlockTable, you want to loop through the ModelSpace or PaperSpace.&amp;nbsp; And you shouldn't be looking for objects of AcadBlock you should be looking for AcadBlockReference, and inside the BlockReference, loop looking for AcadAttributeReference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Better still would be to drop the loop of the ModelSpace, and use a selection filter to obtain the BlockReferences you are looking for directly.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 21:48:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3453100#M55639</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2012-05-10T21:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: c# and DWG Attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3454126#M55640</link>
      <description>&lt;P&gt;Thanks to both of you for your time and patience &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will look at the selection filter to see better how can I do it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks again&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2012 15:18:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/c-and-dwg-attributes/m-p/3454126#M55640</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-11T15:18:01Z</dc:date>
    </item>
  </channel>
</rss>

