User Interface Language

User Interface Language

faisal.aaouatif
Collaborator Collaborator
602 Views
8 Replies
Message 1 of 9

User Interface Language

faisal.aaouatif
Collaborator
Collaborator

Hello,

Is there a way to get the user interface language of a running AutoCAD application without having to go searching in the windows registry?

I didnt found a property doing so.

Thanks.

0 Likes
603 Views
8 Replies
Replies (8)
Message 2 of 9

norman.yuan
Mentor
Mentor

@faisal.aaouatif wrote:

... user interface language of a running AutoCAD application ...


Not sure what do you mean here.

 

Do you mean that if an custom CAD application available in AutoCAD, you want to know which PROGRAMMING LANGUAGE is used to build the Cad app? There are different CAD apps that can be developed by different programming languages: AutoLISP/Visual LISP, VBA, .NET languages (C#, VB.NET and others), C/C++. Most of them can be recognized by the file extension (*.lsp, *.fas, *.dvb, *.dll, *.arx, *crx,...).

 

You might want to explain what exactly you'd like to know in plain English.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 9

faisal.aaouatif
Collaborator
Collaborator

Sorry for the confusion.

I have an Excel VBA application that interacts with Autocad.

This application is intended to be used in different Autocad environments (English/French/German...)

When running the VBA code, I wanted to get the language of the open Autocad instance on the user's machine.

This information will be used in "sendcommand" instruction to this instance.

For example:

- The Purge command requires language-dependent arguments :

      AcadDoc.SendCommand "_-Purge" & vbCr & "All" & vbCr & "*" & vbCr & "Y" & vbCr          For "English" Autocad

      AcadDoc.SendCommand "_-Purge" & vbCr & "TO" & vbCr & "*" & vbCr & "O" & vbCr          For "French" Autocad 

--> Calling GetVariable("Locale") for an active document will do the work.

I was just wondering why there was no such property directly for the application object, before opening a document...

Thanks.

0 Likes
Message 4 of 9

norman.yuan
Mentor
Mentor

So, you just want to get the system variable "LOCALE" before calling AcadDoc.SendCommand().

Yes, this is how the AutoCAD COM API works: the system variables can only be accessed vis AcadDocument.Get[Set]Varibale() method, regardless the a variable is drawing/document dependent or application dependent.

 

However, since you are to call SendCommand from an AcadDocument, which means you can only go ahead if there is a drawing open in AutoCAD anyway. So, you can always call AcadDocument.GetVariable("LOCALE") before proceed to call SendCommand(), right?

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 9

faisal.aaouatif
Collaborator
Collaborator

Exactly.

As I said 

I was just wondering why there was no such property directly for the application object ( Since it is indeed an application property .. ) , before opening a document. But if is the way AutoCAD COM API works, It is what it is.

Thanks a lot Norman.

0 Likes
Message 6 of 9

Ed__Jobe
Mentor
Mentor

Is there a need to know the locale before you open the document? If not, the as @norman.yuan mentioned, using the document api is sufficient. 

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 7 of 9

faisal.aaouatif
Collaborator
Collaborator

When I need to loop over multiple drawings, I will have to query the local variable for each drawing on each iteration, instead of querying the application itself only once, before starting the processing.

May be querying the first drawing , store this data in a variable and use directly it for the others....

But this is not a big problem, because the solution offered by the Document API is also fast and simple.

Thank you.

 

0 Likes
Message 8 of 9

norman.yuan
Mentor
Mentor

Yes, you only get "Locale" value once at the very first drawing opening, or, probably before you open any target drawing - if the running AutoCAD session, which may or may not be launched by your Excel VBA code, does have an default/empty drawing there.  that is, you can do"

 

1. connect to AutoCAD session, using GetObject()/CreateObject(), or new AcadApplication... 

2. Test if AcadApplication.ActiveDocument is Nothing or not.

  a. If not, go ahead to get the value of "LOCALE"

  b. If yes, go ahead to open the first target drawing, then get the value of "LOCALE"

  

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 9 of 9

daniel_cadext
Advisor
Advisor

Also, try to use the API whenever possible, I.e. ActiveDocument.PurgeAll

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx