<?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 How to Change Block Base Point in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-change-block-base-point/m-p/12649941#M4959</link>
    <description>&lt;P&gt;Hi everybody !&lt;BR /&gt;I have a problem as follows:&lt;BR /&gt;- First, when the user types the command, the user will be asked to select all the objects the user wants to create into BlockReference&lt;BR /&gt;- Then we will pick 1 point as the set point for that BlockReference&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;+ I have created a Blockreference, but when the point is set, the objects inside that Block are not placed at that Point location, specifically as shown below.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="aaaa.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1338789i0527830B1C6FB068/image-size/large?v=v2&amp;amp;px=999" role="button" title="aaaa.png" alt="aaaa.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated and thank you very much&lt;/P&gt;</description>
    <pubDate>Tue, 19 Mar 2024 06:37:13 GMT</pubDate>
    <dc:creator>dungthachbomay</dc:creator>
    <dc:date>2024-03-19T06:37:13Z</dc:date>
    <item>
      <title>How to Change Block Base Point</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-change-block-base-point/m-p/12649941#M4959</link>
      <description>&lt;P&gt;Hi everybody !&lt;BR /&gt;I have a problem as follows:&lt;BR /&gt;- First, when the user types the command, the user will be asked to select all the objects the user wants to create into BlockReference&lt;BR /&gt;- Then we will pick 1 point as the set point for that BlockReference&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;+ I have created a Blockreference, but when the point is set, the objects inside that Block are not placed at that Point location, specifically as shown below.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="aaaa.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1338789i0527830B1C6FB068/image-size/large?v=v2&amp;amp;px=999" role="button" title="aaaa.png" alt="aaaa.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated and thank you very much&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 06:37:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-change-block-base-point/m-p/12649941#M4959</guid>
      <dc:creator>dungthachbomay</dc:creator>
      <dc:date>2024-03-19T06:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Block Base Point</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-change-block-base-point/m-p/12649961#M4960</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the block definition (BlockTableRecord), you have to displace all entities.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;var xform Matrix3d.Displacement(pickedPoint.GetAsVector().Negate());
foreach (ObjectId id in btr)
{
    var entity = (Entity)tr.GetObject(id, OpenMode.ForWrite);
    entity.TransformBy(xform);
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 19 Mar 2024 06:49:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-change-block-base-point/m-p/12649961#M4960</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-03-19T06:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Block Base Point</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-change-block-base-point/m-p/12650025#M4961</link>
      <description>&lt;P&gt;Here's a command example which mimics the -BLOCK command.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;    // Mimics the native -BLOCK command
    [CommandMethod("CREATEBLOCK")]
    public void CreateBlock()
    {
        var doc = Application.DocumentManager.MdiActiveDocument;
        var db = doc.Database;
        var ed = doc.Editor;

        using (var tr = db.TransactionManager.StartTransaction())
        {
            var blockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);

            string blockName;
            while (true)
            {
                var promptResult = ed.GetString("\nEnter block name: ");
                if (promptResult.Status != PromptStatus.OK) return;
                blockName = promptResult.StringResult;
                if (string.IsNullOrWhiteSpace(blockName)) return;
                if (!blockTable.Has(blockName)) break;
                ed.WriteMessage($"Block \"{blockName}\" already exists");
            }

            var promptPointResult = ed.GetPoint("\nSpecify the base point: ");
            if (promptPointResult.Status != PromptStatus.OK) return;

            var selection = ed.GetSelection();
            if (selection.Status != PromptStatus.OK) return;

            var blockDefinition = new BlockTableRecord();
            blockDefinition.Name = blockName;
            tr.GetObject(db.BlockTableId, OpenMode.ForWrite);
            var blockId = blockTable.Add(blockDefinition);
            tr.AddNewlyCreatedDBObject(blockDefinition, true);
            var mapping = new IdMapping();
            var identifiers = new ObjectIdCollection(selection.Value.GetObjectIds());
            db.DeepCloneObjects(identifiers, blockId, mapping, false);
            var xform = Matrix3d.Displacement(
                promptPointResult.Value
                .TransformBy(ed.CurrentUserCoordinateSystem)
                .GetAsVector()
                .Negate());
            foreach (IdPair pair in mapping)
            {
                if (pair.IsCloned &amp;amp;&amp;amp; pair.IsPrimary)
                {
                    var entity = (Entity)tr.GetObject(pair.Value, OpenMode.ForWrite);
                    entity.TransformBy(xform);
                }
            }
            tr.Commit();
        }
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 19 Mar 2024 07:32:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-change-block-base-point/m-p/12650025#M4961</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-03-19T07:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Block Base Point</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-change-block-base-point/m-p/12650034#M4962</link>
      <description>&lt;P&gt;Hello !&lt;BR /&gt;Thank you for your help, Can you help me write a complete example? I'm just starting to learn so it's a bit difficult&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 07:41:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-change-block-base-point/m-p/12650034#M4962</guid>
      <dc:creator>dungthachbomay</dc:creator>
      <dc:date>2024-03-19T07:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Block Base Point</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-change-block-base-point/m-p/12650064#M4963</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14363395"&gt;@dungthachbomay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello !&lt;BR /&gt;Thank you for your help, Can you help me write a complete example? I'm just starting to learn so it's a bit difficult&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;See reply #3&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 07:58:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-change-block-base-point/m-p/12650064#M4963</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-03-19T07:58:51Z</dc:date>
    </item>
  </channel>
</rss>

