×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Language Setting info
2

Language Setting info

Language Setting info

(OP)
Hello everyone,
I want obtain info language setting of CATIA with a simple macro;
Can help me someone?
I know I can read the body name of the firt part and so deduct the language, but I want a msgbox that tell me which language is setting.

Thank you to all

RE: Language Setting info

Hi dddn -San.

The status bar in the lower left corner of the screen displays different characters for each language.
I have created a function to determine the language by how "Object" is displayed when nothing is selected.
Link

I am using Japanese CATIA V5, so the characters to be judged may be slightly different, but it should be usable enough.

RE: Language Setting info

Code below doesn't rely on any side effects and reads language from CATIA settings.
Note that default CATIA behavior is to use system language, which can be obtained with GetLocale() function.

CODE

'==============================================================================
'   Gets current CATIA UI language by reading FrameGeneral.CATSettings file
'==============================================================================
Private Function GetLanguageFromSettings()
    ' set the defaul return value
    GetLanguageFromSettings = ""
    
    ' read FrameGeneral.CATSettings from settings as binary
    Dim fso, settingsFile, content, filePos
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set settingsFile = fso.OpenTextFile(fso.BuildPath(CATIA.SystemService.Environ("CATUserSettingPath"), "FrameGeneral.CATSettings"))
    content = settingsFile.ReadAll()
    settingsFile.Close
    filePos = InStr(content, "UserInterfaceLanguage")

    ' read byte that stores setting value
    Select Case Asc(Mid(content, filePos + 54, 1))
        Case &HE5:  GetLanguageFromSettings = "RU"
        Case &H56:  GetLanguageFromSettings = "FR"
        Case &HCA:  GetLanguageFromSettings = "EN"
        Case &H5A:  GetLanguageFromSettings = "DE"
        Case &H27:  GetLanguageFromSettings = "JP"
        Case &H24:  GetLanguageFromSettings = "CH"
        Case &H60:  GetLanguageFromSettings = "KO"
        Case &H0:   GetLanguageFromSettings = "SYSTEM"
    End Select
End Function 

RE: Language Setting info

(OP)
Hi,
thank you all.
Little C. your idea is very interesting but I don't have access at FrameGeneral settings, and so the macro dosen't work; but is a good input and I will try to read this settings.

Thanky you so much.

RE: Language Setting info

Quote:

I don't have access at FrameGeneral settings

How could that be? This file is required by CATIA to operate.

RE: Language Setting info

(OP)
I have this setting file but I can't manipulate; I want to get a msgbox with a selected language, but I don't know a way to do it.

RE: Language Setting info

What error does it raise? Can you post a screenshot?

CODE

Sub CATMain()
    MsgBox GetLanguageFromSettings()
End Sub
'==============================================================================
'   Gets current CATIA UI language by reading FrameGeneral.CATSettings file
'==============================================================================
Private Function GetLanguageFromSettings()
    ' set the defaul return value
    GetLanguageFromSettings = ""
    
    ' read FrameGeneral.CATSettings from settings as binary
    Dim fso, settingsFile, content, filePos
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set settingsFile = fso.OpenTextFile(fso.BuildPath(CATIA.SystemService.Environ("CATUserSettingPath"), "FrameGeneral.CATSettings"))
    content = settingsFile.ReadAll()
    settingsFile.Close
    filePos = InStr(content, "UserInterfaceLanguage")

    ' read byte that stores setting value
    Select Case Asc(Mid(content, filePos + 54, 1))
        Case &HE5:  GetLanguageFromSettings = "RU"
        Case &H56:  GetLanguageFromSettings = "FR"
        Case &HCA:  GetLanguageFromSettings = "EN"
        Case &H5A:  GetLanguageFromSettings = "DE"
        Case &H27:  GetLanguageFromSettings = "JP"
        Case &H24:  GetLanguageFromSettings = "CH"
        Case &H60:  GetLanguageFromSettings = "KO"
        Case &H0:   GetLanguageFromSettings = "SYSTEM"
    End Select
End Function 

RE: Language Setting info

(OP)

I have correct the error, with the direct path of the FrameGeneral and in this way, macro is correct. I don't catch why then line doesn't work, with your script.

RE: Language Setting info

Run this script and post messages it displays.

CODE

Sub CATMain()
    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    MsgBox "Dir: " & CATIA.SystemService.Environ("CATUserSettingPath")
    MsgBox "Path: " & fso.BuildPath(CATIA.SystemService.Environ("CATUserSettingPath"), "FrameGeneral.CATSettings")
    MsgBox CStr(fso.FileExists(fso.BuildPath(CATIA.SystemService.Environ("CATUserSettingPath"), "FrameGeneral.CATSettings")))
End Sub 

RE: Language Setting info

(OP)
Little C. thank you so much for your help.
On attached the mesgox results:


RE: Language Setting info

Ok, modify GetLanguageFromSettings function above:

CODE

Dim fso, dir, path, settingsFile, content, filePos
    Set fso = CreateObject("Scripting.FileSystemObject")
    For each dir in Split(CATIA.SystemService.Environ("CATUserSettingPath"), ";")
        path = fso.BuildPath(dir, "FrameGeneral.CATSettings")
        If fso.FileExists(path) then
            Set settingsFile = fso.OpenTextFile(path)
            content = settingsFile.ReadAll()
            settingsFile.Close
            Exit for
        End if
    Next
    If IsEmpty(dir) then
        Exit function 
    End if 

RE: Language Setting info

(OP)
Thank you so much.
In this way msgbox is correct.

Thank you!!

RE: Language Setting info

Final version with "SYSTEM" language analysis:

CODE

'==============================================================================
'   Gets current CATIA UI language by reading FrameGeneral.CATSettings file
'==============================================================================
Private Function GetLanguageFromSettings()
    ' set the defaul return value
    GetLanguageFromSettings = ""
    
    ' locate FrameGeneral.CATSettings among all settings directories
    Dim fso, dir, path, settingsFile, content, filePos, ss
    Set fso = CreateObject("Scripting.FileSystemObject")
    For Each dir In Split(CATIA.SystemService.Environ("CATUserSettingPath"), ";")
        path = fso.BuildPath(dir, "FrameGeneral.CATSettings")
        If fso.FileExists(path) Then
            Exit For
        End If
    Next
    If IsEmpty(dir) Then
        Exit Function
    End If

    ' read file
    Set settingsFile = fso.OpenTextFile(path)
    content = settingsFile.ReadAll()
    settingsFile.Close
    filePos = InStr(content, "UserInterfaceLanguage")

    ' read byte that stores setting value
    Select Case Asc(Mid(content, filePos + 54, 1))
        Case &HE5:  GetLanguageFromSettings = "RU"
        Case &H56:  GetLanguageFromSettings = "FR"
        Case &HCA:  GetLanguageFromSettings = "EN"
        Case &H5A:  GetLanguageFromSettings = "DE"
        Case &H27:  GetLanguageFromSettings = "JP"
        Case &H24:  GetLanguageFromSettings = "CH"
        Case &H60:  GetLanguageFromSettings = "KO"
        Case &H0:   ' check system locale
            Set ss = CATIA.SystemService
            Select Case ss.Evaluate("Function Main() Main = GetLocale() End Function", CATVBScriptLanguage, "Main", Array())
                Case 1049: GetLanguageFromSettings = "RU"
                Case 1036: GetLanguageFromSettings = "FR"
                Case 1033: GetLanguageFromSettings = "EN"
                Case 1031: GetLanguageFromSettings = "DE"
                Case 1041: GetLanguageFromSettings = "JP"
                Case 2052: GetLanguageFromSettings = "CH"
                Case 1042: GetLanguageFromSettings = "KO"
            End Select
    End Select
End Function 

RE: Language Setting info

(OP)
Hi Little C. thanks again.

For the string "content = settingsFile.ReadAll()", is it possible to have a msgbox with all content of the FrameGeneral.CATSettings? When I print msgbox content I obtain: M◻︎

RE: Language Setting info

Not possible, because .CATsettings files are binary and contain null bytes which are atreated as end of string chars by VBA.

You really have to dig in with hex editor by yourself or use CAA to read it.

RE: Language Setting info

(OP)
Thank you Little, clear.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close