// DAZ Studio version 3.1  filetype Pose Preset

var g_sTOOL_NAME = "Pose Preset";
var g_oFILE = new DzFile( getScriptFileName() );
var g_sSCRIPT_NAME = String( "%1.%2" ).arg( g_oFILE.baseName() ).arg( g_oFILE.extension() );
var g_bSHIFT_PRESSED = shiftPressed();
var g_bCONTROL_PRESSED = ctrlPressed();

var g_sROOT = "Root";
var g_sSELECTED = "Selected";
var g_sNONE = "None";
var g_sRECURSIVE = "Recursive";

var g_oGui = new DsInterface;
var g_oActions = new DsActions;
var g_oStringHelper = new DzStringHelper;
var g_oArrayHelper = new DzArrayHelper;
var g_oPresetHelper = new DzPresetHelper;
var g_oSettingsHelper = new DzSettingsHelper;
var g_oSceneHelper = new DzSceneHelper;

/***********************************************************************
***** DsInterface Prototype *****
***********************************************************************/

/*********************************************************************/
function DsInterface()
{
	this.m_nMARGIN = 5;
	this.m_nSPACING = 5;
	this.m_nMIN_BTN_WIDTH = 80;
	this.m_nMAX_BTN_HEIGHT = 20;
	this.m_nWIDGET_WIDTH = 190;
	this.m_aBoolNames = new Array;
	this.m_aBoolObjs = new Array;
	this.m_aStrNames = new Array;
	this.m_aStrObjs = new Array;
	this.m_aCmbNames = new Array;
	this.m_aCmbObjs = new Array;
	this.m_wDlg;
	this.m_wTabStack, this.m_wOptionPage, this.m_wPrefsPage;
	this.m_wCombGB, this.m_wPrefsGB;
	this.m_wNdsLbl, this.m_wPrpgtnLbl;
	this.m_wNodes, this.m_wPrpgtn;
	this.m_wbMrphsGBox;
	this.m_wbLimitsBtnGrp;
	this.m_wbObeyLimits, this.m_wbLimitsOff;
	this.m_wbTrnsfrmsGBox;
	this.m_wRotGB, this.m_wbXrot, this.m_wbYrot, this.m_wbZrot;
	this.m_wTranGB, this.m_wbXtran, this.m_wbYtran, this.m_wbZtran;
	this.m_wScaleGB, this.m_wbScale, this.m_wbXscale, this.m_wbYscale, this.m_wbZscale;
	this.m_wHelpBtn, this.m_wAcceptBtn, this.m_wCancelBtn;
	this.m_wRdBtn, this.m_wRcrdBtn, this.m_wRcrdOnExec, this.m_wDfltBtn;

}
/***********************************************************************/
DsInterface.superclass = Object;

/*********************************************************************/
DsInterface.prototype.doCommon = function()
{
	this.m_wDlg = new DzDialog;
	this.m_wTabStack = new DzTabWidget( this.m_wDlg );
	this.m_wOptionPage = new DzVGroupBox( this.m_wTabStack );
	this.m_wCombGB = new DzVGroupBox( this.m_wOptionPage );
	this.m_wNdsLbl = new DzLabel( this.m_wCombGB );
	this.m_wNodes = new DzComboBox( this.m_wCombGB );
	this.m_wNodes.insertItem( g_sROOT );
	this.m_wNodes.insertItem( g_sSELECTED );
	this.m_aCmbObjs.push( this.m_wNodes );
	this.m_aCmbNames.push( "cbNodes" );
	this.m_wPrpgtnLbl = new DzLabel( this.m_wCombGB );
	this.m_wPrpgtn = new DzComboBox( this.m_wCombGB );
	this.m_wPrpgtn.insertItem( g_sNONE );
	this.m_wPrpgtn.insertItem( g_sRECURSIVE );
	this.m_aCmbObjs.push( this.m_wPrpgtn );
	this.m_aCmbNames.push( "cbPrpgtn" );
	this.m_wbMrphsGBox = new DzVGroupBox( this.m_wOptionPage );
	this.m_wbMrphsGBox.checkable = true;
	this.m_aBoolObjs.push( this.m_wbMrphsGBox );
	this.m_aBoolNames.push( "mrphs" );
	this.m_wbLimitsBtnGrp = new DzVButtonGroup( this.m_wOptionPage );
	this.m_wbObeyLimits = new DzRadioButton( this.m_wbLimitsBtnGrp );
	this.m_aBoolObjs.push( this.m_wbObeyLimits );
	this.m_aBoolNames.push( "obylmts" );
	this.m_wbLimitsOff = new DzRadioButton( this.m_wbLimitsBtnGrp );
	this.m_aBoolObjs.push( this.m_wbLimitsOff );
	this.m_aBoolNames.push( "lmtsoff" );
	this.m_wbTrnsfrmsGBox = new DzVGroupBox( this.m_wOptionPage );
	this.m_wbTrnsfrmsGBox.checkable = true;
	this.m_aBoolObjs.push( this.m_wbTrnsfrmsGBox );
	this.m_aBoolNames.push( "trnsfrms" );
	this.m_wRotGB = new DzVGroupBox( this.m_wbTrnsfrmsGBox );
	this.m_wbXrot = new DzCheckBox( this.m_wRotGB );
	this.m_aBoolObjs.push( this.m_wbXrot );
	this.m_aBoolNames.push( "xrot" );
	this.m_wbYrot = new DzCheckBox( this.m_wRotGB );
	this.m_aBoolObjs.push( this.m_wbYrot );
	this.m_aBoolNames.push( "yrot" );
	this.m_wbZrot = new DzCheckBox( this.m_wRotGB );
	this.m_aBoolObjs.push( this.m_wbZrot );
	this.m_aBoolNames.push( "zrot" );
	this.m_wTranGB = new DzVGroupBox( this.m_wbTrnsfrmsGBox );
	this.m_wbXtran = new DzCheckBox( this.m_wTranGB );
	this.m_aBoolObjs.push( this.m_wbXtran );
	this.m_aBoolNames.push( "xtran" );
	this.m_wbYtran = new DzCheckBox( this.m_wTranGB );
	this.m_aBoolObjs.push( this.m_wbYtran );
	this.m_aBoolNames.push( "ytran" );
	this.m_wbZtran = new DzCheckBox( this.m_wTranGB );
	this.m_aBoolObjs.push( this.m_wbZtran );
	this.m_aBoolNames.push( "ztran" );
	this.m_wScaleGB = new DzVGroupBox( this.m_wbTrnsfrmsGBox );
	this.m_wbScale = new DzCheckBox( this.m_wScaleGB );
	this.m_aBoolObjs.push( this.m_wbScale );
	this.m_aBoolNames.push( "scale" );
	this.m_wbXscale = new DzCheckBox( this.m_wScaleGB );
	this.m_aBoolObjs.push( this.m_wbXscale );
	this.m_aBoolNames.push( "xscale" );
	this.m_wbYscale = new DzCheckBox( this.m_wScaleGB );
	this.m_aBoolObjs.push( this.m_wbYscale );
	this.m_aBoolNames.push( "yscale" );
	this.m_wbZscale = new DzCheckBox( this.m_wScaleGB );
	this.m_aBoolObjs.push( this.m_wbZscale );
	this.m_aBoolNames.push( "zscale" );
	this.m_wPrefsPage = new DzVGroupBox( this.m_wTabStack );
	this.m_wPrefsGB = new DzVGroupBox( this.m_wPrefsPage );
	this.m_wRcrdOnExec = new DzCheckBox( this.m_wPrefsGB );
	this.m_aBoolObjs.push( this.m_wRcrdOnExec );
	this.m_aBoolNames.push( "rcrdOnExec" );
	this.setDefaults();
}

/*********************************************************************/
DsInterface.prototype.doDialog = function()
{
	this.doCommon();
	var oHelp = App.getHelpMgr();
	var oMgr = MainWindow.getActionMgr();
	var oAction = oMgr ? oMgr.findAction( "DzWhatsThisAction" ) : undefined;
	this.m_wDlg.caption = String( "%1 (%2)" ).arg( g_sTOOL_NAME ).arg( g_sSCRIPT_NAME );
	this.m_wDlg.whatsThis = String( "<b>File : </b> %1<br>" ).arg( g_sSCRIPT_NAME ) +
							String( "<b>Type : </b> %2<br>" ).arg( getScriptType() ) +
							String( "<b>Size : </b> %3<br>" ).arg( g_oFILE.sizeStr() ) +
							String( "<b>Version : </b> %4<br>" ).arg( getScriptVersionString() ) +
							String( "<b>Created : </b> %5<br>" ).arg( g_oFILE.created().toString( "dddd, MMMM d yyyy h:mm ap" ) ) +
							String( "<b>Modified : </b> %6" ).arg( g_oFILE.lastModified().toString( "dddd, MMMM d yyyy h:mm ap" ) );
	var wDlgLayout = new DzGridLayout( this.m_wDlg );
	wDlgLayout.margin = this.m_nMARGIN;
	wDlgLayout.spacing = this.m_nSPACING;
	wDlgLayout.addMultiCellWidget( this.m_wTabStack, 0, 0, 0, 2 );
	var wDlgBtnsGB = new DzGroupBox( this.m_wDlg );
	wDlgBtnsGB.flat = true;
	var wDlgBtnsLyt = new DzGridLayout( wDlgBtnsGB );
	wDlgBtnsLyt.margin = this.m_nMARGIN;
	wDlgBtnsLyt.spacing = this.m_nSPACING;
	this.m_wHelpBtn = new DzPushButton( wDlgBtnsGB );
	this.m_wHelpBtn.pixmap = new Pixmap( String( "%1/images/icons/whatsthissmallicon.png" ).arg( App.getResourcesPath() ) );
	this.m_wHelpBtn.maxHeight = this.m_nMAX_BTN_HEIGHT;
	if( oAction )
	{
		this.m_wHelpBtn.clicked.connect( oAction, "trigger()" );
	}
	this.m_wHelpBtn.toolTip = oHelp.getToolTip( "WhatsThis" );
	this.m_wHelpBtn.whatsThis = oHelp.getHelpString( "WhatsThis" );
	wDlgBtnsLyt.addWidget( this.m_wHelpBtn, 0, 0 );
	wDlgBtnsLyt.setColStretch( 1, 1 );
	this.m_wAcceptBtn = new DzPushButton( wDlgBtnsGB );
	this.m_wAcceptBtn.text = "&Accept";
	this.m_wAcceptBtn.minWidth = this.m_nMIN_BTN_WIDTH;
	this.m_wAcceptBtn.maxHeight = this.m_nMAX_BTN_HEIGHT;
	this.m_wDlg.setAcceptButton( this.m_wAcceptBtn );
	this.m_wAcceptBtn.toolTip = oHelp.getToolTip( "AcceptDialog" );
	this.m_wAcceptBtn.whatsThis = oHelp.getHelpString( "AcceptDialog" );
	wDlgBtnsLyt.addWidget( this.m_wAcceptBtn, 0, 2 );
	this.m_wCancelBtn = new DzPushButton( wDlgBtnsGB );
	this.m_wCancelBtn.text = "&Cancel";
	this.m_wCancelBtn.minWidth = this.m_nMIN_BTN_WIDTH;
	this.m_wCancelBtn.maxHeight = this.m_nMAX_BTN_HEIGHT;
	this.m_wDlg.setRejectButton( this.m_wCancelBtn );
	this.m_wCancelBtn.toolTip = oHelp.getToolTip( "CancelDialog" );
	this.m_wCancelBtn.whatsThis = oHelp.getHelpString( "CancelDialog" );
	wDlgBtnsLyt.addWidget( this.m_wCancelBtn, 0, 3 );
	wDlgLayout.addMultiCellWidget( wDlgBtnsGB, 1, 1, 0, 2 );
	this.m_wOptionPage.whatsThis = oHelp.getHelpString( "PresetOptionTab" );
	this.m_wOptionPage.flat = true;
	this.m_wOptionPage.insideMargin = this.m_nMARGIN;
	this.m_wOptionPage.insideSpacing = this.m_nSPACING;
	this.m_wCombGB.columns = 2;
	this.m_wNdsLbl.text = "Nodes :";
	this.m_wNdsLbl.alignment = this.m_wNdsLbl.AlignRight;
	this.m_wNdsLbl.whatsThis = oHelp.getHelpString( "PresetPoseNode" );
	this.m_wNodes.minWidth = this.m_nWIDGET_WIDTH;
	this.m_wNodes.whatsThis = this.m_wNdsLbl.whatsThis;
	this.m_wPrpgtnLbl.text = "Propagation :";
	this.m_wPrpgtnLbl.alignment = this.m_wPrpgtnLbl.AlignRight;
	this.m_wPrpgtnLbl.whatsThis = oHelp.getHelpString( "PresetPosePropagatation" );
	this.m_wPrpgtn.minWidth = this.m_nWIDGET_WIDTH;
	this.m_wPrpgtn.whatsThis = this.m_wPrpgtnLbl.whatsThis;
	this.m_wbMrphsGBox.title = "Morphs :";
	this.m_wbMrphsGBox.whatsThis = oHelp.getHelpString( "PresetPoseMorphs" );
	this.m_wbMrphsGBox.columns = 3;
	this.m_wbLimitsBtnGrp.title = "Transform Limits :";
	this.m_wbLimitsBtnGrp.whatsThis = oHelp.getHelpString( "PresetPoseLimits" );
	this.m_wbLimitsBtnGrp.columns = 2;
	this.m_wbObeyLimits.text = "Obey Limits";
	this.m_wbLimitsOff.text = "Turn Limits Off";
	this.m_wbTrnsfrmsGBox.title = "Transforms :";
	this.m_wbTrnsfrmsGBox.whatsThis = oHelp.getHelpString( "PresetPoseTransforms" );
	this.m_wbTrnsfrmsGBox.columns = 3;
	this.m_wRotGB.title = "Rotation :";
	this.m_wbXrot.text = "X axis";
	this.m_wbYrot.text = "Y axis";
	this.m_wbZrot.text = "Z axis";
	this.m_wTranGB.title = "Translation :";
	this.m_wbXtran.text = "X axis";
	this.m_wbYtran.text = "Y axis";
	this.m_wbZtran.text = "Z axis";
	this.m_wScaleGB.title = "Scale :";
	this.m_wbScale.text = "General";
	this.m_wbXscale.text = "X axis";
	this.m_wbYscale.text = "Y axis";
	this.m_wbZscale.text = "Z axis";
	this.m_wTabStack.addTab( this.m_wOptionPage, "Options" );
	this.m_wPrefsPage.whatsThis = oHelp.getHelpString( "PresetPrefTab" );
	this.m_wPrefsPage.flat = true;
	this.m_wPrefsPage.insideMargin = this.m_nMARGIN;
	this.m_wPrefsPage.insideSpacing = this.m_nSPACING;
	this.m_wPrefsGB.margin = this.m_nMARGIN;
	this.m_wPrefsGB.spacing = this.m_nSPACING;
	this.m_wRcrdOnExec.text = "Set Preferred Options on Accept";
	this.m_wRcrdOnExec.whatsThis = oHelp.getHelpString( "PresetPrefOnAccept" );
	this.m_wRcrdBtn = new DzPushButton( this.m_wPrefsGB );
	this.m_wRcrdBtn.text = "&Set Preferred Options";
	this.m_wRcrdBtn.whatsThis = oHelp.getHelpString( "PresetSetPref" );
	this.m_wRcrdBtn.pressed.connect( this, "setOptions" );
	this.m_wRdBtn = new DzPushButton( this.m_wPrefsGB );
	this.m_wRdBtn.text = "&Read Preferred Options";
	this.m_wRdBtn.whatsThis = oHelp.getHelpString( "PresetReadPref" );
	this.m_wRdBtn.pressed.connect( this, "getOptions" );
	this.m_wDfltBtn = new DzPushButton( this.m_wPrefsGB );
	this.m_wDfltBtn.text = "Restore &Default Options";
	this.m_wDfltBtn.whatsThis = oHelp.getHelpString( "PresetRestoreDef" );
	this.m_wDfltBtn.pressed.connect( this, "setDefaults" );
	var wNotesGB = new DzVGroupBox( this.m_wPrefsPage );
	wNotesGB.title = "Notes :";
	wNotesGB.margin = this.m_nMARGIN;
	wNotesGB.spacing = this.m_nSPACING;
	wNotesGB.minWidth = this.m_nWIDGET_WIDTH + 100;
	var wKeyLbl = new DzLabel( wNotesGB );
	wKeyLbl.text = oHelp.getHelpString( "PresetNotes" );
	this.m_wTabStack.addTab( this.m_wPrefsPage, "Preferences" );
	this.m_wDlg.maxWidth = this.m_wDlg.minWidth;
	this.m_wDlg.maxHeight = this.m_wDlg.minHeight;
	this.getOptions();
	if( this.m_wDlg.exec() )
	{
		if( this.m_wRcrdOnExec.checked )
		{
			this.setOptions();
		}
		g_oActions.begin();
	}
}

/*********************************************************************/
DsInterface.prototype.doNoDialog = function()
{
	this.doCommon();
	if( g_bSHIFT_PRESSED )
	{
		this.getOptions();
	}
	g_oActions.begin();
}

/*********************************************************************/
DsInterface.prototype.setDefaults = function()
{
	for( var i = 0; i < this.m_wNodes.count; i++ )
	{
		if( this.m_wNodes.text( i ) == g_sROOT )
		{
			this.m_wNodes.currentItem = i;
			break;
		}
		this.m_wNodes.currentItem = 0;
	}
	for( var i = 0; i < this.m_wPrpgtn.count; i++ )
	{
		if( this.m_wPrpgtn.text( i ) == g_sRECURSIVE )
		{
			this.m_wPrpgtn.currentItem = i;
			break;
		}
		this.m_wPrpgtn.currentItem = 0;
	}
	var isTrue = [ this.m_wbMrphsGBox, this.m_wbObeyLimits, this.m_wbTrnsfrmsGBox, this.m_wbXrot, this.m_wbYrot, this.m_wbZrot, this.m_wbXtran, this.m_wbYtran, this.m_wbZtran, this.m_wbScale, this.m_wbXscale, this.m_wbYscale, this.m_wbZscale ];
	var isFalse = [ this.m_wRcrdOnExec, this.m_wbLimitsOff ];
	for( var i = 0; i < isTrue.length; i++ )
	{
		isTrue[ i ].checked = true;
	}
	for( var i = 0; i < isFalse.length; i++ )
	{
		isFalse[ i ].checked = false;
	}
}

/*********************************************************************/
DsInterface.prototype.getOptions = function()
{
	for( var i = 0; i < this.m_aBoolObjs.length; i++ )
	{
		this.m_aBoolObjs[ i ].checked = g_oSettingsHelper.get( g_oStringHelper.stripSpaces( g_sTOOL_NAME ), this.m_aBoolNames[ i ], this.m_aBoolObjs[ i ].checked );
	}
	for( var i = 0; i < this.m_aStrObjs.length; i++ )
	{
		this.m_aStrObjs[ i ].text = g_oSettingsHelper.get( g_oStringHelper.stripSpaces( g_sTOOL_NAME ), this.m_aStrNames[ i ], this.m_aStrObjs[ i ].text );
	}
	for( var i = 0; i < this.m_aCmbObjs.length; i++ )
	{
		var tStr = g_oSettingsHelper.get( g_oStringHelper.stripSpaces( g_sTOOL_NAME ), this.m_aCmbNames[ i ], this.m_aCmbObjs[ i ].currentText );
		for( var j = 0; j < this.m_aCmbObjs[ i ].count; j++ )
		{
			if( this.m_aCmbObjs[ i ].text( j ) == tStr )
			{
				this.m_aCmbObjs[ i ].currentItem = j;
				break;
			}
		}
	}
}

/*********************************************************************/
DsInterface.prototype.setOptions = function()
{
	for( var i = 0; i < this.m_aBoolObjs.length; i++ )
	{
		g_oSettingsHelper.set( g_oStringHelper.stripSpaces( g_sTOOL_NAME ), this.m_aBoolNames[ i ], this.m_aBoolObjs[ i ].checked );
	}
	for( var i = 0; i < this.m_aStrObjs.length; i++ )
	{
		g_oSettingsHelper.set( g_oStringHelper.stripSpaces( g_sTOOL_NAME ), this.m_aStrNames[ i ], this.m_aStrObjs[ i ].text );
	}
	for( var i = 0; i < this.m_aCmbObjs.length; i++ )
	{
		g_oSettingsHelper.set( g_oStringHelper.stripSpaces( g_sTOOL_NAME ), this.m_aCmbNames[ i ], this.m_aCmbObjs[ i ].currentText );
	}
}

/*********************************************************************/
DsInterface.prototype.getNodes = function()
{
	return this.m_wNodes.currentText;
}

/*********************************************************************/
DsInterface.prototype.getPropagation = function()
{
	return this.m_wPrpgtn.currentText;
}

/*********************************************************************/
DsInterface.prototype.morphsChecked = function()
{
	return this.m_wbMrphsGBox.checked;
}

/*********************************************************************/
DsInterface.prototype.limitsChecked = function()
{
	return this.m_wbObeyLimits.checked;
}

/*********************************************************************/
DsInterface.prototype.transformsChecked = function()
{
	return this.m_wbTrnsfrmsGBox.checked;
}

/*********************************************************************/
DsInterface.prototype.xRotChecked = function()
{
	return this.m_wbXrot.checked;
}

/*********************************************************************/
DsInterface.prototype.yRotChecked = function()
{
	return this.m_wbYrot.checked;
}

/*********************************************************************/
DsInterface.prototype.zRotChecked = function()
{
	return this.m_wbZrot.checked;
}

/*********************************************************************/
DsInterface.prototype.xTranChecked = function()
{
	return this.m_wbXtran.checked;
}

/*********************************************************************/
DsInterface.prototype.yTranChecked = function()
{
	return this.m_wbYtran.checked;
}

/*********************************************************************/
DsInterface.prototype.zTranChecked = function()
{
	return this.m_wbZtran.checked;
}

/*********************************************************************/
DsInterface.prototype.gScaleChecked = function()
{
	return this.m_wbScale.checked;
}

/*********************************************************************/
DsInterface.prototype.xScaleChecked = function()
{
	return this.m_wbXscale.checked;
}

/*********************************************************************/
DsInterface.prototype.yScaleChecked = function()
{
	return this.m_wbYscale.checked;
}

/*********************************************************************/
DsInterface.prototype.zScaleChecked = function()
{
	return this.m_wbZscale.checked;
}

/***********************************************************************
***** DsActions Prototype *****
***********************************************************************/

/*********************************************************************/
function DsActions()
{
	this.m_nSTART_TIME = Scene.getTime();
	this.m_aNodes = new Array;
	this.m_oSkeleton;
	this.m_oElement;
	this.m_oObject;
	this.m_bMorphs;
	this.m_bLimits;
	this.m_bTransforms;
	this.m_bXRot, this.m_bYRot, this.m_bZRot;
	this.m_bXPos, this.m_bYPos, this.m_bZPos;
	this.m_bGScl, this.m_bXScl, this.m_bYScl, this.m_bZScl;
	this.m_bAskImage = true;
	this.m_aImagePaths = new Array;

}
/***********************************************************************/
DsActions.superclass = Object;

/*********************************************************************/
DsActions.prototype.begin = function()
{
	var bSelected = false;
	var bRecurse = false;
	var bRoot = false;
	if( g_oGui.getNodes() == g_sSELECTED )
	{
		bSelected = true;
	}
	if( g_oGui.getPropagation() == g_sRECURSIVE )
	{
		bRecurse = true;
	}
	if( g_oGui.getNodes() == g_sROOT )
	{
		bRoot = true;
		bSelected = true;
	}
	g_oPresetHelper.setDoMorphs( g_oGui.morphsChecked() );
	g_oPresetHelper.setLimits( g_oGui.limitsChecked() );
	g_oPresetHelper.setTransforms( g_oGui.transformsChecked() );
	g_oPresetHelper.setXRot( g_oGui.xRotChecked() );
	g_oPresetHelper.setYRot( g_oGui.yRotChecked() );
	g_oPresetHelper.setZRot( g_oGui.zRotChecked() );
	g_oPresetHelper.setXPos( g_oGui.xTranChecked() );
	g_oPresetHelper.setYPos( g_oGui.yTranChecked() );
	g_oPresetHelper.setZPos( g_oGui.zTranChecked() );
	g_oPresetHelper.setGScl( g_oGui.gScaleChecked() );
	g_oPresetHelper.setXScl( g_oGui.xScaleChecked() );
	g_oPresetHelper.setYScl( g_oGui.yScaleChecked() );
	g_oPresetHelper.setZScl( g_oGui.zScaleChecked() );
	setBusyCursor();
	this.m_aNodes = g_oSceneHelper.collectNodes( bSelected, bRecurse, bRoot );
	beginUndo();

	for( var i = 0; i < this.m_aNodes.length; i++ ){
		this.setProperties( this.m_aNodes[ i ].getSkeleton(), this.m_aNodes[ i ], bRecurse );
	}
	acceptUndo( String( "\"%1\"" ).arg( g_sSCRIPT_NAME ) );
	clearBusyCursor();
}

DsActions.prototype.setProperties =function( oSkeleton, oNode, bRecurse ){
	var sSkeleton = "";
	if( oSkeleton ){
		this.m_oSkeleton = oSkeleton;
		sSkeleton = this.m_oSkeleton.name;
	}
	this.m_oElement = oNode;
	this.m_oObject = ( this.m_oElement ? this.m_oElement.getObject() : undefined );
	g_oPresetHelper.setTargetElement( this.m_oElement );
	switch( this.m_oElement.name ){
		case "rFoot":
				g_oPresetHelper.setTransformProperty( "Scale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "XScale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "YScale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "ZScale",  [ 1 ] );
				break;
		case "rToe":
				g_oPresetHelper.setTransformProperty( "Scale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "XScale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "YScale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "ZScale",  [ 1 ] );
				break;
		case "lFoot":
				g_oPresetHelper.setTransformProperty( "Scale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "XScale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "YScale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "ZScale",  [ 1 ] );
				break;
		case "lToe":
				g_oPresetHelper.setTransformProperty( "Scale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "XScale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "YScale",  [ 1 ] );
				g_oPresetHelper.setTransformProperty( "ZScale",  [ 1 ] );
				break;
		default:
			break;
	}
	if( bRecurse ){
		var aStack = [ oNode ];
		while(aStack.length>0){
			var oParent = aStack.pop();
			var nNodes = oParent.getNumNodeChildren();
			var oChild;
			for( var n = 0; n < nNodes; n++ ){
				oChild = oParent.getNodeChild( n );
				if( oChild.inherits( "DzBone" ) ){
					if(oChild.getNumNodeChildren()>0){
						aStack.push( oChild );
					}
					this.setProperties( oSkeleton, oChild, false );
				}
			}
		}
	}
}

g_bCONTROL_PRESSED ? g_oGui.doDialog() : g_oGui.doNoDialog();