When I clone a layout from another drawing exported from Revit and then save it. After reopen the file, the viewports are lost. Can you please help me with this issue?
private void CopyContent(ObjectId newLayoutId, Layout cloneLayout)
{
Document mdiActiveDocument = Application.DocumentManager.MdiActiveDocument;
Database database = mdiActiveDocument.Database;
using (Transaction transaction = mdiActiveDocument.TransactionManager.StartTransaction())
{
Layout newLayout = newLayoutId.GetObjectAs<Layout>();
using (BlockTableRecord blockTableRecord = cloneLayout.BlockTableRecordId.OpenAs<BlockTableRecord>())
{
List<ObjectId> list = blockTableRecord.OfType<ObjectId>().Where(id => id.IsFullyValid()).ToList();
if (list.Any())
{
ObjectIdCollection objectIdCollection = new ObjectIdCollection(list.ToArray());
IdMapping idMapping = new IdMapping();
database.WblockCloneObjects(objectIdCollection, newLayout.BlockTableRecordId, idMapping,
(DuplicateRecordCloning)4, false);
}
}
transaction.Commit();
}
}
Before saving the file image / After saving the file and reopening image
I tried to Audit and purge the project but it did not help. The viewport should not be lost after saving the file.