Share

3ds Max Configuration File 3dsmax.ini

Access to the 3ds Max configuration file 3dsmax.ini is provided through the cfgMgr struct.

The cfgMgr struct exposes these functions:

<string> cfgMgr.getIniFile()

Returns the full path of the 3ds Max INI file.

<array> cfgMgr.getAllSectionNames()

Returns an array of all the section names in the INI file.

cfgMgr.setSection <section_string>

Sets the current section to the specified name. Note that this function will create a new section with the specified name if the section name does not exist. The other get/set/delete functions in cfgMgr operate on the currently set section.

<string> cfgMgr.getSectionName()

Gets the current section name, either the last section read, or a section set by setSection(). Other get/set/delete functions operate on the current section.

<boolean> cfgMgr.sectionExists <section_string>

Returns true if the specified section exists already in the INI file, false otherwise. Note that the section name matching is not case sensitive.

<boolean> cfgMgr.deleteSection <section_string>

Deletes the specified section.

This function always returns true.

[<array>|undefined] cfgMgr.getSectionKeyNames()

Gets an array of key names for the current section.

<boolean> cfgMgr.keyExists <key_string>

Returns true if the specified key exists in the current section, false otherwise.

<boolean> cfgMgr.deleteKey <key_string>

Deletes the specified key.

This function always returns true.

<boolean> cfgMgr.putString <key_string> <string>

Writes the specified string value to the specified key, where the first parameter is the key name, and the second parameter is the value.

This function always returns true.

<boolean> cfgMgr.putFloat <key_string> <float>

Writes the specified float value to the specified key.

This function always returns true.

<boolean> cfgMgr.putInt <key_string> <int> useULong:<false>

Writes the specified integer value to the specified key. The optional useULong parameter is for internal use only.

This function always returns true.

<boolean> cfgMgr.putFloatArray <key_string> <float array>

Writes the specified array of floats to the specified key.

This function always returns true.

<boolean> cfgMgr.putIntArray <key_string> <int array> useULong:<false>

Writes the specified array of integers to the specified key. The optional useULong parameter is for internal use only.

This function always returns true.

[<string>|undefined] cfgMgr.getString <key_string>

Returns the value of the specified key as a string if the key exists, or as undefined if it does not.

[<float>|undefined] cfgMgr.getFloat <key_string>

Returns the value of the specified key as a float if the key exists, or as undefined if it does not. If the key contains an array, the first value is coerced to a float and returned. If the key contains character data, a value of 0.0 is returned.

[<int>|undefined] cfgMgr.getInt <key_string> useULong:<false>

Returns the value of the specified key as an integer if the key exists, or as undefined if it does not. If the key contains a float value, it is coerced to an integer before it is returned. If it contains character data, a value of 0 is returned. If the key contains an array, the first value is coerced to an integer and returned.

[<float array>|undefined] cfgMgr.getFloatArray <key_string>

Returns an array of floats for the specified key, if it exists, or undefined if it does not.

Do not call this function on a key that contains anything other than an array of floats.

[<int array>|undefined] cfgMgr.getIntArray <key_string> useULong:<false>

Returns an array of integers for the specified key, if it exists, or undefined if it does not.

For Example

-- get ini file path:
cfgMgr.getIniFile()
--> "C:\[path_to_ini_file]\3dsMax.ini"

-- get all the sections:
cfgMgr.getAllSectionNames()

-- create a new section for the demo:
cfgMgr.setSection "CFGMGR TEST"

-- confirm this is the active section:
cfgMgr.getSectionName()
--> "CFGMGR TEST"

cfgMgr.sectionExists "CFGMGR TEST"
--> false
-- returns false until the section contains keys

cfgMgr.putString "MyStringKey" "Hello this is a string"
cfgMgr.putFloat "MyFloatKey" 3.41
cfgMgr.putInt "MyIntKey" 42
cfgMgr.putFloatArray "MyFloatArrayKey" #(2.2,3.3,4.4)
cfgMgr.putIntArray "MyIntArrayKey" #(7,6,5,4,3)

/* At this point the config file contains:
[CFGMGR TEST]
MyStringKey=Hello this is a string
MyFloatKey=3.410000
MyIntKey=42
MyFloatArrayKey=2.200000 3.300000 4.400000
MyIntArrayKey=7 6 5 4 3
*/

-- you typically do not want to do these things, but they work:
cfgMgr.getFloat "MyIntKey"
--> 42.0
cfgMgr.getInt "MyIntArrayKey"
--> 7
cfgMgr.getString "MyFloatKey"
--> "3.410000"

-- does not work, don't do it:
-- cfgMgr.getFloatArray "MyStringKey"
-- nor this: 
-- cfgMgr.getIntArray "MyFloatArrayKey"

-- but this is ok:
cfgMgr.getFloatArray "MyIntArrayKey"
--> #(7.0, 6.0, 5.0, 4.0, 3.0)

-- cleanup, section/key names are not case-sensitve:
cfgMgr.deleteSection "Cfgmgr Test"

Was this information helpful?