
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey All,
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. I have attached a copy of my code, any thoughts on why this may be failing?
[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;
if (ent != null)
{
ps.AppendEntity(clone);
tr.AddNewlyCreatedDBObject(clone, true);
}
}
tr.Commit();
}
// Let's take a look at the results in paperspace
db.TileMode = false;
}
Solved! Go to Solution.