.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help programming around 2015 API CreateLayout big

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
dhaverstick
821 Views, 7 Replies

Need help programming around 2015 API CreateLayout big

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 

7 REPLIES 7
Message 2 of 8
gjmanuel
in reply to: dhaverstick

 

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

Message 3 of 8
dhaverstick
in reply to: gjmanuel

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

Message 4 of 8
SENL1362
in reply to: dhaverstick

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

Message 5 of 8
SENL1362
in reply to: SENL1362

                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();
                }

 

Message 6 of 8
dhaverstick
in reply to: SENL1362

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

Message 7 of 8
SENL1362
in reply to: dhaverstick

sorry about that, but there are good Adesk supporters, so don't lose faith in them.

Message 8 of 8
autodaug
in reply to: SENL1362

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.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost