Skip to main content

optiSLang 3D Postprocessing Script API 2025 R1

Miscellaneous

Last update: 16.07.2025

Classes

class  RealList
 a convenience class for Lua (std::list<number>) More...
 

Functions

string currentScriptPath ()
 Determines the current directory of the the currently running script file. More...
 
 loadMacros (macro::MacroManager macroManager)
 Load macros stored at the MacroManager. Loaded macros are callable functions in SoS script context. Loaded macros are stored in the sos_macros Lua table. Example call: More...
 
 loadMacros ()
 Load macros stored at the MacroManager of the current sos.database(). Loaded macros are callable functions in SoS script context. Loaded macros are stored in the sos_macros Lua table. Example call: More...
 
 log (string message)
 Issues an info log message. More...
 
 log (number level, string message)
 Issues a log message to the SoS logger. More...
 
 setLogLevel (number level=3, int log_id=-1)
 sets the verbose level of the logger More...
 
 setMaxNumThreads (number numthreads)
 Sets the maximum number of threads used in OpenMP. More...
 
bool useCommandLogFile (bool usage=true)
 Controls the usage of SoS's command log file. More...
 

Detailed Description

Function Documentation

◆ currentScriptPath()

string currentScriptPath ( )

Determines the current directory of the the currently running script file.

The method uses the global interpreter() function to access the Lua state.

Returns
The current directory of the script being processed at the moment.
Exceptions
Anexception if the current script is not a file

◆ loadMacros() [1/2]

loadMacros ( macro::MacroManager  macroManager)

Load macros stored at the MacroManager. Loaded macros are callable functions in SoS script context. Loaded macros are stored in the sos_macros Lua table. Example call:

sos_macros.getNodeMin(sos.database(), "1", 'TEMP', 'min[TEMP]')

Parameters
macroManagerA reference to the MacroManager. All the macroManager's macros are loaded.

◆ loadMacros() [2/2]

loadMacros ( )

Load macros stored at the MacroManager of the current sos.database(). Loaded macros are callable functions in SoS script context. Loaded macros are stored in the sos_macros Lua table. Example call:

sos_macros.getNodeMin(sos.database(), "1", 'TEMP', 'min[TEMP]')

◆ log() [1/2]

log ( string  message)

Issues an info log message.

Parameters
messageThe info log message

◆ log() [2/2]

log ( number  level,
string  message 
)

Issues a log message to the SoS logger.

Parameters
levelDefines the log level. Accepts values between [1-5] as well as their corresponding enum values
  • 1 / logger.ERROR .. error
  • 2 / logger.WARNING .. warning
  • 3 / logger.INFO .. info
  • 4 / logger.DEBUG .. debug
  • 5 / logger.TRACE .. trace
messageThe log message itself
Exceptions
Incase of unknown log level

◆ setLogLevel()

setLogLevel ( number  level = 3,
int  log_id = -1 
)

sets the verbose level of the logger

Parameters
leveldefines the new log level
log_idGives the Id of the logger to set the level for. If omitted all loggers maintained get the same level The following levels exist:
  • 0 .. no output
  • 1 .. only errors
  • 2 .. like 1 + warnings
  • 3 .. like 2 + info (default)
  • 4 .. like 3 + debug info
  • 5 .. like 4 + trace info

◆ setMaxNumThreads()

setMaxNumThreads ( number  numthreads)

Sets the maximum number of threads used in OpenMP.

Parameters
numthreadsthe number of threads
Note
Does not have any action if OpenMP is disabled.

◆ useCommandLogFile()

bool useCommandLogFile ( bool  usage = true)

Controls the usage of SoS's command log file.

Parameters
usageSet to true (default) if a command log file is desired. False otherwise
Returns
The previous state
Note
The command log file will be updated each time the lua interpreter is about to start the execution of a new line of code. This means the physical command log file will be rewritten for EACH LINE! In consequence, at least if there is any change that your loop might get huge for some input, you're strongly advised to switch command log file support off immediately before entering the loop and to reanable it afterwards

Connect with Ansys