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.

Topic Navigation:  

System Directories

User And Computer Names

CPU And Desktop Info

3dsMax Process Priority And Affinity

System Language

Memory Usage Info

 

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.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 has4CPUs (Cores)"
format "Desktop:%@% bits per pixel\n" sysinfo.desktopSize sysinfo.desktopBPP
"Dekstop: [1280,1024] @ 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 #high, #normal, and #low.

EXAMPLE

sysinfo.MAXPriority
#normal
sysinfo.MAXPriority = #low
#low
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:

sysinfo.getLanguage [user:<bool>] 

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 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 3ds Max language. If the language cannot be retrieved, the third element will contain an error string.

   

Memory Usage 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

See Also