<?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: Is changin attributes of blocks in an array independently possible? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/is-changin-attributes-of-blocks-in-an-array-independently/m-p/13236432#M1310</link>
    <description>&lt;P&gt;No, it is not possible because there is not more than one occurrence of the Block with the attribute reference in the array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you create an associative array, you are not creating copies of the objects that you want to array, You are creating multiple insertions of an anonymous block containing a single copy of the objects you want to array.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The situation is the same as you would have if you were to insert a block with attributes into another block, and then create multiple insertions of that other block. There is a single insertion of the block and attribute nested in the block who's insertions are copied, so you cannot change the attribute in each of those insertions/copies.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Dec 2024 15:07:35 GMT</pubDate>
    <dc:creator>ActivistInvestor</dc:creator>
    <dc:date>2024-12-31T15:07:35Z</dc:date>
    <item>
      <title>Is changin attributes of blocks in an array independently possible?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-changin-attributes-of-blocks-in-an-array-independently/m-p/13236101#M1309</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add count to an attribute in an block that is in an array. Is it possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to use the AssocArray as BlockReference and then get the BlockTableRecord to iterate over the blocks, but does not work.&amp;nbsp; the BTR has no objectIds to iterate over.&lt;/P&gt;&lt;P&gt;I know the position can be changed, so I'm wondering if this is possible as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the way I have tried.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;string blockName = "T";
string tag = "TESTATT";
using (Transaction tr = Active.Document.TransactionManager.StartUndoGroupTransaction())
{
    try
    {
        BlockTable bt = (BlockTable)tr.GetObject(Active.Database.BlockTableId, OpenMode.ForRead);
        BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
        BlockReference br = BlockOperations.InsertBlock(tr, bt, modelSpace, blockName, Point3d.Origin);
        br.SetAttributeValue(tr, tag, "Original");
        BlockTableRecord btRec = (BlockTableRecord)tr.GetObject(br.BlockTableRecord, OpenMode.ForRead);
        foreach (ObjectId id in btRec)
        {
            Active.Editor.WriteMessage(id.ToString());
        }
        AssocArrayRectangularParameters param = new AssocArrayRectangularParameters(100, 100, 0, 10, 10, 0, 0, 0);

        VertexRef verref = new VertexRef(br.Position);
        AssocArray array = AssocArray.CreateArray(new ObjectIdCollection { br.ObjectId }, verref, param);

        BlockReference arrayBlock = (BlockReference)tr.GetObject(array.EntityId, OpenMode.ForWrite);
        BlockTableRecord arrayBT = (BlockTableRecord)tr.GetObject(arrayBlock.BlockTableRecord, OpenMode.ForWrite);
        foreach (ObjectId id in arrayBT)
        {
            BlockReference item = (BlockReference)tr.GetObject(id, OpenMode.ForWrite);
            item.SetAttributeValue(tr, tag, "Array");
        }

        tr.Commit();
    }
    catch (System.Exception ex)
    {
        Active.WriteError(ex.Message);
        tr.Abort();
    }
    
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2024 10:47:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-changin-attributes-of-blocks-in-an-array-independently/m-p/13236101#M1309</guid>
      <dc:creator>shricharana_bharadwaj</dc:creator>
      <dc:date>2024-12-31T10:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is changin attributes of blocks in an array independently possible?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-changin-attributes-of-blocks-in-an-array-independently/m-p/13236432#M1310</link>
      <description>&lt;P&gt;No, it is not possible because there is not more than one occurrence of the Block with the attribute reference in the array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you create an associative array, you are not creating copies of the objects that you want to array, You are creating multiple insertions of an anonymous block containing a single copy of the objects you want to array.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The situation is the same as you would have if you were to insert a block with attributes into another block, and then create multiple insertions of that other block. There is a single insertion of the block and attribute nested in the block who's insertions are copied, so you cannot change the attribute in each of those insertions/copies.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2024 15:07:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-changin-attributes-of-blocks-in-an-array-independently/m-p/13236432#M1310</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-12-31T15:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Is changin attributes of blocks in an array independently possible?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-changin-attributes-of-blocks-in-an-array-independently/m-p/13237144#M1311</link>
      <description>&lt;P&gt;I see. I understand arrays much better now. That's why when editing the source it opens for edit similar to block refedit.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the clarification.&lt;/P&gt;&lt;P&gt;Much appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jan 2025 05:25:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-changin-attributes-of-blocks-in-an-array-independently/m-p/13237144#M1311</guid>
      <dc:creator>shricharana_bharadwaj</dc:creator>
      <dc:date>2025-01-01T05:25:25Z</dc:date>
    </item>
  </channel>
</rss>

