Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have attempted to Duplicate a Layout in a Database. I am unable to use a LayoutManager Object since I am trying to make changes to Documents (.dwg files) in the background to multiplle drawings in one sweep. The drawing has a layout with some viewports in it. A hard duplicate that LayoutManager.CopyLayout() worked great, but I realized that I need to be able to do this for drawings that are open in the background via accessing its Database, and since I dont have the drawing open, I wont be able to use LayoutManager.
Here is the current code I had:
private void CopyRebuildSheet()
{
Debug.Print("CopyRebuildSheet");
string newLayoutName = "";
foreach (DataGridViewRow Row in PlanSheetsAvailableTable.Rows)
{
DB_Sheet Sheet;
Sheets.TryGetValue(Row.Cells[SheetNumColumnIndex].Value.ToString(), out Sheet);
string FilePath = $"{Sheet.fullPath}\\{Sheet.fileName}";
Database db = OpenDrawingFile(FilePath);
using(Transaction tr = db.TransactionManager.StartTransaction())
{
DBDictionary layoutDic = tr.GetObject(db.LayoutDictionaryId, OpenMode.ForWrite) as DBDictionary;
foreach(DBDictionaryEntry entry in layoutDic)
{
ObjectId layoutId = entry.Value;
Layout layout = tr.GetObject(layoutId, OpenMode.ForRead) as Layout;
if (layout.LayoutName == Row.Cells[SheetNumColumnIndex].Value.ToString())
{
// Here is an ERROR
LayoutManager layoutManager = ;
//ObjectId newLayoutId = layoutManager.CreateLayout($"{layout.LayoutName} ({Row.Cells[RSNumColumnIndex].Value.ToString()})");
newLayoutName =$"{layout.LayoutName} ({Row.Cells[RSNumColumnIndex].Value})";
//Layout newLayout = tr.GetObject(newLayoutId, OpenMode.ForWrite) as Layout;
layoutManager.CloneLayout(layout.LayoutName, newLayoutName, layoutDic.Count);
if (RSSheetsToBeImportedIntoSheetSetManager.ContainsKey(Sheet.fileName))
{
RSSheetsToBeImportedIntoSheetSetManager[Sheet.fileName] += $"\n{newLayoutName}";
}
else
{
RSSheetsToBeImportedIntoSheetSetManager.Add(Sheet.fileName, newLayoutName);
}
tr.Commit();
break;
}
}
}
EnableTheTitleBlock(newLayoutName);
}
}
Solved! Go to Solution.