WBlockCloneObjects into Paper Space overwrites paper space with the cloned object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a block in my source drawing and I want to use WBlockCloneObjects to transport it into the new drawing and create a reference in paper space of the new drawing.
The problem I have, is that when the reference is created, the entire layout space is replaced with the block. As in, the extents of my sheet become the extents of the block.
first I iterate through the sourceBlockTable to find the BlockTableRecord I want and I added it to my ObjectIdCollection:
foreach (ObjectId objectId in sourceBlockTable)
{
//create a btr, do some checks to make sure it's right. I make sure it's
not a layout, not from an xref or overlay, etc. Then I make sure the
names match..
BlockTableRecord blockToClone = sourceTrans.GetObject(objectId, OpenMode.
ForRead) as BlockTableRecord;
if(blockToClone.Name == blockName //i passed in blockName
{
objectIdCollection.Add(objectId);
}
}
After I get the object added to my collection, I access the destinationDatabase in a using() statement to clone the record:
IdMapping map = new IdMapping();
sourceDatabase.WblockCloneObjects(objectIdCollection, destinationDatabase.BlockTableId, map, DuplicateRecordCloning.Replace, false);
Then I open an transaction and create a reference of the record in paperspace using the standard procedure. I get the paper space block table record I want (I let my users select which layout by TabOrder) and then I create the BlockReference like so:
//I make sure the destination block table has record from the cloning...
blockReferenceId = destinationBlockTable[blockName];
using (BlockReference newBlockReference = new
BlockReference(newBlockInsertPoint, blockReferenceId))
{
blockTablePaperSpace.AppendEntity(newBlockReference)
destinationTransaction.AddNewlyCreatedDBObject
newBlockReference, true);
}
But now my paper space on the layout is simply the block. There is no "sheet" and if I try to edit the page config it just makes the block look bigger but it actually measures the same size, so I'm clearly doing something wrong.