<?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: Need to read the attributes in a selected block. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8840652#M22233</link>
    <description>&lt;P&gt;Is that a Dispose() being called inside a Using { } for the transaction?&lt;/P&gt;</description>
    <pubDate>Sat, 08 Jun 2019 21:27:40 GMT</pubDate>
    <dc:creator>dgorsman</dc:creator>
    <dc:date>2019-06-08T21:27:40Z</dc:date>
    <item>
      <title>Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8838898#M22227</link>
      <description>&lt;DIV class="postarea"&gt;&lt;DIV class="post"&gt;&lt;DIV class="inner"&gt;I need to be able to select a single block and read it's attributes.&amp;nbsp; I am using a structure to then pass those attribute values to other functions.&amp;nbsp; So far I have not been successful in reading the attributes and returning a string value.&amp;nbsp; Below is my code.&amp;nbsp; Any help is appreciated.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (Transaction rbTrans = db.TransactionManager.StartTransaction())&lt;BR /&gt;&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; &amp;nbsp; BlockReference bref = (BlockReference)rbTrans.GetObject(bed, OpenMode.ForRead);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BlockTableRecord bdef = (BlockTableRecord)rbTrans.GetObject(bref.BlockTableRecord, OpenMode.ForRead);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (bdef.HasAttributeDefinitions != true) return null;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach (ObjectId id in bdef)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; DBObject obj = (DBObject)rbTrans.GetObject(id, OpenMode.ForRead, true);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AttributeDefinition attdef = obj as AttributeDefinition;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ((attdef != null) &amp;amp;&amp;amp; (!attdef.Constant))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (attdef.Tag == "pos_Origin_Z")&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; {&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; structure.insPtZ = attdef.TextString;&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; }&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; else if ((attdef.Tag == "pos_Endpoint_Z"))&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; {&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; structure.endPtZ = attdef.TextString;&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; }&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; else if ((attdef.Tag == "prd_UL"))&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; {&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; structure.uLabel = attdef.TextString;&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; }&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; else if ((attdef.Tag == "prd_LP"))&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; {&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; structure.layPos = attdef.TextString;&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; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; structure.insPt = bref.Position;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; structure.blkName = ((BlockTableRecord)bref.DynamicBlockTableRecord.GetObject(OpenMode.ForRead)).Name;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; structure.lyrName = bref.Layer;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; structure.rotAngle = bref.Rotation;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rbTrans.Dispose();&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return structure;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="moderatorbar"&gt;&lt;DIV class="smalltext modified"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 07 Jun 2019 14:02:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8838898#M22227</guid>
      <dc:creator>sonny3g</dc:creator>
      <dc:date>2019-06-07T14:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8839025#M22228</link>
      <description>&lt;P&gt;When you say "read the attributes in a selected block", do you mean AttributeDefinition in a block definition (BlockTableRecord), or do you mean AttributeReferences in BlockReference? Your code gets all AttributeDefinitions and the default Attribute value, yet you collect block position/layer/rotation from a block reference and store the data from different object (block definition and block reference) in a struc for later use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect what you really meant is attributes (AttributeReference) in a block reference. While a BlockReference is a reference to a block definition, the attributes in BlockReference is not a reference to AttributeDefinition. AttributeDefinition is like object template, which is used to create AttributeReference in BlockReference. With code, one can decide if an attributereference is needed in a BlockReference. If yes, the attributeReference can either be created based on available AttributeDefinition, or be created without using AttributeDefinition as template at all. So, If your need get attribute values of a BlockReference, you DO NOT need to trace back to the block definition. Simply loop through BlockReference.AttributeCollection property:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;private MyStructure GetDataFromBlockReference(ObjectId blockReferenceId)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; var structure = new MyStructure();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; using (var tran=blockReferenceId.Database.TransactionManager.StartTransaction())&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var blk=(BlockReference)tran.GetObject(blockReferneceId, OpenMode.ForRead)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; structure.insPt=blk.Position&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //if the block is a dynamic block, you may need to trace back to the dynamic block definition for its name&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; structure.blkName=blk.Name;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; structure.Rotation=....&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach (ObjectId id in blk.AttributeCollection)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var att=(AttributeReference)tran.GetObject(id,OpenMode.ForRead)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;switch (att.Tag.TpUpper)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;case "POS__ORIGIN_Z":&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; structure.insPtz =COnvert.ToDouble(att.TextString);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;case .....&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tran.Commit();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; return structure&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 14:57:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8839025#M22228</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2019-06-07T14:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8839172#M22229</link>
      <description>&lt;P&gt;Thanks Atook and Giles. As usual, you both are very helpful! Between the two of you and Norman Yuan, I was able to get this portion to work now. This is what I have and it is much more concise than my first try. Structure is a separate function that will be used by other functions later.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public BlkStrct ReadBlock(ObjectId bed)&lt;BR /&gt;{&lt;BR /&gt;using (Transaction rbTrans = db.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;BlockReference bref = (BlockReference)rbTrans.GetObject(bed, OpenMode.ForRead);&lt;BR /&gt;BlockTableRecord bdef = (BlockTableRecord)rbTrans.GetObject(bref.DynamicBlockTableRecord, OpenMode.ForRead);&lt;BR /&gt;if (bdef.HasAttributeDefinitions != true) return null;&lt;BR /&gt;foreach (ObjectId id in bref.AttributeCollection)&lt;BR /&gt;{&lt;BR /&gt;AttributeReference attdef = (AttributeReference)rbTrans.GetObject(id, OpenMode.ForRead);&lt;BR /&gt;switch (attdef.Tag)&lt;BR /&gt;{&lt;BR /&gt;case "pos_Origin_Z":&lt;BR /&gt;structure.insPtZ = attdef.TextString;&lt;BR /&gt;break;&lt;BR /&gt;case "pos_Endpoint_Z":&lt;BR /&gt;structure.endPtZ = attdef.TextString;&lt;BR /&gt;break;&lt;BR /&gt;case "prd_UL":&lt;BR /&gt;structure.uLabel = attdef.TextString;&lt;BR /&gt;break;&lt;BR /&gt;case "prd_LP":&lt;BR /&gt;structure.layPos = attdef.TextString;&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;structure.insPt = bref.Position;&lt;BR /&gt;structure.blkName = ((BlockTableRecord)bref.DynamicBlockTableRecord.GetObject(OpenMode.ForRead)).Name;&lt;BR /&gt;structure.lyrName = bref.Layer;&lt;BR /&gt;structure.rotAngle = bref.Rotation;&lt;BR /&gt;&lt;BR /&gt;rbTrans.Dispose();&lt;/P&gt;&lt;P&gt;return structure;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sonny&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 15:55:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8839172#M22229</guid>
      <dc:creator>sonny3g</dc:creator>
      <dc:date>2019-06-07T15:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8839217#M22230</link>
      <description>&lt;P&gt;Well, this code should be OK in NORMAL/MOST situation, but I'd not test BlockTableRecord.HasAttributDefinitions and return if it is False.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I stated, BlockReference's AttributeReference may or may not have coresponding/matching AttributeDefinition in the block definition (that is, attribute in BlockReference IS NOT A REFERENCE of AttributeDefinition, in spite of its name being "AttributeReference"). Regardless a block definition having AttributeDefinitions or not, a BlockReference can have 0 or multiple AttributeReferences. In rare case, the block reference in interest may or may not have the same attributes as the block definition defines. So, for your code, you do not need to test BlockTableRecord.HasAttributeDefinitions; and in rare case, it may lead to wrong result (if the block definition does not have attribute defined, but somehow the block reference in interest does have attributes (created programmatically). So, in your code, simply loop through BlockReference.AttributeCollection is enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 16:07:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8839217#M22230</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2019-06-07T16:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8839529#M22231</link>
      <description>&lt;P&gt;I think I see what you are getting at. &amp;nbsp;This function is part of a tool that is designed to work on specific blocks that our company has designed and not to work on any others, so, the block must have attributes or the program will kick you out. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will probably wind up developing a filter that prevents selecting non-company entities and that would eliminate the attribute test altogether.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you Norman.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 18:45:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8839529#M22231</guid>
      <dc:creator>sonny3g</dc:creator>
      <dc:date>2019-06-07T18:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8839661#M22232</link>
      <description>&lt;P&gt;Well, by saying "&lt;SPAN&gt;so, the block must have attributes or the program will kick you out...." I think you still missed the point of what I have said: BlockTableRecord.HasAttributeDefinitions &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;DOES NOT GARANTEE&lt;/STRONG&gt;&lt;/FONT&gt; of telling you whether a BlockReference contains AttributeReferences or not. So, the code to test it is &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;COMPLETELY NOT NECESSARY&lt;/STRONG&gt;&lt;/FONT&gt;, not to mention the rare chance of leading to wrong result (even the chance is one of ten million, it is a chance!). &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Even if it is harmless because of the way your specific block reference to be added into drawing (that is, if the block definition has attribute defined, then the block reference ALWAYS has the corresponding attribute references), that line of code is still is not necessary. Just as if you add something like&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If (1 != 1) return&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;into in your code here and there a few times: it may be harmless, by why you need it?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 19:53:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8839661#M22232</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2019-06-07T19:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8840652#M22233</link>
      <description>&lt;P&gt;Is that a Dispose() being called inside a Using { } for the transaction?&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2019 21:27:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8840652#M22233</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2019-06-08T21:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8840686#M22234</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/253793"&gt;@dgorsman&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&lt;FONT color="#999999"&gt;Is that a Dispose() being called inside a Using { } for the transaction?&lt;/FONT&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good eye David.&lt;/P&gt;&lt;P&gt;Yes, it's superfluous because of the using statement block enclosing it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I casually wondered about the reasoning for the name of the Transaction variable ; rbTrans&lt;/P&gt;&lt;P&gt;... but that's probably just me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2019 22:31:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8840686#M22234</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2019-06-08T22:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8844978#M22235</link>
      <description>&lt;P&gt;I am not sure how to determine if my block actually has attributes then.&amp;nbsp; What is the best way to do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 15:46:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8844978#M22235</guid>
      <dc:creator>sonny3g</dc:creator>
      <dc:date>2019-06-11T15:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8844982#M22236</link>
      <description>&lt;P&gt;Yes it is.&amp;nbsp; When I had the dispose outside of the }, I did not get the expected results for this transaction.&amp;nbsp; Not sure why.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 15:47:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8844982#M22236</guid>
      <dc:creator>sonny3g</dc:creator>
      <dc:date>2019-06-11T15:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8844989#M22237</link>
      <description>&lt;P&gt;rbTrans is how I know what my transaction is for.&amp;nbsp; In this case, Read Block transaction.&amp;nbsp; Other functions will have transactions named like dlTrans for dimension leader transaction.&amp;nbsp; Just how I try to keep track of where I am at and what I am trying to accomplish within a transaction.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 15:49:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8844989#M22237</guid>
      <dc:creator>sonny3g</dc:creator>
      <dc:date>2019-06-11T15:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8845753#M22238</link>
      <description>&lt;P&gt;BlockRefernce.AttributeCollection tells you if there is AttributeReference in the Block reference. Since your code does LOOPING through AttributeCollection, why do you need to worry whether the block (the BlockRefernce!) has attribute or not?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AGAIN, BlockTableRecord.HasAttributeDefinitions DOES NOT GUARANTEE a block reference has exactly the same attributes as the block definition defines, even in most/usual scenarios it is the case. In your code, you pass a BlcokRefernce's ID to the subroutine for operation (reading Attribute values), which means you have already selected/identified the block reference (by use picking, or by block name...), it is COMPLETELY no need to test BlockTableRecord.HasAttributeDefinitions. In best case, if is harmless, but meaningless.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 21:12:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8845753#M22238</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2019-06-11T21:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need to read the attributes in a selected block.</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8846845#M22239</link>
      <description>&lt;P&gt;I thought it would be better and quicker for my program to validate that the attributes existed before sending the blockreference to the subroutine to read the attributes.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I understand what you are telling me though, my requirement is met by the subroutine reading the attributes.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 11:34:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-to-read-the-attributes-in-a-selected-block/m-p/8846845#M22239</guid>
      <dc:creator>sonny3g</dc:creator>
      <dc:date>2019-06-12T11:34:48Z</dc:date>
    </item>
  </channel>
</rss>

