<?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: Copy Entities in code in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/copy-entities-in-code/m-p/8571903#M23640</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll find some examples on how to mimic the cOPY command with code reading &lt;A href="https://forums.autodesk.com/t5/net/how-to-use-a-copy-jig-for-an-entity-array/m-p/5473174/highlight/true#M43016" target="_blank" rel="noopener"&gt;this reply&lt;/A&gt; and the following ones.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Feb 2019 17:31:12 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2019-02-04T17:31:12Z</dc:date>
    <item>
      <title>Copy Entities in code</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-entities-in-code/m-p/8570414#M23639</link>
      <description>&lt;P&gt;Hi can someone please assist me here. I'm trying to copy a entity to a new location in the drawing but I want to do this all in code. Im currently playing around with PromptSelectionResult and can successfully select the entity but i want to be able to select the location in the current model space to copy this entity to.&lt;/P&gt;
&lt;P&gt;Can someone provide me some example code on how to do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;Shaban.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 06:14:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-entities-in-code/m-p/8570414#M23639</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-04T06:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Entities in code</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-entities-in-code/m-p/8571903#M23640</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll find some examples on how to mimic the cOPY command with code reading &lt;A href="https://forums.autodesk.com/t5/net/how-to-use-a-copy-jig-for-an-entity-array/m-p/5473174/highlight/true#M43016" target="_blank" rel="noopener"&gt;this reply&lt;/A&gt; and the following ones.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2019 17:31:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-entities-in-code/m-p/8571903#M23640</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-02-04T17:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Entities in code</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-entities-in-code/m-p/8573109#M23641</link>
      <description>&lt;P&gt;Thank you for the links they are helpful. But i am struggling to put it all together.&lt;/P&gt;
&lt;P&gt;I can select the entity or entities to copy but I'm failing on executing the destination location to copy to.&lt;/P&gt;
&lt;P&gt;Can you please provide a simple code snippet of selecting the entity then copying to a new location that i select.&lt;/P&gt;
&lt;P&gt;I'm coding in vb.net&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;P&gt;Shaban&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 04:51:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-entities-in-code/m-p/8573109#M23641</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-05T04:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Entities in code</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-entities-in-code/m-p/8573205#M23642</link>
      <description>&lt;P&gt;Here's a simple example.&lt;/P&gt;
&lt;P&gt;It's C# but you should be able to convert it to VB or, better, learn C# instead of VB.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        [CommandMethod("CMD")]
        public static void Cmd()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            // prompt the user to select objects
            var psr = ed.GetSelection();
            if (psr.Status != PromptStatus.OK)
                return;

            // prompt the user to specify the base point
            var ppo = new PromptPointOptions("\nSpecify base point: ");
            var ppr = ed.GetPoint(ppo);
            if (ppr.Status != PromptStatus.OK)
                return;
            var basePt = ppr.Value;

            // prompt the user to specify the desination point
            ppo.Message = "\nSpecify destination point: ";
            ppo.BasePoint = basePt;
            ppo.UseBasePoint = true;
            ppr = ed.GetPoint(ppo);
            if (ppr.Status != PromptStatus.OK)
                return;
            var destPt = ppr.Value;

            // compute the displacement matrix
            var vect = basePt.GetVectorTo(destPt).TransformBy(ed.CurrentUserCoordinateSystem);
            var disp = Matrix3d.Displacement(vect);

            using (var tr = db.TransactionManager.StartTransaction())
            {
                // copy the selected entities
                var ids = new ObjectIdCollection(psr.Value.GetObjectIds());
                var idMap = new IdMapping(); ;
                db.DeepCloneObjects(ids, db.CurrentSpaceId, idMap, false);

                // displace the copied entities
                foreach (IdPair pair in idMap)
                {
                    if (pair.IsPrimary &amp;amp;&amp;amp; pair.IsCloned)
                    {
                        Entity ent = (Entity)tr.GetObject(pair.Value, OpenMode.ForWrite);
                        ent.TransformBy(disp);
                    }
                }
                tr.Commit();
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Feb 2019 06:41:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-entities-in-code/m-p/8573205#M23642</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-02-05T06:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Entities in code</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-entities-in-code/m-p/8575301#M23643</link>
      <description>&lt;P&gt;Love ya work thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 21:09:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-entities-in-code/m-p/8575301#M23643</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-05T21:09:52Z</dc:date>
    </item>
  </channel>
</rss>

