Miscellaneous Functions

hasCurrentExceptionStackTrace()

NEW in 3ds Max 2017: Returns true if a MAXScript stack trace is available. It is only useful inside a catch statement - if used outside a catch, it will return false. It should always return true within a catch.

   

hasCurrentExceptionCallStack()

NEW in 3ds Max 2017: Returns true if a C++ stack trace is available. It is only useful inside a catch statement - if used outside a catch, it will return false. Within a catch, it will be true only if the exception that was caught was a system exception, such as an access violation or an integer divide by 0.

   

getCurrentExceptionCallStack()

NEW in 3ds Max 2017: Returns the C++ stack trace captured at the time an exception was thrown, as a string. It is only useful inside a catch statement - if used outside a catch, it will return 'undefined'. Within a catch, if the C++ stack trace was not captured, an empty string is returned.

   

CaptureCallStack [skipFirstNStackLevels:<int>]

NEW in 3ds Max 2017: Captures the MAXScript call stack. The skipFirstNStackLevels parameter defaults to 3 if not specified.

   

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:<bool> 

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 three integers like #(3000, 6, 0) with 3ds Max release number, max API number, revision number of the SDK.

   

getMaxExtensionVersion()

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

   

getMAXWindowSize() 

Returns the 3ds Max window size in pixels.

   

getMAXWindowPos() 

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.

   

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
<color>ConvertKelvinToRGB <float>Kelvin <float>scale 

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

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: