System Information

The sysinfo struct provides several variables and methods related to accessing system information like system directories, system name, user, desktop size, and color depth as well as hardware-related data like CPU count and memory usage.

System Directories

sysInfo.windowsdir 

A read only variable containing the Windows directory as a <string> value.

sysInfo.systemdir 

A read only variable containing the Windows System directory as a <string> value.

sysInfo.tempdir 

A read only variable containing the Temp directory as a <string> value.

sysInfo.currentdir 

A variable to get/set the current directory as a <string> value.

The current directory is the directory MAXScript will look for files if no explicit path is specified, for example, in fileIn() calls. If a relative path is specified in such a call, it will be resolved relatively to the directory in sysInfo.currentdir .

As this variable can be read and written to, it effectively allows you to specify the current directory at any time before using relative paths or no explicit paths at all.

EXAMPLE

sysinfo.currentdir
-->"C:\Documents and Settings\username\My Documents\3dsmax\Scripts"

sysinfo.currentdir = "C:\\Temp"
-->"C:\Temp"

fileIn "test.ms" --this willloadthe scriptfromC:\Temp
-->OK

User and Computer Names:

sysInfo.username 

A read only variable containing the user name as a <string> value.

sysInfo.computername 

A read only variable containing the computer name as a <string> value.

EXAMPLE

currentUser = sysinfo.username + "@" + sysinfo.computername
"SonGoku@FlyingNimbus"

CPU and Desktop Info:

sysInfo.cpucount 

A read only variable containing the number of CPUs as an <integer> value.

sysInfo.desktopSize 

A read only system global variable that returns the Windows Desktop size in pixels as a Point2 value. Note that on dual monitor systems with the desktop set to stretch on both monitors, the desktop size returned will include the second monitor.

sysInfo.DesktopSizeUnscaled 

A read only system global variable that contains the unscaled Windows Desktop size in pixels as a Point2 value. Note that on dual monitor systems with the desktop set to stretch on both monitors, the desktop size returned will include the second monitor. Available in in 3ds Max 2017 and higher.

sysInfo.desktopBPP 

A read only system global variable. Returns the Windows Desktop color depth as an integer value in Bits Per Pixel. For example, if the graphics driver is set to 32 bit True Color, the value returned will be 32.

EXAMPLES

format "Your system has % CPUs (Cores)\n" sysinfo.cpucount
"Your system has 8 CPUs (Cores)"
format "Desktop: Scaled % / Unscaled % @ % bits per pixel\n" sysinfo.desktopSize sysinfo.DesktopSizeUnscaled sysinfo.desktopBPP
"Desktop: Scaled [1920,1080] / Unscaled [1920,1080] @ 32 bits per pixel"

3ds Max Process Priority and Affinity:

sysInfo.MAXPriority 

Gets/sets the 3ds Max process priority as a <name> value. Valid priority name values are #realtime, #high, #abovenormal, #normal, #belownormal, and #low.

Note: You need admin privileges to set #realtime. If you are not admin, setting #realtime will result in a setting of #high. Setting #realtime is not generally recommended, and is only appropriate for applications that talk directly to hardware.

There are also write-only priorities: #backgroundBegin and #backgroundEnd. In Windows 10, setting #backgroundBegin results in a reported priority of #low, and #backgroundEnd returns the process to its original priority, unless you were in #realTime, in which case the process remains in #low. In Windows 7, setting #backgroundBegin does not change the reported priority.

Available in 3ds Max 2017.1 Update and higher: #abovenormal, #belownormal, #backgroundBegin, #backgroundEnd, and #realtime.

For information about the corresponding system process priority levels, see the MSDN topic SetPriorityClass function.

EXAMPLE

(
current_priority = sysinfo.MAXpriority
priorities = #(#low,#belowNormal,#normal,#aboveNormal,#high,#realtime)
for p1 in priorities do 
(
sysinfo.MAXpriority = #normal
sysinfo.MAXpriority = p1
format "% : %\t" p1 sysinfo.MAXpriority
for p2 in priorities do 
(
sysinfo.MAXpriority = p2
format "\t%" sysinfo.MAXpriority
sysinfo.MAXpriority = p1
)
format "\n"
)
print "Priority Modifiers"
priority_modifiers = #(#backgroundBegin,#backgroundEnd)
for p1 in priorities do 
(
sysinfo.MAXpriority = #normal
sysinfo.MAXpriority = p1
format "% : %\t" p1 sysinfo.MAXpriority
for p2 in priority_modifiers do 
(
sysinfo.MAXpriority = p2
format "\t%" sysinfo.MAXpriority
)
format "\n"
)
sysinfo.MAXpriority = current_priority
ok
)
sysinfo.processAffinity 

Gets/sets the process affinity (the processors the process can use) as a pointer value. Each bit in the pointer value corresponds to a processor. If the bit is set, the process can use that processor.

Available in 3ds Max 2008 and higher. Previously, available in the Avguard Extensions.

sysinfo.systemAffinity 

A read-only property containing the system affinity (the processors present in the system) as a pointer. Each bit in the pointer corresponds to a processor. If the bit is set, the processor exists.

Available in 3ds Max 2008 and higher. Previously, available in the Avguard Extensions.

EXAMPLE

The following example shows how to get an array of existing processor or a bitarray with a bit set for each existing processor (core). In this example, the system has four cores.

--getting system affinity as a Pointer:
sysinfo.systemAffinity
-->15P

--getting system affinity as an array:
(for i = 1 to 32 where bit.get sysinfo.systemAffinity i collect i)
-->#(1,2,3,4)

--getting system affinity as a bitarray:
(for i = 1 to 32 where bit.get sysinfo.systemAffinity i collect i)as bitarray
-->#{1..4}

System Language and Locale:

sysinfo.getLanguage [user:<boolean>] 

This method returns the Windows OS Language as an array with three elements:

The first two elements are integer values that correspond to the Primary Language and SubLanguage IDs. See the Windows SDK Help file for documentation of these IDs.

The third element is a description script for the current language. Starting with 3ds Max 2010, if the language cannot be retrieved, the third element will contain an error string.

If the optional keyword user : is true (the default), the current user's language is returned. If false , the system's language is returned.

Available in 3ds Max 6 and higher.

sysinfo.getMaxLanguage() 

This method available in 3ds Max 2010 and higher returns the 3ds Max Language as an array such as #(9, 1, "ENU", "English (United States)", "en-US"). Starting in 3ds Max 2013 and higher, this method returns an array with five elements. Previous versions returned a four element array.

The first two elements are integer values that correspond to the Primary Language and SubLanguage IDs. See the Windows SDK Help file for documentation of these IDs.

The third element is the three letter code for the current language, for example "ENU" for US English.

The fourth element is the description string for the current 3ds Max language. If the description string cannot be retrieved, this element contains the value undefined.

The fifth element is the 3ds Max two letter localization code and country name code, in the form <language>-<country>, for example "en-US".

sysInfo.getDecimalChars()

Available in 3ds Max 2020.2 Update and higher: Returns and array containing the user locale decimal separator characters from the following locations:

  1. The OS user locale
  2. the C runtime locale
  3. The C++ runtime global locale
  4. The .NET runtime global locale

For example:

res = sysInfo.getDecimalChars()
--> #(".", ".", ".", ".")
Note: 3ds Max only reads the once locale on startup. Changing the locale or specifying a custom decimal separator while 3ds Max is running will cause this method to return the new character, but does not change the character 3ds Max uses until it re-starts.

Memory Usage and Max Process Info:

sysinfo.getSystemMemoryInfo() 

A method which returns a seven element array containing the system memory status data. The array elements contain the following respectively:

EXAMPLE

(
r=sysinfo.getSystemMemoryInfo()
for i=2 to 7 do r[i] /= (1024*1024.)
format "percent of memory in use:\t%\n" r[1]
format "total physical memory:\t% MB\n" r[2]
format "free physical memory:\t% MB\n" r[3]
format "used physical memory:\t% MB\n" (r[2]-r[3])
format "total paging file size:\t% MB\n" r[4]
format "free paging file size:\t% MB\n" r[5]
format "used paging file size:\t% MB\n" (r[4]-r[5])
format "total virtual memory:\t% MB\n" r[6]
format "free virtual memory:\t\t% MB\n" r[7]
format "used virtual memory:\t\t% MB\n" (r[6]-r[7])
ok
)

OUTPUT

percent of memory in use: 0
total physical memory: 255.359 MB
free physical memory: 16.5156 MB
used physical memory: 238.844 MB
total paging file size: 1016.3 MB
free paging file size: 757.898 MB
used paging file size: 258.398 MB
total virtual memory: 2047.88 MB
free virtual memory:  1846.55 MB
used virtual memory:  201.328 MB
OK
sysinfo.getMAXMemoryInfo() 

Returns a nine element array containing the 3ds Max memory status data. The array elements contain the following respectively:

EXAMPLE

(
r=sysinfo.getMAXMemoryInfo()
for i=2 to 9 do r[i] /= (1024*1024.)
format "Page Fault Count:\t\t\t%\n" r[1]
format "Peak Working Set Size:\t\t% MB\n" r[2]
format "Working Set Size:\t\t\t% MB\n" r[3]
format "Quota Peak Paged Pool Usage:\t% MB\n" r[4]
format "Quota Paged Pool Usage:\t\t% MB\n" r[5]
format "Quota Peak NonPaged Pool Usage:\t% MB\n" r[6]
format "Quota NonPaged Pool Usage:\t\t% MB\n" r[7]
format "Pagefile Usage:\t\t\t% MB\n" r[8]
format "Peak Pagefile Usage:\t\t\t% MB\n" r[9]
ok
)

OUTPUT

Page Fault Count:   32948
Peak Working Set Size:  70.3594 MB
Working Set Size:   70.3594 MB
Quota Peak Paged Pool Usage: 0.166186 MB
Quota Paged Pool Usage:  0.161236 MB
Quota Peak NonPaged Pool Usage: 0.0213509 MB
Quota NonPaged Pool Usage:  0.0213509 MB
Pagefile Usage:   58.9023 MB
Peak Pagefile Usage:   58.9219 MB
<int>sysinfo.getMAXHandleCount()
<int>sysinfo.getMAXUserObjectCount()
<int>sysinfo.getMAXGDIObjectCount()

These functions return the number of handles, user objects, and GDI objects held by the 3ds Max process. Available in 3ds Max 2019.3 Update and higher. This is the same information displayed in the Windows Task Manager on the Details tab.

<integer64>sysInfo.getMAXHeapUsed()

Returns the 3ds Max heap memory used, as an Integer64 value. Available in 3ds Max 2021 and higher.

3ds Max Command Line Info

<string>sysinfo.getCommandLine()

Returns the entire command line (including arguments) as a string. Available in 3ds Max 2019.2 Update and higher.

For example:

""C:\\Program Files\\Autodesk\\3ds Max 2019\\3dsmax.exe" -d -dfc -g -q"

<array>sysinfo.getCommandLineArgs() 

Returns an array of strings where each element is a command line argument. Available in 3ds Max 2019.2 Update and higher.

For example:

#("-d", "-dfc", "-g", "-q")