<?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 object inside same drawing... problems in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/2897110#M62056</link>
    <description>&lt;P&gt;Thank you, that is perfect. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jan 2011 14:13:17 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-01-28T14:13:17Z</dc:date>
    <item>
      <title>Copy object inside same drawing... problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/2896054#M62054</link>
      <description>&lt;P&gt;I've been using this method for "copying" objects from one point to another..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim EntityCopy As Entity = EntitySource.GetTransformedCopy(Matrix3d.Displacement(startPT.GetVectorTo(EndPT)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But have run into a few glitches, not program stopping glitches just annoying ones..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With polylines, not all the properties are copied, one for example is the "global width".&amp;nbsp; it gets re-set to 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem is with dynamic blocks..&amp;nbsp; the above method creates a "dumb" version of the block rather than a functional dynamic version of the block..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone show me a way to fix this, or an alternate method for copying objects from point a to point b?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2011 17:04:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/2896054#M62054</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-01-27T17:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: Copy object inside same drawing... problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/2896682#M62055</link>
      <description>&lt;P&gt;In that case as&amp;nbsp;for&amp;nbsp;&amp;nbsp;Tony Tanzillo's recomendation&amp;nbsp;I wouldt use&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;DeepCloneObjects&lt;/STRONG&gt; &lt;/FONT&gt;&lt;FONT color="#000000"&gt;method of DataBase&lt;/FONT&gt;&amp;nbsp;instead&lt;/P&gt;&lt;P&gt;Try this quicky&lt;/P&gt;&lt;P&gt;No error trapping in there, do it by yourself&lt;/P&gt;&lt;PRE&gt;    &amp;lt;CommandMethod("como")&amp;gt; _
    Public Shared Sub CopyMove()
        Dim doc As Document = acApp.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor

        Dim peo As New PromptEntityOptions(vbLf &amp;amp; "Select object:")

        Dim per As PromptEntityResult = ed.GetEntity(peo)

        If per.Status &amp;lt;&amp;gt; PromptStatus.OK Then

            Return
        End If
        Dim startPT As Point3d = ed.GetPoint(vbCr &amp;amp; "Pick a point from: ").Value
        Dim EndPT As Point3d = ed.GetPoint(vbCr &amp;amp; "Pick a point to: ").Value
        Using tr As Transaction = db.TransactionManager.StartTransaction()
            Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)

            Dim sourceId As ObjectId = per.ObjectId

            Dim EntitySource As Entity = CType(tr.GetObject(sourceId, OpenMode.ForRead), Entity)
            Dim ids As New ObjectIdCollection()
            ids.Add(sourceId)
            db.DeepCloneObjects(ids, db.CurrentSpaceId, New IdMapping, False)
            Dim EntityCopy As Entity = CType(tr.GetObject(ids(0), OpenMode.ForRead), Entity)
            EntityCopy.UpgradeOpen()
            EntityCopy.TransformBy(Matrix3d.Displacement(startPT.GetVectorTo(EndPT)))
            EntityCopy.ColorIndex = 2

            tr.Commit()
        End Using&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2011 22:57:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/2896682#M62055</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2011-01-27T22:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Copy object inside same drawing... problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/2897110#M62056</link>
      <description>&lt;P&gt;Thank you, that is perfect. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2011 14:13:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/2897110#M62056</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-01-28T14:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Copy object inside same drawing... problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/2897190#M62057</link>
      <description>&lt;P&gt;You're welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Glad to help&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Oleg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;~'J'~&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2011 14:52:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/2897190#M62057</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2011-01-28T14:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Copy object inside same drawing... problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/2897292#M62058</link>
      <description>&lt;P&gt;Working with making blocks from existing entities in a file. I've run into problems with iterating through the entities within a selection set and writing them to my new blocktablerecord. How do I take those items from my selection set and add them to this new block? All thoughts and help are appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2011 15:50:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/2897292#M62058</guid>
      <dc:creator>MRiemenCAD</dc:creator>
      <dc:date>2011-01-28T15:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Copy object inside same drawing... problems</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/5768908#M62059</link>
      <description>&lt;P&gt;For the benefit future readers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just create a new block table record rather than adding it to the model space block table record. I think i know what i'm doing, but i'll let the more experienced autocad developers tweak the code. This is some quick and dirty code which i previously wrote.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect that the following is a shallow copy though - change to a deep one as you see fit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;      private static void CloneAndTrasnformTheObjects(PromptPointResult PPRbasePoint, PromptPointResult PPRdestinationPoint, SelectionSet ss)
        {
            // Get the transformation vector to apply to all cloned objects
            Point3d pointBase = PPRbasePoint.Value;
            Point3d pointDestination = PPRdestinationPoint.Value;
            Vector3d transformationVector = pointBase.GetVectorTo(pointDestination);

            // get the entites which we want to clone
            ObjectIdCollection entitiesToCopy = new ObjectIdCollection(ss.GetObjectIds());

            //set up the document/database/editor 
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            using (DocumentLock docLock = doc.LockDocument())
            {
                using (Transaction tr = db.TransactionManager.StartOpenCloseTransaction())
                {

                    // clone the following objects
                    foreach (ObjectId id in entitiesToCopy)
                    {
                        BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                        BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                        Entity entityOriginal = tr.GetObject(id, OpenMode.ForRead) as Entity;
                        Entity entityClone = entityOriginal.Clone() as Entity;

                        // ensuring we have no null values
                        if (entityClone != null &amp;amp;&amp;amp; entityOriginal != null &amp;amp;&amp;amp; bt != null &amp;amp;&amp;amp; btr != null)
                        {
                            entityClone.TransformBy(Matrix3d.Displacement(transformationVector));
                            btr.AppendEntity(entityClone);
                            tr.AddNewlyCreatedDBObject(entityClone, true);
                        }
                    }
                    tr.Commit();

                } 
            }
        }   &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rgds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BK&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2015 23:19:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-object-inside-same-drawing-problems/m-p/5768908#M62059</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2015-08-12T23:19:40Z</dc:date>
    </item>
  </channel>
</rss>

