ObjectARX

ObjectARX

Reply
Contributor
Pluc.m
Posts: 21
Registered: ‎08-31-2012
Message 1 of 7 (102 Views)

GetFileNameForOpen in command context freeze in 2011

102 Views, 6 Replies
09-13-2012 08:56 AM

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.

Distinguished Mentor
owenwengerd
Posts: 626
Registered: ‎08-06-2002
Message 2 of 7 (98 Views)

Re: GetFileNameForOpen in command context freeze in 2011

09-13-2012 10:43 AM 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
Contributor
Pluc.m
Posts: 21
Registered: ‎08-31-2012
Message 3 of 7 (96 Views)

Re: GetFileNameForOpen in command context freeze in 2011

09-13-2012 10:45 AM in reply to: Pluc.m

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

Distinguished Mentor
owenwengerd
Posts: 626
Registered: ‎08-06-2002
Message 4 of 7 (92 Views)

Re: GetFileNameForOpen in command context freeze in 2011

09-13-2012 10:59 AM 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
Contributor
Pluc.m
Posts: 21
Registered: ‎08-31-2012
Message 5 of 7 (90 Views)

Re: GetFileNameForOpen in command context freeze in 2011

09-13-2012 11:00 AM in reply to: owenwengerd

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

Distinguished Mentor
owenwengerd
Posts: 626
Registered: ‎08-06-2002
Message 6 of 7 (84 Views)

Re: GetFileNameForOpen in command context freeze in 2011

09-13-2012 12:37 PM 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
Contributor
Pluc.m
Posts: 21
Registered: ‎08-31-2012
Message 7 of 7 (82 Views)

Re: GetFileNameForOpen in command context freeze in 2011

09-13-2012 12:38 PM in reply to: owenwengerd

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

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.