MAXScript Source Filename Access

These methods allow a script to query the source file it has been run from and the position inside the source file:

<filename>getSourceFileName()      

Returns the filename path of the source file the function has been called from.

Returns undefined if the call does not occur from a valid MAXScript file, for example if executed in the Listener.

Returns empty string or file path without a file name if called from an Untitled (not yet saved) file.

If the method has been called from inside a string evaluated using the execute() method, the result will still be the file the execute() has been called from.

Available in 3ds Max 9 and higher.

<filename>getThisScriptFilename()   

Returns the filename associated with the calling script. Same as getSourceFileName() , added mainly for backwards compatibility with pre-Max 9 scripts using the Avguard Extensions.

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

<integerPtr>getSourceFileOffSet() 

Returns the character position in the source script file, 'undefined' if not called from a source script file. The return value is IntegerPtr to ensure that the position would be valid even with files over 4GB.

Available in 3ds Max 9 and higher.

<integerPtr>getSourceFileLine() 

Returns the code line in the source script file, 'undefined' if not called from a source script file, for example if executed from the Listener.The return value is IntegerPtr to ensure that the line number would be valid even with files over 4GB.

Available in 3ds Max 2010 and higher.