There is currently a bug in the 2015 API that will not let you create a new layout in a drawing if you have previously opened that drawing's Layout DBDictionary. [42879:Layout Manager throws a eSetFailed Error]
I have a lot of code that opens that particular dictionary to see what layouts exist in a drawing and what their names are. Is there a clever way to do this without opening the Layout dictionary or resorting to using COM?
Thanks in advance,
Darren
Solved! Go to Solution.
Solved by SENL1362. Go to Solution.
The .NET sample at Import a layout from an external drawing may help you? You may have to add the following line to avoid a access denied error...besides that...it works in 2015.
Using docLock As DocumentLock = acDoc.LockDocument()
Gary
Thanks, Gary, but I should have been more clear in my original post. I need to 1) iterate through a drawing's existing layouts to get their names AND 2) possibly create a new layout in the drawing. With the bug in the 2015 API, I cannot do that at this time. I can accomplish either task separately but I cannot create a layout IF I have previously opened the layout DBDictionary. And the only way I know how to get all the names of the layouts is to open that dictionary.
I can go the COM route to get the names of the existing layouts but I would prefer not to do that if at all possible.
What I would really like is for Autodesk to fix the **** bug. At this rate, the 2016 version of the software will be out before the error is corrected in the 2015 version.
Darren
two ideas (noy coded)
1. activate layout using the layoutNr then get layoutName using LayoutManager
2. query blocks and read their IsLayout flag then get the layout object using the layout reference
using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); foreach (ObjectId btrId in bt) { BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead); if (btr.IsLayout) { Layout layout = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead); ed.WriteMessage("\n {0}", layout.LayoutName); } } tr.Commit(); }
Thanks so much, SENL1362! That is exactly what I am looking for.
On a side note, my company is a member of the Autodesk Developer Network and I haven't received any good coding advice from them on this topic.
Thanks again!
Darren
sorry about that, but there are good Adesk supporters, so don't lose faith in them.
Another way to work around this is to inspect the layout dictionary in a separate transaction from the one in which you create the new layout. The problem only occurs if you have the layout dictionary open while you create the layout.