Author Topic: Documents are always read only - How do I tell Acad to let go?  (Read 1806 times)

0 Members and 1 Guest are viewing this topic.

tonofsteel

  • Guest
Documents are always read only - How do I tell Acad to let go?
« on: November 18, 2011, 01:48:25 PM »
I open a document using:

Code: [Select]
            Document acDoc = acDocMgr.Open(DrawingPath, false);

My code runs and updates the drawing, then I look in the title bar and it says the drawing is read only and if I try save it says it is write protected.

So I am opening the drawing to write, I am telling it that openreadonly = false, yet when I am done it is read only.

I have using statements for the document lock and the transaction, so when they are done the drawing should be released back to a state where surely you can save the file.

I am using a function with the following setup:

Code: [Select]
    public static class MyCommands
    {
        [CommandMethod("Draw", CommandFlags.Session)]
        public static void Draw()
        {

Since I want to iterate over drawings and add/change them I have it set up this way. 

Does anyone know what might cause this?  Is there something you need to release somewhere.  I try doc.upgradeopen and it either does not have any effect or it crashes autocad saying eWasOpenForWrite. 

But no matter what happens at the end of running a bit of code it wont let me save my changes. What A useless API, dont tell me the file is write protected - TELL ME WHY

What about docmanager.ExecuteInApplicationContext()?  Do I need a whole different approach?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Documents are always read only - How do I tell Acad to let go?
« Reply #1 on: November 18, 2011, 05:34:21 PM »
I open a document using:

Code: [Select]
            Document acDoc = acDocMgr.Open(DrawingPath, false);

My code runs and updates the drawing, then I look in the title bar and it says the drawing is read only and if I try save it says it is write protected.

< .. ?

I haven't come across a similar situation. Is the problem with one drawing or ALL drawings. ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Documents are always read only - How do I tell Acad to let go?
« Reply #2 on: November 18, 2011, 07:19:35 PM »
do you make it active?
acadApp.DocumentManager.MdiActiveDocument =acDoc

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Documents are always read only - How do I tell Acad to let go?
« Reply #3 on: November 18, 2011, 07:34:47 PM »

Bryce,
Yeah, that's the problem with only getting a little part of the info ... :)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

TimBlanch

  • Guest
Re: Documents are always read only - How do I tell Acad to let go?
« Reply #4 on: November 18, 2011, 08:25:40 PM »
With the information provided.
Code: [Select]
Document acDoc = Application.DocumentManager.Open(drawingPath, false);Opens the file in ReadWrite mode. So I have to ask are the files you are trying to open read only or on a drive you only have read permissions?
If what you are doing is supposedly all automated and you want to iterate over multiple drawings do you really need to open the drawing in the document editor?