3ds Max C++ API Reference
MAXScript Namespace Reference

Enumerations

enum class  ScriptSource : int { NotSpecified , Embedded , NonEmbedded , Dynamic }
 

Functions

ScripterExport int GetUIScaledValue (float value)
 
ScripterExport int GetValueUIUnscaled (float value)
 
ScripterExport float GetUIScaledValueFloat (float value)
 
ScripterExport float GetValueUIUnscaledFloat (float value)
 
ScripterExport bool SetMAXScriptListenerLogFile (const MCHAR *filename, const MCHAR *mode)
 Sets MAXScript listener log file to specified file. More...
 
ScripterExport bool GetMAXScriptListenerLogFile (MSTR &listenerLogFileName)
 Gets the MAXScript listener log file name if present. More...
 
ScripterExport bool CanRunScriptingFeature (MaxSDK::ISceneScriptSecurityManager::ScriptingFeature scriptingFeature)
 Test whether the specified ScriptingFeature can be executed. More...
 
ScripterExport void ValidateCanRunMAXScriptSystemCommand (const MCHAR *command, Value **arg_list, int count)
 Validate whether MAXScript system commands can be executed. More...
 
ScripterExport void ValidateCanRunMAXScriptSystemCommand (const MCHAR *command, const MCHAR *arguments)
 Validate whether MAXScript system commands can be executed. More...
 
ScripterExport void ValidateCanRunPythonScripts (const MCHAR *command, Value **arg_list, int count)
 Validate whether Python scripts can be executed. More...
 
ScripterExport void ValidateCanRunPythonScripts (const MCHAR *command, const MCHAR *arguments)
 Validate whether Python scripts can be executed. More...
 
ScripterExport MSTR CreateStringRepresentationOfArgumentList (Value **arg_list, int count)
 Create string representation of argument list. More...
 

Enumeration Type Documentation

◆ ScriptSource

enum ScriptSource : int
strong
Enumerator
NotSpecified 

source of the script was not specified; same security rights as for Embedded scripts will apply

Embedded 

source of the script was a scene file (i.e., a scene file embedded script), security rights dependent on Safe Scene Script Execution settings

NonEmbedded 

source of the script was not a scene file, full security rights, i.e.

no security restrictions.

Dynamic 

the script is dynamically generated at runtime and could contain input from various sources that are interpreted as scripted commands.

Therefore dynamic scripts will always execute with restricted security rights, regardless of Safe Scene Script Execution settings

25  {
26  NotSpecified,
27  Embedded,
28  NonEmbedded,
29  Dynamic
30  };
@ Embedded
source of the script was a scene file (i.e., a scene file embedded script), security rights dependent...
@ NotSpecified
source of the script was not specified; same security rights as for Embedded scripts will apply
@ Dynamic
the script is dynamically generated at runtime and could contain input from various sources that are ...
@ NonEmbedded
source of the script was not a scene file, full security rights, i.e.

Function Documentation

◆ GetUIScaledValue()

ScripterExport int MAXScript::GetUIScaledValue ( float  value)

◆ GetValueUIUnscaled()

ScripterExport int MAXScript::GetValueUIUnscaled ( float  value)

◆ GetUIScaledValueFloat()

ScripterExport float MAXScript::GetUIScaledValueFloat ( float  value)

◆ GetValueUIUnscaledFloat()

ScripterExport float MAXScript::GetValueUIUnscaledFloat ( float  value)

◆ SetMAXScriptListenerLogFile()

ScripterExport bool MAXScript::SetMAXScriptListenerLogFile ( const MCHAR filename,
const MCHAR mode 
)

Sets MAXScript listener log file to specified file.

Parameters
[in]filename- The fully qualified path for the listener log file
[in]mode- The file open mode specification, typically "w" or "a". See the MAXScript Help file, topic FileStream Values, for a description of the mode string values. Note that this method automatically adds 't' to the specified mode string.
Returns
- true if the listener log file was created, false otherwise.

◆ GetMAXScriptListenerLogFile()

ScripterExport bool MAXScript::GetMAXScriptListenerLogFile ( MSTR listenerLogFileName)

Gets the MAXScript listener log file name if present.

Parameters
[out]listenerLogFileName- Returns the fully qualified path for the listener log file
Returns
- true if a listener log file name was acquired, false otherwise.

◆ CanRunScriptingFeature()

ScripterExport bool MAXScript::CanRunScriptingFeature ( MaxSDK::ISceneScriptSecurityManager::ScriptingFeature  scriptingFeature)

Test whether the specified ScriptingFeature can be executed.

This function checks to see whether the specified ScriptingFeature can be executed. The specified ScriptingFeature is disabled in the following cases:

  1. When MAXScript is executing a scene file embedded script, Safe Scene Script Execution Mode is enabled in ISceneScriptSecurityManager, and the specified ScriptingFeature in embedded scripts is disabled in ISceneScriptSecurityManager.
  2. When MAXScript is executing a dynamic script, which can be embedded in a scene file or not.
  3. When 3ds Max is running in SecureMode.
    Parameters
    [in]scriptingFeature- The ScriptingFeature.
    Returns
    - true if commands associated with the specified ScriptingFeature can be executed, false otherwise.
    See also
    MAXScript::ScriptSource

◆ ValidateCanRunMAXScriptSystemCommand() [1/2]

ScripterExport void MAXScript::ValidateCanRunMAXScriptSystemCommand ( const MCHAR command,
Value **  arg_list,
int  count 
)

Validate whether MAXScript system commands can be executed.

This function checks to see whether MAXScript system commands can be executed, and if not throws an exception. MAXScript system command execution is disabled in the following cases:

  1. When MAXScript is executing a scene file embedded script, Safe Scene Script Execution Mode is enabled in ISceneScriptSecurityManager, and MAXScript System Commands in embedded scripts is disabled in ISceneScriptSecurityManager. If this is the case, a SecurityException exception is thrown.
  2. When MAXScript is executing a dynamic script, which can be embedded in a scene file or not. If this is the case, a SecurityException exception is thrown.
  3. When 3ds Max is running in SecureMode. If this is the case, a RuntimeError exception is thrown. This function should be called from the code that implements the MAXScript command in question. This override of the function would be used when the code is a standard MAXScript primitive implementation. For example:
    Value* set_file_attribute_cf(Value** arg_list, int count)
    {
    check_arg_count(setFileAttribute, 3, count);
    MAXScript::ValidateCanRunMAXScriptSystemCommand(_T("setFileAttribute"), arg_list, count);
    ...
    Definition: value.h:107
    #define check_arg_count(fn, w, g)
    Definition: maxscript.h:188
    ScripterExport void ValidateCanRunMAXScriptSystemCommand(const MCHAR *command, Value **arg_list, int count)
    Validate whether MAXScript system commands can be executed.
    If MAXScript system commands can not be executed, the arguments in arg_list are converted to their string representation and are appended to the command name for error reporting purposes by 3ds Max.
    Parameters
    [in]command- The name of the MAXScript system command. Note that this name is used only for error reporting purposes by 3ds Max.
    [in]arg_list- The list of arguments to the command.
    [in]count- The count of arguments in arg_list.
    See also
    MAXScript::ScriptSource

◆ ValidateCanRunMAXScriptSystemCommand() [2/2]

ScripterExport void MAXScript::ValidateCanRunMAXScriptSystemCommand ( const MCHAR command,
const MCHAR arguments 
)

Validate whether MAXScript system commands can be executed.

This function checks to see whether MAXScript system commands can be executed, and if not throws an exception. MAXScript system command execution is disabled in the following cases:

  1. When MAXScript is executing a scene file embedded script, Safe Scene Script Execution Mode is enabled in ISceneScriptSecurityManager, and MAXScript System Commands in embedded scripts is disabled in ISceneScriptSecurityManager. If this is the case, a SecurityException exception is thrown.
  2. When MAXScript is executing a dynamic script, which can be embedded in a scene file or not. If this is the case, a SecurityException exception is thrown.
  3. When 3ds Max is running in SecureMode. If this is the case, a RuntimeError exception is thrown. This function should be called from the code that implements the MAXScript command in question. This override of the function would be used when the code is not a standard MAXScript primitive implementation, and the string representation of the argument list is manually constructed. For example:
    MAXScript::ValidateCanRunMAXScriptSystemCommand(_T("executeScriptFile"), TSTR(_T("\"")) + filename + _T("\""));
    #define TSTR
    Definition: strclass.h:1054
    If MAXScript system commands can not be executed, the arguments string is appended to the command name for error reporting purposes by 3ds Max.
    Parameters
    [in]command- The name of the MAXScript system command. Note that this name is used only for error reporting purposes by 3ds Max.
    [in]arguments- A string representation of the list of arguments to the command. Note that this value can be nullptr.
    See also
    MAXScript::ScriptSource

◆ ValidateCanRunPythonScripts() [1/2]

ScripterExport void MAXScript::ValidateCanRunPythonScripts ( const MCHAR command,
Value **  arg_list,
int  count 
)

Validate whether Python scripts can be executed.

This function checks to see whether Python scripts can be executed, and if not throws an exception. Python script execution through the python MAXScript interface is disabled in the following cases:

  1. When the script is embedded in a scene file, Safe Scene Script Execution Mode is enabled in ISceneScriptSecurityManager, and Python script execution in embedded scripts is disabled in ISceneScriptSecurityManager. If this is the case, a SecurityException exception is thrown.
  2. When MAXScript is executing a dynamic script, which can be embedded in a scene file or not. If this is the case, a SecurityException exception is thrown.
  3. When 3ds Max is running in SecureMode. If this is the case, a RuntimeError exception is thrown. This function should be called from the code that attempts to run Python scripts. This override of the function would be used when the code is a standard MAXScript primitive implementation. For example:
    Value* execute_python_script_cf(Value** arg_list, int count)
    {
    check_arg_count(executePythonScript, 3, count);
    MAXScript::ValidateCanRunPythonScripts(_T("executePythonScript"), arg_list, count);
    ...
    ScripterExport void ValidateCanRunPythonScripts(const MCHAR *command, Value **arg_list, int count)
    Validate whether Python scripts can be executed.
    If Python scripts can not be executed, the arguments in arg_list are converted to their string representation and are appended to the command name for error reporting purposes by 3ds Max.
    Parameters
    [in]command- The name of the Python script execution command. Note that this name is used only for error reporting purposes by 3ds Max.
    [in]arg_list- The list of arguments to the command.
    [in]count- The count of arguments in arg_list.
    See also
    MAXScript::ScriptSource

◆ ValidateCanRunPythonScripts() [2/2]

ScripterExport void MAXScript::ValidateCanRunPythonScripts ( const MCHAR command,
const MCHAR arguments 
)

Validate whether Python scripts can be executed.

This function checks to see whether Python scripts can be executed, and if not throws an exception. Python script execution through the python MAXScript interface is disabled in the following cases:

  1. When the script is embedded in a scene file, Safe Scene Script Execution Mode is enabled in ISceneScriptSecurityManager, and Python script execution in embedded scripts is disabled in ISceneScriptSecurityManager. If this is the case, a SecurityException exception is thrown.
  2. When MAXScript is executing a dynamic script, which can be embedded in a scene file or not. If this is the case, a SecurityException exception is thrown.
  3. When 3ds Max is running in SecureMode. If this is the case, a RuntimeError exception is thrown. This function should be called from the code that attempts to run Python scripts. This override of the function would be used when the code is not a standard MAXScript primitive implementation, and the string representation of the argument list is manually constructed. For example:
    MAXScript::ValidateCanRunPythonScripts(_T("executePythonScript"), TSTR(_T("\"")) + pythonScript + _T("\""));
    If Python scripts can not be executed, the arguments string is appended to the command name for error reporting purposes by 3ds Max.
    Parameters
    [in]command- The name of the Python script execution command. Note that this name is used only for error reporting purposes by 3ds Max.
    [in]arguments- A string representation of the list of arguments to the command. Note that this value can be nullptr.
    See also
    MAXScript::ScriptSource

◆ CreateStringRepresentationOfArgumentList()

ScripterExport MSTR MAXScript::CreateStringRepresentationOfArgumentList ( Value **  arg_list,
int  count 
)

Create string representation of argument list.

This function creates a string representation of the specified argument list. Note that this can be a fairly expensive call, and should only be called when necessary. This function would be typically be used in code that is a standard MAXScript primitive implementation. For example:

Value* dotNet_loadAssembly_cf(Value** arg_list, int count)
{
check_arg_count_with_keys(dotNet.loadAssembly, 1, count);
if (!MAXScript::CanRunScriptingFeature(MaxSDK::ISceneScriptSecurityManager::ScriptingFeature::DotNet))
{
TSTR msg = _T("dotNet.loadAssembly ");
msg.append(args);
static MaxSDK::ISceneScriptSecurityManager* spISceneScriptSecurityManager =
MaxSDK::ISceneScriptSecurityManager::ScriptingFeature::MAXScriptSystemCommands);
...
ScripterExport int thread_locals_index
Interface class for the Scene Script Security Manager.
Definition: ISceneScriptSecurityManager.h:26
virtual void LogBlockedCommand(const MSTR &nameOfBlockedCommand, ScriptingFeature feature)=0
Logs a message in the Security Messages window that notifies the user when a command from a scene scr...
static DllExport ISceneScriptSecurityManager * GetInstance()
Returns the only instance of this manager.
#define check_arg_count_with_keys(fn, w, g)
Definition: maxscript.h:190
ScripterExport MSTR CreateStringRepresentationOfArgumentList(Value **arg_list, int count)
Create string representation of argument list.
ScripterExport bool CanRunScriptingFeature(MaxSDK::ISceneScriptSecurityManager::ScriptingFeature scriptingFeature)
Test whether the specified ScriptingFeature can be executed.
Definition: MAXScript_TLS.h:34
Parameters
[in]arg_list- The list of arguments.
[in]count- The count of arguments in arg_list.