Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to migrate my code from 2012 to 2015. I'm having problems with a part of my code where I try to create a layout. This part is a copy of the example found here: http://help.autodesk.com/ .
My code:
// Reference the Layout Manager
LayoutManager acLayoutMgr = LayoutManager.Current;
// Create the new layout with default settings
ObjectId objID = acLayoutMgr.CreateLayout("Tekstborden 1");
// Open the layout
Layout acLayout = transaction.GetObject(objID, OpenMode.ForWrite) as Layout;
try
{
PlotSettingsValidator plotSetVal = PlotSettingsValidator.Current;
plotSetVal.RefreshLists(acLayout);
System.Collections.Specialized.StringCollection sheetList = plotSetVal.GetPlotStyleSheetList();
foreach (String str in sheetList)
{
if (str.ToLower().Equals("_standaard.ctb"))
{
//find out if drawing is using ctb
System.Object test = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("PSTYLEMODE");
if (test.ToString().Equals("1"))
{
// drawing is using ctb so go ahead and
//assign acad.ctb to the layout
//acLayout.UpgradeOpen();
plotSetVal.SetCurrentStyleSheet(acLayout, str);
acLayout.DowngradeOpen();
}
}
}
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
MessageBox.Show(ex.Message);
}This works on 2012. But on 2015 after
ObjectId objID = acLayoutMgr.CreateLayout("Tekstborden 1");the objID = null. The only exeption I could find while debugging is: 'ObjectLeftOnDisk = 'objID.ObjectLeftOnDisk' threw an exception of type 'System.AccessViolationException'' ; 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'
Can anyone tell me whats going on?
Solved! Go to Solution.