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

Problem with preferences.files.EnterpriseMenuFile

8 REPLIES 8
Reply
Message 1 of 9
Passi
672 Views, 8 Replies

Problem with preferences.files.EnterpriseMenuFile

Hi to all,

 

we want to set the preferences.files.EnterpriseMenuFile during the runtime of ACAD.

 

And the vb.net program throws an error:

 

"Fehler beim Festlegen der Voreinstellungen"

 

In English it must be something like: "Error occurs while set up the preferences"

 

All other preferences we've tested, like "QNewTemplateFile" are working during runtime.

 

What's wrong?

 

Best Regards

 

Passi

 

PS: (Here's an example with the standard acadm.cuix. ACAd is a simple AutocadApplication)

 

ACAD.Preferences.Files.EnterpriseMenuFile =

"C:\Autodesk\2013\AutoCAD 2013\UserDataCache\de-DE\Support\acadm.cuix"

 

 

8 REPLIES 8
Message 2 of 9
Balaji_Ram
in reply to: Passi

Hi Pascale,

 

Is the problem specific to AutoCAD Mechanical ? 

Is the code to set the enterprise cuix called during startup or from a command ?

 

I could run the following code to change the enterprise cuix in AutoCAD 2014 :

 

/*

AcadApplication acadApp = Application.AcadApplication as AcadApplication;

AcadPreferences acadPref = acadApp.Preferences;

AcadPreferencesFiles files = acadPref.Files;

String path = files.EnterpriseMenuFile;

files.EnterpriseMenuFile = @"C:\Temp\Test.cuix";

*/

 

dynamic acadApp = Application.AcadApplication;

dynamic preferences = acadApp.Preferences;

dynamic files = preferences.Files;

string path = files.EnterpriseMenuFile;

files.EnterpriseMenuFile = @"C:\Temp\Test.cuix";

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 9
Passi
in reply to: Passi

In the Meanwhile I've researched a little bit more on the error message itself:

 

HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)

 

It's also described here:

 

http://through-the-interface.typepad.com/through_the_interface/2010/02/handling-com-calls-rejected-b...

 

I've discovered, that the Error didn't occur, when I'm checking if Autodesk is quiescent or not: (I've asked for it in another Post :))

 

ACAD.Application.GetAcadState.IsQuiescent

 

And if Yes, than I can change this parameter.

 

The other possibiliy is to try the same program column again if an error occurs. But that's not ideal.

 

So, it seems that the error only occurs, if the AutoCAD is busy, but I'm not sure.

 

Best Regards

 

Passi

 

 

Message 4 of 9
WolframKuss12
in reply to: Balaji_Ram

Hello Bajaji

 

I used your code in C# together with AutoCAD2013 and AutoCAD2014 and it works nicely and in the Idle Handler I can load the enterprise menue file.

 

However, using it together with AutoCAd OEM 2013 it crashes in this line:

 

dynamic preferences = acadApp.Preferences;

 

The crash is obvioulsy in AutoCAd itself (tray / catch around the code in C# does not help). When debugging, the error message is a stack overflow.

 

Any idea on the cause or on a fix?

Is there any other way to programmatically load a enterprise CUIX file in an OEM?

 

TIA,

Wolfram.

 

Message 5 of 9

Strange:

replacing

dynamic preferences = acadApp.Preferences;

with

dynamic preferences = Application.Preferences;

seems to work both under the OEM and the non-OEM version. Smiley Surprised

 

So, from what I understand Preferences at least in the non-OEM version can be a member of Application or of Application.AcadApplication;

Is this correct and why are there two ways to skin the cat? What is AcadApplication in an OEM version?

Anyway, while I don't understand why, at least it works now.

Message 6 of 9
Balaji_Ram
in reply to: WolframKuss12

Hi Wolfram,

 

Sorry for the delay. 

 

Yes, there are two ways to access the preferences. One of them using the AcadApplication COM object and other using the Application. The second way provides an easier way to access the preferences without having to get the COM object first. Both the ways of accessing the preferences work ok in AutoCAD and AutoCAD OEM. The behavior that you mention is about the use of the dynamic keyword in AutoCAD OEM. I had contacted our engineering team about this. I have received a reply that the OEM intentionally puts some restrictions on using dynamic keyword due to certain licensing checks in OEM with which dynamic interferes.

 

The following three methods work ok in AutoCAD OEM : 

 

// Works OK
AcadPreferences pref1 = Application.Preferences as AcadPreferences;
ed.WriteMessage(String.Format("{0}{1}", Environment.NewLine, pref1.Files.SupportPath));
 
// Works OK
AcadApplication acadApp1 = Application.AcadApplication as AcadApplication;
AcadPreferences acadPrefs1 = acadApp1.Preferences;
ed.WriteMessage(String.Format("{0}{1}", Environment.NewLine, acadPrefs1.Files.SupportPath));
 
// Works OK
dynamic pref2 = Application.Preferences as AcadPreferences;
ed.WriteMessage(String.Format("{0}{1}", Environment.NewLine, pref2.Files.SupportPath));
 

 

// Does not work in OEM but works ok in AutoCAD
dynamic acadApp2 = Application.AcadApplication as AcadApplication;
dynamic acadPrefs2 = acadApp2.Preferences;
ed.WriteMessage(String.Format("{0}{1}", Environment.NewLine, acadPrefs2.Files.SupportPath));

 

Regards,

Balaji

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 7 of 9
WolframKuss12
in reply to: Balaji_Ram

Thank you Balaji. It is important to know our code is "officially" ok.Like I said we tested and it worked and it still does. Unfortunately testing some more on different computers shows that on some there is a crash in the line

files.EnterpriseMenuFile = @"C:\Temp\Test.cuix";

The crash only happens when the selected workspace beforehand is one of the workspaces that is included in the Enterprise CUI.

 

We have a pair of computers that seem to be identical - both using ACAD OEM 2013, both Win 7 64bit, same bin and config directories, seemingly same registry settings and on one i crashes on the other it works.

 

Unfortunately by now things are getting urgent 😞

 

Wolfram Kuss,

imos AG.

Message 8 of 9

Of course "it worked and it still does." should read "it worked and it still does on some computers". BTW, is it possible to edit old posts?

 

 

Anyway, here is the current code. "Before enterprise" will be written into the log file, "After enterprise" will not be written:

        AcadPreferences preferences = Application.Preferences as AcadPreferences;
        AcadPreferencesFiles files = preferences.Files;
        bool b = Application.IsQuiescent;
        if (b)
        {
            imosLogging.Log("Before enterprise");
            files.EnterpriseMenuFile = myCuiFile;
            imosLogging.Log("After enterprise");
        }

 Unfortunately while there is an AutoCAD error message during the crash, it does not help. It says, translated to english:

 

"imo CAD OEM is not able to continue. You might want to save changes to your drawing into the following dwg...."

Message 9 of 9

Here is the next iteration of our algorithm to ensure that the same workspace is active after reloading the enterprise CUI as beforehand. This seems to fix all issues:

 

1. We get the systemvariable WSCURRENT and store it. We set it to "" (empty string). Does this always set it to an AutoCAD workspace (AutoCAD is always the main CUI for our customers). We add an idlehandler "OnIdle0".

2 . In OnIdle0 the main processing is done; We create the enterprise CUI that we want the customer to see in this session. Remove OnIdle0, add OnIdle1.

3. In OnIdle1, we load the entrerprisecui with the code I posted above in this thread. This works as it does not affect the current workspace, which is an AutoCAD workspace. Remove OnIdle1, add OnIdle2.

4 In OnIdle2, switch back to the workspace that was active at the beginning. Remove OnIdle2.

 

Bye bye

Wolfram

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