Global Objects

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

Constants

const Boolean false
const Number Infinity
const Number NaN
const Boolean true
const Object undefined

Methods (ECMAScript)

Boolean isFinite (expression)
Boolean isNaN (expression)
 decodeURI (encodedURI)
 decodeURIComponent (encodedURIComponent)
 encodeURI (uri)
 encodeURIComponent (uriComponent)
Object eval (String str)
Number parseFloat (String str)
Number parseInt (String str, Number optBase)
void print (String expression)

Methods (DAZ Script 2 Extensions)

void acceptUndo (String caption)
void beginUndo ()
void cancelUndo ()
void clearBusyCursor ()
void connect (Object sender, String signal, Function functionRef)
void connect (Object sender, String signal, Object receiver, String slot)
Boolean ctrlPressed ()
void debug (expression)
void disconnect (Object sender, String signal, Function functionRef)
void disconnect (Object sender, String signal, Object receiver, String slot)
void finishProgress ()
Array getArguments ()
QDesktopWidget getDesktop ()
String getErrorMessage (DzError errCode)
DzAuthor getScriptAuthor ()
String getScriptFileName ()
String getScriptType ()
String getScriptVersionString ()
void killTimer (Number timerId)
void killTimers ()
Boolean pointersAreEqual (Object ptr1, Object ptr2)
void processEvents ()
Boolean progressIsActive ()
Boolean progressIsCancelled ()
void setBusyCursor ()
Boolean shiftPressed ()
void startProgress (String info, Number totalSteps=0, Boolean isCancellable=false, Boolean showTimeElapsed=false)
Number startTimer (Number interval, function timeoutFunction)
void stepProgress (Number numSteps=1)
void updateProgress (Number position)

Variables

DzApp App
Array arguments
DzColorDialog ColorDialog
DzFileDialog FileDialog
DzGeometryUtil Geometry
DzMainWindow MainWindow
DzMath Math
DzMessageBox MessageBox
DzOpenGL OpenGL
DzScene Scene
DzSystem System

Detailed Description

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

Todo:
Examples: connect, disconnect, debug, killTimer, killTimers, parseFloat, parseInt, startTimer, print, true, false

Function Documentation

void acceptUndo ( String  caption  ) 

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

Parameters:
caption The brief description for the action that will be displayed to the user

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 connect ( Object  sender,
String  signal,
Function  functionRef 
)

Connects a signal from an Object to a DAZ Script function (slot). See Signals and Slots in DAZ Script for more information about using signals and slots.

Parameters:
sender The Object emitting the signal
signal The signal being emitted
functionRef The function to execute when sender emits signal
Example:
    // A function to display a message
    function showMessage(){
        MessageBox.information( "Testing \"connect( Object sender, String signal, functionRef );\"",
        "Test", "&OK" );
    }

    // Create a dialog
    var wDlg = new DzDialog;
    var wDlgLyt = new DzVBoxLayout( wDlg );
    wDlgLyt.autoAdd = true;
    var wBtn = new DzPushButton( wDlg );
    wBtn.text = "Show Message";
    // Connect the DzButton::pressed() signal to the showMessage function
    connect( wBtn, "pressed()", showMessage );

    // Display the dialog
    wDlg.exec();

void connect ( Object  sender,
String  signal,
Object  receiver,
String  slot 
)

Connects a signal from one Object to a function (slot) on another Object. See Signals and Slots in DAZ Script for more information about using signals and slots.

Parameters:
sender The Object emitting the signal
signal The signal being emitted
receiver The Object that will recieve the signal
slot The method on receiver to execute when sender emits signal
Example:
EXAMPLE

Boolean ctrlPressed (  ) 

This function allows a script to determine what meta keys were pressed when the script was activated.

Returns:
True if the control button was pressed when the script was activated

void debug ( expression   ) 

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

Example:
EXAMPLE

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

Disconnects a signal from one Object to a function (slot). See Signals and Slots in DAZ Script for more information about using signals and slots.

Parameters:
sender The Object emitting the signal
signal The signal being emitted
functionRef The function to disconnect from signal
Example:
EXAMPLE

void disconnect ( Object  sender,
String  signal,
Object  receiver,
String  slot 
)

Disconnects a signal from one Object to a function (slot) on another Object. See Signals and Slots in DAZ Script for more information about using signals and slots.

Parameters:
sender The Object emitting the signal
signal The signal being emitted
receiver The Object that will recieve the signal
slot The method on receiver to disconnect from signal
Example:
EXAMPLE

Object eval ( String  str  ) 

Parses and executes str, and returns the result

Parameters:
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

void finishProgress (  ) 

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

Array getArguments (  ) 

This returns the list of arguments passed into the script. By default, this list is empty, however, if arguments were specified to the script when it was executed, they will be contained in this list.

See also:
DzScript::execute(Array)
Returns:
The list of arguments passed to the script.

QDesktopWidget getDesktop (  ) 

This function access to the desktop widget. This can be useful to get the size of the machine's desktop.

Returns:
The desktop widget.

String getErrorMessage ( DzError  errCode  ) 

This function converts an error code into a string message.

Parameters:
errCode The DAZ Studio error code
Returns:
A user-readable message that describes the error represented by the error code.

DzAuthor getScriptAuthor (  ) 

Returns:
The author of the current script (if any).

String getScriptFileName (  ) 

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

String getScriptType (  ) 

Returns:
The file type that this script was saved out as.

String getScriptVersionString (  ) 

Returns:
The version of the current script (if any).

void killTimer ( Number  timerId  ) 

Stops and deletes the timer with the given id

Parameters:
timerId The id of the timer to stop.
Example:
EXAMPLE

See also:
startTimer() and killTimers()

void killTimers (  ) 

Stops and deletes all active timers.

Example:
EXAMPLE

See also:
startTimer() and killTimer()

Number parseFloat ( String  str  ) 

Parses the string 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.

Parameters:
str The string to convert to a floating point number.
Returns:
A floating point number or NaN
Example:
EXAMPLE

Number parseInt ( String  str,
Number  optBase 
)

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.

Parameters:
str The string to convert to an integer.
optBase The base of the number - 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
Returns:
An integer or NaN
Example:
EXAMPLE

Boolean pointersAreEqual ( Object  ptr1,
Object  ptr2 
)

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

Parameters:
ptr1 The first object
ptr2 The second object
Returns:
True if the pointers point to the same object, otherwise false.

void print ( String  expression  ) 

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

Parameters:
expression The expression to print - the argument will be converted to a string (via toString) if necessary.
Example:
EXAMPLE

void processEvents (  ) 

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

Boolean progressIsActive (  ) 

Returns:
true if one or more progress operations are currently being tracked.

Boolean progressIsCancelled (  ) 

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

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();

Boolean shiftPressed (  ) 

This function allows a script to determine what meta keys were pressed when the script was activated.

Returns:
True if the shift button was pressed when the script was activated

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.

Parameters:
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.

Number startTimer ( Number  interval,
function  timeoutFunction 
)

Creates a new timer and executes timeoutFunction every interval milliseconds.

Parameters:
interval The number of milliseconds between signals emitted by the timer.
timeoutFunction The function that is called when the timer times out.
Returns:
Created timer's id.
Example:
EXAMPLE

void stepProgress ( Number  numSteps = 1  ) 

Steps the current progress dialog forward the given number of steps

Parameters:
numSteps The number of steps to move the progress indicator forward

void updateProgress ( Number  position  ) 

Sets the current progress dialog to the given number of steps

Parameters:
position The number of steps to set as the current position for the progress indicator


Variable Documentation

DzApp App

Global variable giving all DAZ Scripts access to the application object.

Array arguments

An Array of the arguments passed to a function. (Read Only)

Attention:
Only exists in the context of a function.
Example:
    function sum(){
        var nTotal = 0;
        for( var i = 0; i < arguments.length; i++ ){
            nTotal += arguments[ i ];
        }
        return nTotal;
    }
    var nSum = sum( 2, 3, 4, 5 );
    // nSum: 14

DzColorDialog ColorDialog

Global variable giving all DAZ Scripts access to the color picker object.

const Boolean false

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

Example:
EXAMPLE

DzFileDialog FileDialog

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

DzGeometryUtil Geometry

Global variable giving all DAZ Scripts access to the geometry object.

const Number Infinity

A special value used to indicate a division by zero occourance. 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;
    // nNum: Infinity

Boolean isFinite(expression)

Parses and executes str, and returns the result

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 isNaN(expression)

Returns:
A Boolean value indicating whether an expression is NaN (Not a Number)
Example:
    var nTmp = 5;
    var bTmp = isNaN( nTmp );
    // bTmp == false
    var sTmp = "five";
    bTmp = isNaN( sTmp );
    // bTmp: true

DzMainWindow MainWindow

Global variable giving all DAZ Scripts access to the interface object.

DzMath Math

Global math object

DzMessageBox MessageBox

Global variable giving all DAZ Scripts access to the message box object.

const 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";
    // nNum: NaN

DzOpenGL OpenGL

Global variable giving all DAZ Scripts access to the OpenGL object.

DzScene Scene

Global variable giving all DAZ Scripts access to the scene object.

DzSystem System

The global system object.

const Boolean true

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

Example:
EXAMPLE

const Object 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;
    // nNum: undefined


Generated on Thu Sep 24 12:21:09 2009

Copyright © 2002 - 2009 DAZ 3D, Inc.