<?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 Copying Entity to Layout in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7102476#M31333</link>
    <description>&lt;P&gt;Hey All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to copy a polyline from the model view to a paperspace layout. I have no problem creating a new object on the paperspace layout, however when I try to clone an entity and the append it to the paperspace blocktable, it does not appear on the paperspace as intended. &amp;nbsp;I have attached a copy of my code, any thoughts on why this may be failing?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[CommandMethod("stopworking")]&lt;BR /&gt;public void copy2paper()&lt;BR /&gt;{&lt;BR /&gt;Document doc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;Database db = doc.Database;&lt;BR /&gt;Editor ed = doc.Editor;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (Transaction tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;// Get the primary paperspace from the block table&lt;/P&gt;&lt;P&gt;BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);&lt;BR /&gt;BlockTableRecord ps = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.PaperSpace], OpenMode.ForWrite);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PromptEntityResult prEnt = ed.GetEntity("Select an entity: ");&lt;/P&gt;&lt;P&gt;if (prEnt.Status == PromptStatus.OK)&lt;BR /&gt;{&lt;BR /&gt;// Add each to the paperspace blocktablerecord&lt;BR /&gt;// and create/add an associated viewport object&lt;BR /&gt;Entity ent = (Entity)tr.GetObject(prEnt.ObjectId, OpenMode.ForWrite);&lt;BR /&gt;Entity clone = ent.Clone() as Entity;&lt;/P&gt;&lt;P&gt;if (ent != null)&lt;BR /&gt;{&lt;BR /&gt;ps.AppendEntity(clone);&lt;BR /&gt;tr.AddNewlyCreatedDBObject(clone, true);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;tr.Commit();&lt;BR /&gt;}&lt;BR /&gt;// Let's take a look at the results in paperspace&lt;BR /&gt;db.TileMode = false;&lt;BR /&gt;}&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2017 16:48:59 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-05-23T16:48:59Z</dc:date>
    <item>
      <title>Copying Entity to Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7102476#M31333</link>
      <description>&lt;P&gt;Hey All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to copy a polyline from the model view to a paperspace layout. I have no problem creating a new object on the paperspace layout, however when I try to clone an entity and the append it to the paperspace blocktable, it does not appear on the paperspace as intended. &amp;nbsp;I have attached a copy of my code, any thoughts on why this may be failing?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[CommandMethod("stopworking")]&lt;BR /&gt;public void copy2paper()&lt;BR /&gt;{&lt;BR /&gt;Document doc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;Database db = doc.Database;&lt;BR /&gt;Editor ed = doc.Editor;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (Transaction tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;// Get the primary paperspace from the block table&lt;/P&gt;&lt;P&gt;BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);&lt;BR /&gt;BlockTableRecord ps = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.PaperSpace], OpenMode.ForWrite);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PromptEntityResult prEnt = ed.GetEntity("Select an entity: ");&lt;/P&gt;&lt;P&gt;if (prEnt.Status == PromptStatus.OK)&lt;BR /&gt;{&lt;BR /&gt;// Add each to the paperspace blocktablerecord&lt;BR /&gt;// and create/add an associated viewport object&lt;BR /&gt;Entity ent = (Entity)tr.GetObject(prEnt.ObjectId, OpenMode.ForWrite);&lt;BR /&gt;Entity clone = ent.Clone() as Entity;&lt;/P&gt;&lt;P&gt;if (ent != null)&lt;BR /&gt;{&lt;BR /&gt;ps.AppendEntity(clone);&lt;BR /&gt;tr.AddNewlyCreatedDBObject(clone, true);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;tr.Commit();&lt;BR /&gt;}&lt;BR /&gt;// Let's take a look at the results in paperspace&lt;BR /&gt;db.TileMode = false;&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 16:48:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7102476#M31333</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-05-23T16:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Copying Entity to Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7103433#M31334</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works just fine for me. Try it and see if it works on your pc?&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;PRE&gt; [CommandMethod("stopworking")]
        public void copy2paper()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                // Get the primary paperspace from the block table
                BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                BlockTableRecord ps = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.PaperSpace], OpenMode.ForWrite);


                PromptEntityResult prEnt = ed.GetEntity("Select an entity: ");
                if (prEnt.Status == PromptStatus.OK)
                {
                    // Add each to the paperspace blocktablerecord
                    // and create/add an associated viewport object
                    Entity ent = (Entity)tr.GetObject(prEnt.ObjectId, OpenMode.ForWrite);
                    Entity clone = ent.Clone() as Entity;
                    ps.AppendEntity(clone);
                    tr.AddNewlyCreatedDBObject(clone, true);                   
                }

                tr.Commit();
            }
            // Let's take a look at the results in paperspace
            db.TileMode = false;
        }
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="inPaperspace.JPG" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/359274i5AD2EC9A9EF529B7/image-size/large?v=v2&amp;amp;px=999" role="button" title="inPaperspace.JPG" alt="inPaperspace.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 00:49:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7103433#M31334</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2017-05-24T00:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Copying Entity to Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7103541#M31335</link>
      <description>&lt;P&gt;You don't use Clone() to copy an Entity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You use the Database.DeepCloneObjects() method. &amp;nbsp;There is a big difference. The latter will clone anything attached to the entity along with it (Clone() does a 'shallow' clone, and only clones the entity itself, but nothing attached to it like an ExtensionDictionary). DeepCloneObjects() also preserves object references between multiple objects when they are cloned in the same operation. DeepCloneObjects() is what the COPY command uses.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 02:38:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7103541#M31335</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-05-24T02:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Copying Entity to Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7115180#M31336</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;that was the solution I used to build my original code. When cloning the object I forgot to transform it onto the paperspace sheet area and a s a result didn't realize the code I posted was working as designed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 16:55:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7115180#M31336</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-05-29T16:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Copying Entity to Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7115192#M31337</link>
      <description>&lt;P&gt;Thanks for the reply,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For my purposes the clone() function was perfectly adequate as I only needed to clone the shape of the object I was cloning in order to create a non rectangular viewport. That does clear up some questions about the usage of deepclone vs clone, so thanks for the reply!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 17:00:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7115192#M31337</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-05-29T17:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Copying Entity to Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7117780#M31338</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;&lt;P&gt;Thanks for the reply,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For my purposes the clone() function was perfectly adequate as I only needed to clone the shape of the object I was cloning in order to create a non rectangular viewport. That does clear up some questions about the usage of deepclone vs clone, so thanks for the reply!&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;That's fine as long as what you're cloning is not a 'heavy' polyline (Polyline2d), as Clone() doesn't clone their vertex subentities.&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 18:58:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copying-entity-to-layout/m-p/7117780#M31338</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-05-30T18:58:19Z</dc:date>
    </item>
  </channel>
</rss>

