User Tools

Site Tools


Global

Global objects, methods, variables and constants available to all scripts via the global namespace.

More...

Properties

Methods

ECMAScript
StringdecodeURI ( String encodedURI )
StringdecodeURIComponent ( String encodedURIComponent )
StringencodeURI ( String uri )
StringencodeURIComponent ( String uriComponent )
Objecteval ( String str )
BooleanisFinite ( Object expression )
BooleanisNaN ( Object expression )
NumberparseFloat ( String str )
NumberparseInt ( String str, Number radix )
QtScript
voidgc ()
voidprint ( String expression )
StringqsTr ( String sourceText )
StringqsTranslate ( String sourceText )
StringqsTrId ( String id )
DAZ Script
voidacceptUndo ( String caption )
BooleanbackgroundProgressIsActive ()
BooleanbackgroundProgressIsCancelled ()
voidbeginNodeSelectionHold ()
voidbeginUndo ()
voidcancelUndo ()
voidclearBusyCursor ()
voidclearNodeSelectionHolds ()
voidclearUndoStack ()
voidconnect ( Object sender, String signal, Object receiver, String function )
voidconnect ( Object sender, String signal, Object thisObject, Function functionRef )
voidconnect ( Object sender, String signal, Function functionRef )
voiddebug ( expression )
voiddisconnect ( Object sender, String signal, Object receiver, String function )
voiddisconnect ( Object sender, String signal, Object thisObject, Function functionRef )
voiddisconnect ( Object sender, String signal, Function functionRef )
voiddropNodeSelectionHold ()
voiddropUndo ()
voidfinishBackgroundProgress ()
voidfinishProgress ()
ArraygetArguments ()
StringgetErrorMessage ( DzError errCode )
QObjectgetObjectParent ( QObject obj )
DzAuthorgetScriptAuthor ()
StringgetScriptFileName ()
StringgetScriptType ()
StringgetScriptVersionString ()
voidinclude ( String scriptPath )
BooleanpointersAreEqual ( QObject ptr1, QObject ptr2 )
voidprocessEvents ()
BooleanprogressIsActive ()
BooleanprogressIsCancelled ()
voidrestoreNodeSelectionHold ()
voidsetBusyCursor ()
voidsleep ( Number milliseconds )
voidstartBackgroundProgress ( String info, Number totalSteps=0, Boolean isCancellable=false )
voidstartProgress ( String info, Number totalSteps=0, Boolean isCancellable=false, Boolean showTimeElapsed=false )
voidstepBackgroundProgress ( Number numSteps=1 )
voidstepProgress ( Number numSteps=1 )
voidupdateBackgroundProgress ( Number position )
voidupdateProgress ( Number position )
Deprecated
Stringunescape ( String text )
Stringescape ( String text )
BooleanshiftPressed ()
BooleanctrlPressed ()
QDesktopWidget (deprecated)getDesktop ()

Detailed Description

The global object is never used directly, and cannot be created using the new operator. It is automatically created when the scripting engine is initialized, and its functions and properties are available immediately. The global object has no syntax. Its functions and properties are accessed directly.

Properties


Boolean : false

A special value corresponding to the primitive value, false. (Read Only)

Example:

var nTest = 0 > 1;
print( typeof nTest ); // boolean
print( nTest ); // false

Number : Infinity

A special value used to indicate a division by zero occurrence. In Daz Script, division by zero does not raise an error, instead it assigns the Infinity value. Use isFinite() to test if a value is finite or not. (Read Only)

Example:

var nNum = 1/0;
print( typeof nNum ); // number
print( nNum ); // Infinity

JSON : JSON

Global variable giving all DAZ Scripts access to the ECMAScript JSON object.


Math : Math

Global variable giving all DAZ Scripts access to the ECMAScript Math object.


Number : NaN

A special value used to indicate that the value of a Number, is “Not a Number”. (Read Only)

Example:

var nNum = 1/"six";
print( typeof nNum ); // number
print( nNum ); // NaN

Object : null

A special value used to indicate a variable does not have a value. (Read Only)

Example:

var nNum = null;
print( typeof nNum ); // object
print( nNum ); // null

Boolean : true

A special value corresponding to the primitive value, true. (Read Only)

Example:

var nTest = 0 < 1;
print( typeof nTest ); // boolean
print( nTest ); // true

Undefined : undefined

A special value used to indicate a variable does not have a defined value (e.g., has not yet been assigned). (Read Only)

Example:

var nNum;
print( typeof nNum ); // undefined
print( nNum ); // undefined

DzApp : App

A global variable giving all DAZ Scripts access to the application object.


DzColorDialog : ColorDialog

A global variable giving all DAZ Scripts access to public static members on QColorDialog.


DzFileDialog : FileDialog

A global variable giving all DAZ Scripts access to the file dialog object.


DzGeometryUtil : Geometry

A global variable giving all DAZ Scripts access to the geometry object.


DzMainWindow : MainWindow

A global variable giving all DAZ Scripts access to the interface object.


DzMessageBox : MessageBox

A global variable giving all DAZ Scripts access to public static members on QMessageBox.


DzOpenGL : OpenGL

A global variable giving all DAZ Scripts access to the OpenGL object.


DzScene : Scene

A global variable giving all DAZ Scripts access to the scene object.


DzSystem : System

A global variable giving all DAZ Scripts access to the system object.


DzUndoStack : UndoStack

A global variable giving all DAZ Scripts access to the undo stack object.

Methods


String : decodeURI( String encodedURI )

Parameter(s):

  • encodedURI - The encoded URI to decode.

Return Value:

  • A new version of encodedURI in which each escape sequence and UTF-8 encoding of the kind that might be introduced by encodeURI() is replaced with the character that it represents. Escape sequences that could not have been introduced by encodeURI() are not replaced.

String : decodeURIComponent( String encodedURIComponent )

Return Value:

  • A new version of encodedURIComponent in which each escape sequence and UTF-8 encoding of the kind that might be introduced by encodeURIComponent() is replaced with the character that it represents.

String : encodeURI( String uri )

Parameter(s):

  • uri - The URI to encode.

Return Value:

  • A new version of uri in which each instance of certain characters is replaced by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.

String : encodeURIComponent( String uriComponent )

Return Value:

  • A new version of uri in which each instance of certain characters is replaced by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.

Object : eval( String str )

Parses and executes str, and returns the result.

Parameter(s):

  • str - The statement to evaluate.

Example:

var sTmp = "x";
var nTmp = 5;
sTmp = eval( "sTmp + nTmp" );
// sTmp: "x5"

Example:

var nTmp = 2;
var nTmp2 = 5;
nTmp = eval( "nTmp + nTmp2" );
// nTmp: 7

Boolean : isFinite( Object expression )

Parameter(s):

  • expression - The script expression to evaluate.

Return Value:

  • false if expression coerces to NaN or Infinity, otherwise true.

Example:

print( "isFinite( NaN ) //", isFinite( NaN ) );
print( "isFinite( undefined ) //", isFinite( undefined ) );
print( "isFinite( {} ) //", isFinite( {} ) );
 
print( "isFinite( true ) //", isFinite( true ), ":", Number( true ) );
print( "isFinite( true ) //", isFinite( false ), ":", Number( false ) );
print( "isFinite( null ) //", isFinite( null ), ":", Number( null ) );
print( "isFinite( 5 ) //", isFinite( 5 ) );
 
print( "isFinite( \"5\" ) //", isFinite( "5" ), ":", Number( "5" ) );
print( "isFinite( \"5.5\" ) //", isFinite( "5.5" ), ":", Number( "5.5" ) );
print( "isFinite( \"5,5\" ) //", isFinite( "5,5" ), ":", Number( "5,5" ) );
print( "isFinite( \"ABC123\" ) //", isFinite( "ABC123" ), ":", Number( "ABC123" ) );
print( "isFinite( \"\" ) //", isFinite( "" ), ":", Number( "" ) );
print( "isFinite( \" \" ) //", isFinite( " " ), ":", Number( " " ) );
 
var dateNow = new Date();
print( "isFinite( new Date() ) //", isFinite( dateNow ), ":", Number( dateNow ) );
var sDate = dateNow.toString();
print( "isFinite( (new Date()).toString() ) //", isFinite( sDate ), ":", Number( sDate ) );

Boolean : isNaN( Object expression )

Parameter(s):

  • expression - The script expression to evaluate.

Return Value:

  • true if expression is NaN (Not a Number), otherwise false.

Example:

print( "isNaN( NaN ) //", isNaN( NaN ) );
print( "isNaN( undefined ) //", isNaN( undefined ) );
print( "isNaN( {} ) //", isNaN( {} ) );
 
print( "isNaN( true ) //", isNaN( true ), ":", Number( true ) );
print( "isNaN( true ) //", isNaN( false ), ":", Number( false ) );
print( "isNaN( null ) //", isNaN( null ), ":", Number( null ) );
print( "isNaN( 5 ) //", isNaN( 5 ) );
 
print( "isNaN( \"5\" ) //", isNaN( "5" ), ":", Number( "5" ) );
print( "isNaN( \"5.5\" ) //", isNaN( "5.5" ), ":", Number( "5.5" ) );
print( "isNaN( \"5,5\" ) //", isNaN( "5,5" ), ":", Number( "5,5" ) );
print( "isNaN( \"ABC123\" ) //", isNaN( "ABC123" ), ":", Number( "ABC123" ) );
print( "isNaN( \"\" ) //", isNaN( "" ), ":", Number( "" ) );
print( "isNaN( \" \" ) //", isNaN( " " ), ":", Number( " " ) );
 
var dateNow = new Date();
print( "isNaN( new Date() ) //", isNaN( dateNow ), ":", Number( dateNow ) );
var sDate = dateNow.toString();
print( "isNaN( (new Date()).toString() ) //", isNaN( sDate ), ":", Number( sDate ) );

Number : parseFloat( String str )

Parses str and returns the floating point number that it represents or NaN if the parse fails. Leading and trailing whitespace is ignored, and if the string contains a number followed by non-numeric characters, the value of the number is returned and the remainder of the string is ignored.

Parameter(s):

  • str - The string to convert to a floating point number.

Return Value:

  • A floating point number or NaN.

Example:

print( "parseFloat( \"5\" ) //", parseFloat( "5" ) );
print( "parseFloat( \"5.5\" ) //", parseFloat( "5.5" ) );
print( "parseFloat( \"5,5\" ) //", parseFloat( "5,5" ) );
print( "parseFloat( \"5ABC\" ) //", parseFloat( "5ABC" ) );
print( "parseFloat( \"ABC5\" ) //", parseFloat( "ABC5" ) );

Number : parseInt( String str, Number radix )

Parses the string and returns the integer that it represents or NaN if the parse fails. Leading and trailing whitespace is ignored, and if the string contains a number followed by non-numeric characters, the value of the number is returned and the remainder of the string is ignored.

Parameter(s):

  • str - The string to convert to an integer.
  • radix - The (optional) base of the number; [2,36]; if not specified, base is determined as follows:
    • base 16 if the number begins with “0x” or “0X”
    • base 8 if the number begins with “0”
    • base 10 otherwise

Return Value:

  • An integer or NaN.

Example:

print( "parseInt( \"5\" ) //", parseInt( "5" ) );
print( "parseInt( \"5.5\" ) //", parseInt( "5.5" ) );
print( "parseInt( \"5,5\" ) //", parseInt( "5,5" ) );
print( "parseInt( \"5ABC\" ) //", parseInt( "5ABC" ) );
print( "parseInt( \"ABC5\" ) //", parseInt( "ABC5" ) );
print( "parseInt( \"0x0123456789abcdef\" ) //", parseInt( "0x0123456789abcdef" ) );
print( "parseInt( \"0123456789abcdef\", 16 ) //", parseInt( "0123456789abcdef", 16 ) );
print( "parseInt( \"01234567\" ) //", parseInt( "01234567" ) );
print( "parseInt( \"01234567\", 8 ) //", parseInt( "01234567", 8 ) );
print( "parseInt( \"10001110101\", 2 ) //", parseInt( "10001110101", 2 ) );

void : gc()

While the garbage collector is automatically run for script objects that are no longer referenced, there is no guarantee on when it will take place. This function can be used to explicitly request garbage collection.


void : print( String expression )

Prints the expression to the console (if executed from within the Script Editor) or to the log.

Parameter(s):

  • expression - The expression to print - the argument will be converted to a string (via toString) if necessary.

Example:

print( "Hello, World!" );

String : qsTr( String sourceText )

Return Value:

  • A translated version of sourceText if an appropriate translated string is available, otherwise returns sourceText itself.

String : qsTranslate( String sourceText )

Return Value:

  • The translation text for sourceText, by querying the installed translation files. Translation files are searched from the most recently installed file back to the first installed file.

String : qsTrId( String id )

Return Value:

  • A translated string identified by id. If no matching string is found, id itself is returned.

void : acceptUndo( String caption )

Scripts can call this function to accept and finish a hold on the undo stack started by calling beginUndo().

Parameter(s):

  • caption - The brief description for the action that will be displayed to the user.

Boolean : backgroundProgressIsActive()

Return Value:

  • true if one or more background progress operations are currently being tracked.

See Also:


Boolean : backgroundProgressIsCancelled()

Return Value:

  • true if the user has cancelled the current operation by pressing the 'Cancel' button on the background progress.

void : beginNodeSelectionHold()

Captures the current state of node selection in the scene, on a node selection stack.

See Also:

Since:

  • 4.9.4.109

void : beginUndo()

Starts a hold on the undo stack. It is recommended that scripts use this function rather than accessing DzUndoStack directly, since if the script crashes or a logic error results in leaving the undo stack open, calling this function insures that the undo stack will be closed at the end of script execution.


void : cancelUndo()

Scripts can call this function to cancel a hold on the undo stack started by calling beginUndo().


void : clearBusyCursor()

Clears the application-standard busy cursor and returns the mouse cursor to the previous cursor. Match every call to setBusyCursor() with a call to this function.

Example:

setBusyCursor();
// ... do something ...
clearBusyCursor();

void : clearNodeSelectionHolds()

Clears all selection holds without restoring the selection.

See Also:

Since:

  • 4.9.4.109

void : clearUndoStack()

Scripts can call this function to clear the undo stack.


void : connect( Object sender, String signal, Object receiver, String function )

Connects a signal from one object to a function (slot) on another object.

Parameter(s):

  • sender - The object emitting the signal.
  • signal - The signal being emitted.
  • receiver - The object that will receive the signal.
  • function - The name of the method on receiver to execute when sender emits signal. If receiver is a script defined Function, the 'this' object within the context of the function will be the Global object.

See Also:


void : connect( Object sender, String signal, Object thisObject, Function functionRef )

Connects a signal from an object to a function.

Parameter(s):

  • sender - The object emitting the signal.
  • signal - The signal being emitted.
  • thisObject - The object to bind to 'this' in the scope of functionRef if functionRef is a script-defined Function. If functionRef is a function on a QObject, this argument is not used.
  • functionRef - The function to execute when sender emits signal.

See Also:

Since:

  • 4.15.0.18

void : connect( Object sender, String signal, Function functionRef )

Connects a signal from an object to a function.

Parameter(s):

  • sender - The object emitting the signal.
  • signal - The signal being emitted.
  • functionRef - The function to execute when sender emits signal.

See Also:


void : debug( expression )

Prints expression to the output console (stderr), followed by a newline.

Example:

debug( "Um... Houston?" );

void : disconnect( Object sender, String signal, Object receiver, String function )

Disconnects a signal from one object to a function (slot) on another object.

Parameter(s):

  • sender - The object emitting the signal.
  • signal - The signal being emitted.
  • receiver - The object that receives the signal.
  • function - The method on receiver to disconnect from signal.

See Also:


void : disconnect( Object sender, String signal, Object thisObject, Function functionRef )

Disconnects a signal from an object to a function.

Parameter(s):

  • sender - The object emitting the signal.
  • signal - The signal being emitted.
  • thisObject - The object bound to 'this' in the scope of functionRef if functionRef is a script-defined Function. If functionRef is a function on a QObject, this argument is not used.
  • functionRef - The function to disconnect from signal.

See Also:

Since:

  • 4.15.0.18

void : disconnect( Object sender, String signal, Function functionRef )

Disconnects a signal from an object to a function.

Parameter(s):

  • sender - The object emitting the signal.
  • signal - The signal being emitted.
  • functionRef - The function to disconnect from signal.

See Also:


void : dropNodeSelectionHold()

Removes the current hold on the state of node selection in the scene without restoring the selection.

See Also:

Since:

  • 4.9.4.109

void : dropUndo()

Scripts can call this function to drop a hold on the undo stack started by calling beginUndo().


void : finishBackgroundProgress()

Ends the current background progress tracking operation, and closes the background progress if no other background progress tracking operations are active.

See Also:


void : finishProgress()

Ends the current progress tracking operation, and closes the progress dialog if no other progress tracking operations are active.

See Also:


Array : getArguments()

Return Value:

  • The list of arguments passed to the script (if any) upon execution, otherwise an empty Array.

See Also:


String : getErrorMessage( DzError errCode )

This function converts an error code into a string message.

Parameter(s):

  • errCode - The Daz Studio error code.

Return Value:

  • A user-readable message that describes the error represented by the error code.

QObject : getObjectParent( QObject obj )

This function allows a script to get the object-parent of a QObject.

Parameter(s):

  • obj - The QObject to get the parent of.

Return Value:


DzAuthor : getScriptAuthor()

Return Value:

  • The author of the current script (if any).

String : getScriptFileName()

Return Value:

  • The file name of the current script (if any).

String : getScriptType()

Return Value:

  • The file type that this script was saved out as.

String : getScriptVersionString()

Return Value:

  • The version of the current script (if any).

void : include( String scriptPath )

Includes the contents of scriptPath in the same context as the calling script. This function should only be called within the global scope of the script; it should not be called within a nested scope and it should not be called inline. As a safeguard against circular references, the script engine keeps an internal list of unique paths for included scripts; per script context, per execution. Each time the function is called, scriptPath is checked against the list to ensure that the path has only been included once within the context of the script.

Parameter(s):

  • scriptPath - The path of the script to include. The path is assumed to be relative to the ./scripts directory. Absolute paths are also supported.

Example:

include( "MyFolder/MyScript.dse" );
oMyObject.myFunction();

Boolean : pointersAreEqual( QObject ptr1, QObject ptr2 )

This function allows a script to test if two QObject derived variables point to the same instance.

Parameter(s):

  • ptr1 - The first object.
  • ptr2 - The second object.

Return Value:

  • true if the pointers point to the same object, otherwise false.

void : processEvents()

Pauses execution of the script and allows the GUI thread time to process events.


Boolean : progressIsActive()

Return Value:

  • true if one or more progress operations are currently being tracked, otherwise false.

Boolean : progressIsCancelled()

Return Value:

  • true if the user has cancelled the current operation by pressing the 'Cancel' button on the progress dialog.

void : restoreNodeSelectionHold()

Restores node selection in the scene to the state it was in when the last call to beginNodeSelectionHold() was made.

See Also:

Since:

  • 4.9.4.109

void : setBusyCursor()

Sets the application-standard busy cursor. Match every call to this function with a call to clearBusyCursor() to restore the previous cursor.

Example:

setBusyCursor();
// ... do something ...
clearBusyCursor();

void : sleep( Number milliseconds )

Pauses the script for the specified number of milliseconds without blocking the application event loop.

Parameter(s):

  • milliseconds - The duration, in milliseconds, to sleep.

Example:

print( new Date );
sleep( 6000 ); // 0.1 min
print( new Date );

Since:

  • 4.8.0.45

void : startBackgroundProgress( String info, Number totalSteps=0, Boolean isCancellable=false )

Displays a background progress bar to the user if one is not already being displayed and starts a progress tracking operation.

Parameter(s):

  • info - The string to display in the status bar as the current description of the operation.
  • totalSteps - The number of progress steps for the operation to be complete.
  • isCancellable - If true, the user is given the option to cancel the operation.

See Also:


void : startProgress( String info, Number totalSteps=0, Boolean isCancellable=false, Boolean showTimeElapsed=false )

Displays a progress dialog to the user if one is not already being displayed and starts a progress tracking operation.

Parameter(s):

  • info - The string to display in the progress dialog as the current description of the operation.
  • totalSteps - The number of progress steps for the operation to be complete.
  • isCancellable - If true, the user is given the option to cancel the operation.
  • showTimeElapsed - If true, the amount of time since the progress operation was started will be displayed in the dialog.

See Also:


void : stepBackgroundProgress( Number numSteps=1 )

Steps the current background progress forward the given number of steps.

Parameter(s):

  • numSteps - The number of steps to move the progress indicator forward.

void : stepProgress( Number numSteps=1 )

Steps the current progress dialog forward the given number of steps.

Parameter(s):

  • numSteps - The number of steps to move the progress indicator forward.

See Also:


void : updateBackgroundProgress( Number position )

Sets the current background progress to the given number of steps.

Parameter(s):

  • position - The number of steps to set as the current position for the progress indicator.

See Also:


void : updateProgress( Number position )

Sets the current progress dialog to the given number of steps.

Parameter(s):

  • position - The number of steps to set as the current position for the progress indicator.

String : unescape( String text )

Deprecated

Exists only to keep old code working. Do not use in new code. Use decodeURI() or decodeURIComponent() instead.


String : escape( String text )

Deprecated

Exists only to keep old code working. Do not use in new code. Use encodeURI() or encodeURIComponent() instead.


Boolean : shiftPressed()

Deprecated

Exists only to keep old code working. Do not use in new code. Use DzApp::modifierKeyState() instead.

var bShiftPressed = App.modifierKeyState() & 0x02000000;

Boolean : ctrlPressed()

Deprecated

Exists only to keep old code working. Do not use in new code. Use DzApp::modifierKeyState() instead.

var bControlPressed = App.modifierKeyState() & 0x04000000;

QDesktopWidget (deprecated) : getDesktop()

Deprecated

Exists only to keep old code working. Do not use in new code. Use DzDesktopWidget instead.

var wDesktop = new DzDesktopWidget();