在我们运行中文脚本时候,如果3dsmax默认语言是英文,执行带有中文的脚本就会报错,或者界面显示乱码,解决方法很简单

我们只需要在 Customize–>Preferences…–>Files–>Default Language下拉列表中,将其改为Chinese,重启3dsmax软件,一劳永逸。


这个选项就保存在3dsmax.ini中,可以读ini文件来判断或设置

if "2052" != GetINISetting (GetMAXIniFile()) "File Language Options" "LanguageToUseForFileIO" do
SetINISetting (GetMAXIniFile()) "File Language Options" "LanguageToUseForFileIO" "2052"

当然修改ini文件会有个缺点,就是需要重启max。如果不想重启max,可以用下面的函数

Fn SetDefaultLanguageToChinese = 
(
    if (MaxVersion() )[1] >= 15000 do
    if "2052" != GetINISetting (GetMAXIniFile()) "File Language Options" "LanguageToUseForFileIO" do 
    (
        DialogMonitorOPS.UnRegisterNotification id:#SetDefaultLanguageToChinese
        Fn DialogMonitorCallBackSetDefaultLanguageToChinese = 
        (
            currentHandle = DialogMonitorOPS.GetWindowHandle()
            if "Preference Settings" == UIAccessor.GetWindowText currentHandle do
            (
                languageNames = #("Chinese","English","German","French","japanese","Korean","Current")
                childrens = Windows.getChildrenHWND currentHandle
                
                languageLabel = undefined 
                for tempControl in childrens where tempControl[5] == "Default Language:" do 
                (
                    languageLabel = tempControl
                )
                if languageLabel != undefined do
                for tempControl in childrens where 
                (
                    tempControl[2]==languageLabel[2] and \
                    tempControl[3]==languageLabel[3]  and \
                    "ComboBox" == tempControl[4] and \
                    FindItem languageNames tempControl[5] != 0
                )
                do
                (
                    UIAccessor.SendMessage tempControl[1] 0x014E 6 0
                )
                UIAccessor.SendMessageID currentHandle #IDOK
            )
            true
        )
        DialogMonitorOPS.RegisterNotification DialogMonitorCallBackSetDefaultLanguageToChinese id:#SetDefaultLanguageToChinese
        DialogMonitorOPS.Enabled = true
        DialogMonitorOPS.ShowNotification()
        max file preferences
        DialogMonitorOPS.UnRegisterNotification id:#SetDefaultLanguageToChinese
        DialogMonitorOPS.Enabled = false
    )
)
SetDefaultLanguageToChinese()