Share

Resource String Replacement

Overview

Starting with 3ds Max 2012, Scripts and MacroScripts can use Resource IDs in place of strings.

This simplifies the localization of scripts significantly:

All hard-coded English strings can be replaced with Resource IDs and the Resource IDs together with the original values can be stored in a Resource file.

The Resource file can then be translated into multiple languages and the corresponding language version can be loaded automatically according to the 3ds Max Language Settings.

Implementation

A Resource ID is identified as a name surrounded by tildes, for example LIGHT_LISTER_DIALOG_NAME.

If MAXScript encounters a Resource ID at compile time, it will search for and load the Resource File that contains the Resource ID / Resource Value pairs and will use the Resource Value in place of the Resource ID. Note that MAXScript will disregard matched files with a size of 0, and will continue searching as described below.

The search for the Resource File will be performed as follows:

  • The directory in which the script source file is stored will be scanned for the same file name as script file, but with the extension .RES. If the script is not saved in a file yet, a Compile error will be thrown.
  • If the Resource file was not found there, MAXScript will look for that filename in a subdirectory whose name is based on the ISO language/country name (for example, fr-FR)
  • If the file is still not found, MAXScript will look in the en-US subdirectory.
  • As result, if no localized version of the Resource file exists, the English Resource file will be used by default (if found).
  • If no matching Resource file could be found, a Compile error will be thrown.

Errors and warnings related to loading MacroScripts and especially issues with Resource IDs, Values and Files will be reported to the Scripting Listener.

Resource File Editing

Resource files (*.res) files are now supported in the Scripting Editor's File > Open and File > Save dialogs.

Was this information helpful?