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

GetFileNameForOpen in command context freeze in 2011

6 REPLIES 6
Reply
Message 1 of 7
Pluc.m
390 Views, 6 Replies

GetFileNameForOpen in command context freeze in 2011

Hi,

 

I wrote a little application that redefines the open command. On open, the new command will ask which file to open, check the file state (lock), then ask how the user wants to open the file. If the file is locked by another user, it will ask if you want to open it as read-only or if you want to abord the opening. If it's not locked, it will ask if you want to open it as read-only or full access. Open opening the file as Full Access, it will remove Windows' read-only file attribute and then open the file fully.

 

The other part of the application is a hook on the "DocumentToBeDestroyed" event. Whenever you close a drawing, it will check if another user as that file locked, and if not, it will turn the file into read-only.

 

Everything works fine in AutoCAD 2012 x64 on Windows 7 machines. However, ONE of our machine is running AutoCAD 2011 x86 on Windows XP and the application refuses to work on that machine. The first problem was that I worked with .NET 4.0. So I switched that arround to 3.5 (even had to manually edit projet files for some reason...). Now the DLL loads up. But the nightmare aint over yet.

 

My current problem, in AutoCAD 2011 x86 only, is that when I call "GetFileNameForOpen" to open up the file dialog, AutoCAD straight up freezes. No error, no delay, no nothing. You press CTRL+O or type OPEN in the CLI, and it just stops responding. The weird part is that if I put the EXACT SAME 3 LINES of code in the plugin's initialisation code, it opens it just fine... So I started messing arround with CommandFlags in my command attribute, but couldnt find anything that fixes it.

 

Here is the command

 

[CommandMethod("OPEN", CommandFlags.Session | CommandFlags.NoUndoMarker | CommandFlags.Transparent)]
public void OuvertureProtege()
{
    PromptOpenFileOptions opts = new PromptOpenFileOptions("Sélectionner un fichier");
    opts.Filter = "Dessin (*.dwg)|*.dwg|Normes (*.dws)|*.dws|DXF (*.dxf)|*.dxf|Gabarit de dessin (*.dwt)|*.dwt";
    // The next line doesn't open the file dialog.
    PromptFileNameResult pr =  AcadApplication.DocumentManager.MdiActiveDocument.Editor.GetFileNameForOpen(opts);
    // The next lines are never executed.
    if (pr.Status == PromptStatus.OK)
        OuvertureProtege_Core(pr.StringResult);
}

 Any lead or ideas on what could have an impact on this issue is really appreciated.

6 REPLIES 6
Message 2 of 7
owenwengerd
in reply to: Pluc.m

You're more likely to get help if you post your managed API questions in the .NET group.

--
Owen Wengerd
ManuSoft
Message 3 of 7
Pluc.m
in reply to: Pluc.m

Oh? What is this forum for then? I'm kind of confused....

Message 4 of 7
owenwengerd
in reply to: Pluc.m

This forum is for ObjectARX (which is a native C++ API). I suppose you're confused by Autodesk's decision to include the word "ObjectARX" in its name for the managed API, but the two are entirely different.

--
Owen Wengerd
ManuSoft
Message 5 of 7
Pluc.m
in reply to: owenwengerd

Ohhhh, ok. The .NET API is basically just a ObjectARX wrapper, correct?

Message 6 of 7
owenwengerd
in reply to: Pluc.m

I believe parts of the .NET API wrap unmanaged counterparts, but you should ask that question of the .NET API experts.

--
Owen Wengerd
ManuSoft
Message 7 of 7
Pluc.m
in reply to: owenwengerd

That was just a curiosity question. I asked the original question in .NET forum already. Thanks!

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

Post to forums  

Autodesk Design & Make Report

”Boost