Miscellaneous Functions

freeSceneBitmaps()      

Frees up all the memory used by the image file bitmap caches. This is useful if memory is fragmented with a lot of different bitmaps and you want to have just the ones currently active reloaded.

rescaleWorldUnits <factor> [ #selOnly ]   

This method provides functionality similar to that of Rescale World Utility plug-in in 3ds Max. <factor> is the factor the objects should be scaled by. If #selOnly is specified then only the selected objects are scaled.

IsNetServer() 

Returns true if 3ds Max is operating in network rendering mode and false if operating in normal interactive mode.

loadDllsFromDir <directory_path_string> <filename_wildcard_string> 

Load all the plug-ins found in the specified directory. The directory_path_string must be terminated with a '\'.

EXAMPLE

LoadDllsFromDir "f:\\maxsdk\\plugin\\" "*.dlc"
scanForNewPlugins includeUnknownSuperclasses:<boolean> 

Scans for new plug-in classes and exposes the classes to MAXScript. Typically called after calling loadDllsFromDir() .

If includeUnknownSuperclasses: is false (the default), classes with unknown superclasses are ignored.

Available in 3ds Max 2008 and higher. Previously available via the [AVG] DLX Extension.

maxVersion() 

Returns an Array with nine items such as #(21000, 52, 0, 21, 2, 0, 2112, 2019, ".2 Update"), where the first three numbers are the 3ds Max release number, API version, and revision number of the SDK.

The next four numbers represent the major version, the update version, the hotfix number, and the build number. Available in 3ds Max 2019.1 Update and higher. These match the results of SystemTools.GetBuildNumber(), and the version displayed on the Help > Autodesk Product Information > About 3ds Max dialog.

The last two items represent the product year (an integer) and the product version description as a string. Available in 3ds Max 2019.2 Update and higher. This string is empty for the main release, and populated for update releases, security fixes, and hot fixes. These two items are concatenated and displayed as "Product Version" in the Help > Autodesk Product Information > About 3ds Max dialog.

getMaxExtensionVersion()

Available in in 3ds Max 2016 Extension 1 and higher: Returns an integer indicating the 3ds Max Extension version, or 0 if it is not an Extension.

getMAXWindowSize [ removeUIScaling:<true> ] 

Returns the 3ds Max window size in pixels.

The optional removeUIScaling parameter indicates whether to remove scaling on high-DPI displays.

getMAXWindowPos [ removeUIScaling:<true> ] 

Returns the 3ds Max window position in pixels relative to the upper left corner of the desktop. Returns [-4,-4] when the application is maximized.

The optional removeUIScaling parameter indicates whether to remove scaling on high-DPI displays.

<boolean> getMaxscriptStartupState (#stdScriptsLoading | #stdScriptsLoaded | #startupScriptsLoading | #startupScriptsLoaded)

Returns true if the specified startup state is true. Available in 3ds Max 2019.2 Update and higher. For example, getMaxscriptStartupState #stdScriptsLoading will only return true while the standard scripts are being loaded. After the standard scripts are loaded, getMaxscriptStartupState #stdScriptsLoaded returns true.

<enum>getCurrentScriptSourceType()

Returns the script source type, which determines how it is handled by the Safe Scene Script Execution feature. Returned values can be:

generateAPIList (<StringStream> | <FileStream> | <WindowStream>) [ caseSensitiveSort:<boolean> ] 

Generates sorted list of MAXScript keywords. This is the same list used by the Scripting Editor for auto-completion. Available in 3ds Max 2020.1 Update and higher.

If the caseSensitveSort argument is specified as true (the default), the ASCII order of characters is used, so all capitals occur before lower case, ABCabc. If false, capitalization is ignored, and keywords are sorted AaBbCc.

This list could be saved to a file and used for MAXScript support in an external editor. You can create such a list with the following example:

apifile = undefined
try
(
  apifile = openFile @"c:\maxscript.api" mode:"w"
  generateAPIList apifile
  close apifile
)
catch -- mainly in case file cannot be opened with write access
(
  if apifile != undefined do close apifile
) 
swap <destination> <destination> 

Takes two valid assignment destinations (property, array index, or variable) as arguments and swaps their values.

EXAMPLE

swap myMaterial.diffuseMap.map1 myMaterial.diffuseMap.map2
<controller>createFloatControllerWithRandomValues <min time> <max time> <delta time> <min value> <max value>

Creates a float controller that contains keys over the specified range of time with the specified time steps with random values in the specified range. Useful for testing where you need massive scenes with random data.

Available in 3ds Max 2019.1 Update and higher.

<color>ConvertKelvinToRGB <float>Kelvin <float>scale 

Returns the blackbody radiation color corresponding to the temperature in Kelvin specified by the first argument. The second argument scales the color output. Available in in 3ds Max 2017 and higher.

A value of 6,500 K produces white color [255,255,255] at Scale of 1.0, or equal R,G and B values at any other Scale

EXAMPLE

(
     global Kelvin2RGBExplorerRollout
     try(destroyDialog Kelvin2RGBExplorerRollout)catch()

     rollout Kelvin2RGBExplorerRollout "Kelvin To RGB Explorer"
     (
           local theGradient = bitmap 600 50
           local theGradient2 = bitmap 600 1
           local theColorArray = #()
           local theKelvinArray = #()

           button btn_fromPreset1 "100" width:50 across:8 align:#left
           button btn_fromPreset2 "1,000" width:50 align:#left offset:[-20,0]
           button btn_fromPreset3 "1,500" width:50 align:#left offset:[-40,0]
           button btn_fromPreset4 "2,500" width:50 align:#left offset:[-60,0]
           button btn_fromPreset5 "5,000" width:50 align:#left offset:[-80,0]
           button btn_fromPreset6 "6,500" width:50 align:#left offset:[-100,0]
           button btn_fromPreset7 "10,000" width:50 align:#left offset:[-120,0]
           spinner spn_fromKelvin "Start Temperature In Kelvin:" range:[0.01,10000000,100] fieldwidth:50 align:#right

           button btn_toPreset1 "100" width:50 across:8 align:#left
           button btn_toPreset2 "1,000" width:50 align:#left offset:[-20,0]
           button btn_toPreset3 "1,500" width:50 align:#left offset:[-40,0]
           button btn_toPreset4 "2,500" width:50 align:#left offset:[-60,0]
           button btn_toPreset5 "5,000" width:50 align:#left offset:[-80,0]
           button btn_toPreset6 "6,500" width:50 align:#left offset:[-100,0]
           button btn_toPreset7 "10,000" width:50 align:#left offset:[-120,0]
           spinner spn_toKelvin "End Temperature In Kelvin:" range:[0.01,10000000,10000] fieldwidth:50 align:#right

           progressbar prg_scale height:15 width:480 align:#left across:2 offset:[0,0] value:100.0 color:green
           spinner spn_scale "Scale:" range:[0.01,1.0,1.0] scale:0.01 fieldwidth:50 align:#right

           bitmap bmp_gradient width:600 height:50 align:#center

           edittext edt_Kvalue "Kelvin:" across:4 fieldwidth:100 align:#left
           edittext edt_Rvalue "R:"  fieldwidth:120 align:#center
           edittext edt_Gvalue "G:"  fieldwidth:120 align:#center
           edittext edt_Bvalue "B:"  fieldwidth:120 align:#right

           fn convertKelvin2RGB =
           (
                theColorArray = #()
                theKelvinArray = #()
                local theColorScale = spn_scale.value
                local currentValue = spn_fromKelvin.value
                local increment = (spn_toKelvin.value-spn_fromKelvin.value)/599.0
                for k = 1 to 600 do
                (
                     append theColorArray (ConvertKelvinToRGB currentValue theColorScale)
                     append theKelvinArray currentValue
                     currentValue+= increment
                )
                setPixels theGradient2 [0,0] theColorArray
                copy theGradient2 theGradient
                bmp_gradient.bitmap = theGradient
           )

           on spn_fromKelvin changed val do
           (
                if val > spn_toKelvin.value do spn_toKelvin.value = val
                convertKelvin2RGB()
           )
           on spn_toKelvin changed val do
           (
                if val < spn_fromKelvin.value do spn_fromKelvin.value = val
                convertKelvin2RGB()
           )

           on prg_scale clicked val do
           (
                if val < 1 do val = 1
                prg_scale.value = val
                spn_scale.changed (spn_scale.value = val/100.0)
           )

           on btn_fromPreset1 pressed do ( spn_fromKelvin.changed (spn_fromKelvin.value = 100))
           on btn_fromPreset2 pressed do ( spn_fromKelvin.changed (spn_fromKelvin.value = 1000))
           on btn_fromPreset3 pressed do ( spn_fromKelvin.changed (spn_fromKelvin.value = 1500))
           on btn_fromPreset4 pressed do ( spn_fromKelvin.changed (spn_fromKelvin.value = 2500))
           on btn_fromPreset5 pressed do ( spn_fromKelvin.changed (spn_fromKelvin.value = 5000))
           on btn_fromPreset6 pressed do ( spn_fromKelvin.changed (spn_fromKelvin.value = 6500))
           on btn_fromPreset7 pressed do ( spn_fromKelvin.changed (spn_fromKelvin.value = 10000))

           on btn_toPreset1 pressed do ( spn_toKelvin.changed (spn_toKelvin.value = 100))
           on btn_toPreset2 pressed do ( spn_toKelvin.changed (spn_toKelvin.value = 1000))
           on btn_toPreset3 pressed do ( spn_toKelvin.changed (spn_toKelvin.value = 1500))
           on btn_toPreset4 pressed do ( spn_toKelvin.changed (spn_toKelvin.value = 2500))
           on btn_toPreset5 pressed do ( spn_toKelvin.changed (spn_toKelvin.value = 5000))
           on btn_toPreset6 pressed do ( spn_toKelvin.changed (spn_toKelvin.value = 6500))
           on btn_toPreset7 pressed do ( spn_toKelvin.changed (spn_toKelvin.value = 10000))

           on spn_scale changed val do
           (
                prg_scale.value = val*100.0
                convertKelvin2RGB()
           )

           on Kelvin2RGBExplorerRollout mousemove pos do
           (
                if pos.x >= bmp_gradient.pos.x and pos.x <= bmp_gradient.pos.x+601 and pos.y >= bmp_gradient.pos.y and pos.y <= bmp_gradient.pos.y+50 do
                (
                     theSample = pos.x-10
                     if theSample < 1 do theSample = 1
                     if theSample > 600 do theSample = 600
                     edt_Kvalue.text = theKelvinArray[theSample] as string
                     edt_Rvalue.text = theColorArray[theSample].r as string
                     edt_Gvalue.text = theColorArray[theSample].g as string
                     edt_Bvalue.text = theColorArray[theSample].b as string
                )
           )

           on Kelvin2RGBExplorerRollout open do convertKelvin2RGB()
     )
     createDialog Kelvin2RGBExplorerRollout 620 160
)

This script produces a rollout that looks like this:

setNumberThreads <int>ThreadType <int>maxNumThreads <int>minElementsPerThread

Sets the number of threads for various parts of 3ds Max.

ThreadType can be:

0 - Mesh Threading - used to for some mesh operations like building normals, clip operations, vector normalization, etc 1 - Deformation Threading - used by modifiers like bend, skin, skinwrap, etc 2 - Mesh Creation Threading - the number of threads used to create DirectX hardware meshes

maxNumThreads is the maximum number of threads to use for the operation, though it is not limited and can be larger than the number of CPUs available.

minElementsPerThread is used to restrict the number of threads by specifying a minimum number of elements to assign to a thread, depending on the thread type. For example for Mesh Creation Threading, the elements are the number of faces/vertices per thread. Set to 0 to ignore this value.