<?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: entity position deviates from the specified position while copy BlockReference by blockId in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12987794#M2812</link>
    <description>&lt;P&gt;Well, using Editor.Command()/using command "COPY" does not change the fact that excessive use of dynamic blocks would result in high memory consumption. If you insert the block references with its default dynamic properties with code, there would be no extra memory consumption. The increased memory is resulted in when the block reference's dynamic properties are changed (each change would lead AutoCAD to create a new BlockTableRecord and its block reference). If you have a very complicated block definition (say many entities in it and these entities could be manipulated with dozens of dynamic properties), the BlockTableRecord could be quite big in size of memory. So, each instance of the block reference with a unique dynamic property value would lead AutoCAD to create new pair of an anonymous BlockTableRecord (with similar big amount of memory required) and a block reference. You can see, if you create 100 block references of this block with each of them has unique dynamic property value, you would end up with 100 big sized anonymous BlockTablerecords plus 100 instances of BlockReferences (paired to each anonymous block definition). Therefore, using big-sized/complicated dynamic blocks excessively would cause heavy overhead for AutoCAD process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Aug 2024 22:52:30 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2024-08-28T22:52:30Z</dc:date>
    <item>
      <title>entity position deviates from the specified position while copy BlockReference by blockId</title>
      <link>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12981245#M2805</link>
      <description>&lt;LI-CODE lang="general"&gt;        static void CopyBlocks()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            var dynBlockNames = new List&amp;lt;string&amp;gt; { "block1", "block2", "block3" };

            for (int i = 0; i &amp;lt; dynBlockNames.Count; i++)
            {
                var basePoint = new Point3d(i, i, i);
                ObjectId blockId;
                BlockReference newBr;
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
                    newBr = new BlockReference(basePoint, bt["blockName"]);

                    BlockTableRecord modelSpace = trans.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite) as BlockTableRecord;
                    modelSpace.AppendEntity(newBr);
                    blockId = newBr.ObjectId;
                    trans.Commit();
                }

                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    for (int j = 100; j &amp;lt; 1000; i++)
                    {
                        var tp = new Point3d(j, j, j);
                        ed.Command("_.COPY", blockId, "", basePoint, tp);
                    }

                    trans.Commit();
                }
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;something was wrong with&amp;nbsp;the specified position "tp"&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2024 11:05:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12981245#M2805</guid>
      <dc:creator>lixiaohai1222</dc:creator>
      <dc:date>2024-08-26T11:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: entity position deviates from the specified position while copy BlockReference by blockId</title>
      <link>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12982136#M2806</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;something was wrong with the specified position "tp"&lt;/BLOCKQUOTE&gt;&lt;P&gt;What was wrong with the specified position?&amp;nbsp; You need to be more specific. What was the result verses what was expected result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running Object Snap perhaps ?&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;</description>
      <pubDate>Mon, 26 Aug 2024 17:31:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12982136#M2806</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-08-26T17:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: entity position deviates from the specified position while copy BlockReference by blockId</title>
      <link>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12983180#M2807</link>
      <description>&lt;P&gt;1&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 07:27:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12983180#M2807</guid>
      <dc:creator>lixiaohai1222</dc:creator>
      <dc:date>2024-08-27T07:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: entity position deviates from the specified position while copy BlockReference by blockId</title>
      <link>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12983185#M2808</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lixiaohai1222_0-1724743438469.jpeg" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1402286iA400374701CCAA59/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lixiaohai1222_0-1724743438469.jpeg" alt="lixiaohai1222_0-1724743438469.jpeg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lixiaohai1222_1-1724743447488.jpeg" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1402287iFD439A78B9E53120/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lixiaohai1222_1-1724743447488.jpeg" alt="lixiaohai1222_1-1724743447488.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN class=""&gt;all the blocks specified by red arrow are also copied to wrong point&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 07:24:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12983185#M2808</guid>
      <dc:creator>lixiaohai1222</dc:creator>
      <dc:date>2024-08-27T07:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: entity position deviates from the specified position while copy BlockReference by blockId</title>
      <link>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12983277#M2809</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;There's something weird with this line:&lt;/P&gt;
&lt;PRE class="lia-code-sample line-numbers language-general" tabindex="0"&gt;&lt;CODE&gt;for (int j = 100; j &amp;lt; 1000; i++)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You're incrementing 'i' and 'j' is never incremented.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 08:15:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12983277#M2809</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-08-27T08:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: entity position deviates from the specified position while copy BlockReference by blockId</title>
      <link>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12983349#M2810</link>
      <description>&lt;P&gt;Also, as &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4476837"&gt;@ActivistInvestor&lt;/a&gt; said, maybe something due to some running object snap. If you absolutely want to use Editor.Command, you should temporarily disable object snaps:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;ed.Command("_.COPY", blockId, "", "_none", basePoint, tp);&lt;/LI-CODE&gt;
&lt;P&gt;But, instead of calling the COPY command, you could simply insert the new block references as you do for the "base" ones.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 09:03:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12983349#M2810</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-08-27T09:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: entity position deviates from the specified position while copy BlockReference by blockId</title>
      <link>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12985284#M2811</link>
      <description>&lt;P&gt;thanks, but dynamic properties will be lost while simply insert the new block references. In addition, when using DotNetARX.BlockTools.SetDynBlockValue to modify the attribute value of the new block references, AutoCAD will leak memory.&lt;BR /&gt;issue: &lt;A href="https://forums.autodesk.com/t5/net/net-plugin-causes-high-memory-consumption-leak-not-in-managed/td-p/5633915" target="_blank"&gt;https://forums.autodesk.com/t5/net/net-plugin-causes-high-memory-consumption-leak-not-in-managed/td-p/5633915&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 01:34:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12985284#M2811</guid>
      <dc:creator>lixiaohai1222</dc:creator>
      <dc:date>2024-08-28T01:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: entity position deviates from the specified position while copy BlockReference by blockId</title>
      <link>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12987794#M2812</link>
      <description>&lt;P&gt;Well, using Editor.Command()/using command "COPY" does not change the fact that excessive use of dynamic blocks would result in high memory consumption. If you insert the block references with its default dynamic properties with code, there would be no extra memory consumption. The increased memory is resulted in when the block reference's dynamic properties are changed (each change would lead AutoCAD to create a new BlockTableRecord and its block reference). If you have a very complicated block definition (say many entities in it and these entities could be manipulated with dozens of dynamic properties), the BlockTableRecord could be quite big in size of memory. So, each instance of the block reference with a unique dynamic property value would lead AutoCAD to create new pair of an anonymous BlockTableRecord (with similar big amount of memory required) and a block reference. You can see, if you create 100 block references of this block with each of them has unique dynamic property value, you would end up with 100 big sized anonymous BlockTablerecords plus 100 instances of BlockReferences (paired to each anonymous block definition). Therefore, using big-sized/complicated dynamic blocks excessively would cause heavy overhead for AutoCAD process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 22:52:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/entity-position-deviates-from-the-specified-position-while-copy/m-p/12987794#M2812</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-08-28T22:52:30Z</dc:date>
    </item>
  </channel>
</rss>

