<?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: AttributeReference TextString Not Updated in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4397551#M47881</link>
    <description>&lt;P&gt;&lt;FONT size="2"&gt;Thanks for the reply jabone. But unfortunately Middle Center is still left as well. I went ahead and changed the block definition and the problem still persists.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The alignment does NOT seem to be the issue, it is only an effect of the real problem.&lt;STRONG&gt; The problem is that the text is not re-applying it's preset alignment.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Sep 2013 15:52:04 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-09-04T15:52:04Z</dc:date>
    <item>
      <title>AttributeReference TextString Not Updated</title>
      <link>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4397275#M47879</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Hey all,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I'm back so soon with more problems! &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I change a block's attributes&amp;nbsp;&lt;SPAN&gt;programmatically using this helper function I created:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;private void UpdateAttributes(Database database, Detail det)
        {
            using (Transaction tr = database.TransactionManager.StartTransaction())
            {   //Grab the BlockReference the detail refers to.
                BlockReference block = (BlockReference)tr.GetObject(det.ObjectId, OpenMode.ForRead);

                //Iterate over the Attribute ids.
                foreach (ObjectId attributeId in block.AttributeCollection)
                {   //Get the current AttributeReference.
                    AttributeReference acAttribute = (AttributeReference)tr.GetObject(attributeId, OpenMode.ForWrite);
                    //Find the matching attribute.
                    foreach (DetailAttribute tmpAttr in det.Attributes)
                    {
                        if (tmpAttr.TagString.Equals(acAttribute.Tag, StringComparison.OrdinalIgnoreCase))
                        {   //The attributes match, copy the value of the detail.
                            Editor ed = AcAp::Application.DocumentManager.MdiActiveDocument.Editor;
                            acAttribute.TextString = tmpAttr.TextString;
                        }
                    }
                }
                tr.Commit(); //Faster than commiting, no changes were made.
            }
        }&lt;/PRE&gt;&lt;P&gt;&lt;FONT size="2"&gt;You can ignore the Detail and DetailAttribute objects as they are also user-defined. &amp;nbsp;Also note that this function expects the database to be currently open for working on.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Everything in this function works fine, but there is a strange quirk that becomes noticeable only when I use this function to edit an attribute that has its &lt;STRONG&gt;"Invisible"&lt;/STRONG&gt; property set to &lt;STRONG&gt;"No"&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;Below, is the original block that is edited via this function:&lt;/FONT&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;IMG align="center" src="https://forums.autodesk.com/t5/image/serverpage/image-id/59999i4A57F79C28502CEF/image-size/small?v=mpbl-1&amp;amp;px=-1" title="Original Block" alt="Original Block" border="0" /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV&gt;&lt;P&gt;As you can see, the block has a number with 4 digits (for our purposes, call this the &lt;STRONG&gt;Block Number&lt;/STRONG&gt;).&lt;/P&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;FONT size="2"&gt;Next, is the block after it is the function executes, and the attribute is changes:&lt;/FONT&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;IMG align="center" src="https://forums.autodesk.com/t5/image/serverpage/image-id/60001i1F0302C0CA982754/image-size/small?v=mpbl-1&amp;amp;px=-1" title="Edited Block" alt="Edited Block" border="0" /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;In this picture, the Block Number was changed so that it did not include the leading zero.&lt;/P&gt;&lt;P&gt;However, notice that the the Block Number attribute remained in the same exact position!&lt;/P&gt;&lt;P&gt;The position is measured from the bottom-left corner of the text, and the attribute is justified to&amp;nbsp;&lt;STRONG&gt;"Middle"&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;In addition to the attribute's text being justified to middle, the&amp;nbsp;&lt;STRONG&gt;"Lock Position"&lt;/STRONG&gt; property is set to&amp;nbsp;&lt;STRONG&gt;"No"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The text will auto-correct its position, however, if I move the block to a new location. &amp;nbsp;Or if I manually type in the Block Number (changing it to something else, then changing to "210").&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Also, this is not a&lt;STRONG&gt; REGEN&lt;/STRONG&gt; issue, as this command will not fix the location.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;So, in short, &amp;nbsp;I do not believe this is an error with the block's settings. &amp;nbsp;It appears something internal is happening or perhaps I need to do more inside my code.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Also, I did attempt to use one of AttributeReference's 2 methods:&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;AttributeReference.UpdateMTextAttribute&lt;/PRE&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;However, this resulted in an exception (my assumption is because my drawing is being modified in-memory and not in the AutoCAD editor.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;If you've got any advice, I'm up for it!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Thanks much,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;-Nicholas&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2013 14:22:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4397275#M47879</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-04T14:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeReference TextString Not Updated</title>
      <link>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4397445#M47880</link>
      <description>&lt;P&gt;You should use middle center. &amp;nbsp;Middle is still left.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2013 15:15:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4397445#M47880</guid>
      <dc:creator>jaboone</dc:creator>
      <dc:date>2013-09-04T15:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeReference TextString Not Updated</title>
      <link>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4397551#M47881</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Thanks for the reply jabone. But unfortunately Middle Center is still left as well. I went ahead and changed the block definition and the problem still persists.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The alignment does NOT seem to be the issue, it is only an effect of the real problem.&lt;STRONG&gt; The problem is that the text is not re-applying it's preset alignment.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2013 15:52:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4397551#M47881</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-04T15:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeReference TextString Not Updated</title>
      <link>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4397921#M47882</link>
      <description>&lt;P&gt;Did you remeber to use ATTSYNC to sync the attribute?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2013 18:14:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4397921#M47882</guid>
      <dc:creator>jaboone</dc:creator>
      <dc:date>2013-09-04T18:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeReference TextString Not Updated</title>
      <link>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4398333#M47883</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;ATTSYNC seems to do the trick. &amp;nbsp;Although I'm not too sure what it does.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;It appeared to me that when I use ATTSYNC on the block, &amp;nbsp;all attribute properties are restored to that in the original block definition and the TextStrings (or attribute values) are NOT removed.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I did find the documentation on this command:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;&lt;A target="_blank" href="http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-512c.htm,topicNumber=d0e199454"&gt;ATTSYNC Documentation&lt;/A&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Must my drawing be open in the AutoCAD editor to use this?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2013 20:53:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4398333#M47883</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-04T20:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeReference TextString Not Updated</title>
      <link>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4398395#M47884</link>
      <description>&lt;P&gt;Yes there are drawbacks to useing ATTSYNC but it is the ONLY way to get attributes to update after a block has been inserted in a drawing. &amp;nbsp;I guess I should have mentioned that. &amp;nbsp;I don't like it either but we do what we have to do.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2013 21:35:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4398395#M47884</guid>
      <dc:creator>jaboone</dc:creator>
      <dc:date>2013-09-04T21:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeReference TextString Not Updated</title>
      <link>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4400115#M47885</link>
      <description>&lt;P&gt;Hi, for me the best way to do this it to insert a new bloc with all attributes and delete the previous block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you change a def of Block, you need to check all block already inserted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2013 10:47:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/attributereference-textstring-not-updated/m-p/4400115#M47885</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-05T10:47:53Z</dc:date>
    </item>
  </channel>
</rss>

