// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // // global proc int illustratorFileOptions ( string $parent, string $action, string $initialOptions, string $resultCallback ) // // Description: // This script posts the Adobe(R) Illustrator(R) file accessor options. // // Parameters: // $parent - the elf parent layout for this options layout. It is // always a scrollLayout. // $action - the action that is to be performed with this invokation // of this proc. Valid options are: // "query" - construct the options string and pass it // to the resultCallback. // "post" - post all the elf controls. // $resultCallback - // This is the proc to be called with the result string. // resultCallback ( string $optionsString ) // // Returns: // 1 if successfull. // 0 otherwise. // { int $result; string $currentOptions; string $optionList[]; string $optionBreakDown[]; int $index; if ($action == "post") { setUITemplate -pushTemplate DefaultTemplate; setParent $parent; floatFieldGrp -label (uiRes("m_illustratorFileOptions.kScaleFactor")) -v1 0 -pre 2 illustratorScaleFactorVal; checkBoxGrp -label (uiRes("m_illustratorFileOptions.kGroup")) -l1 "" -v1 1 illustratorGroupVal; // Now set to current settings. // $currentOptions = $initialOptions; if (size($currentOptions) > 0) { tokenize($currentOptions, ";", $optionList); for ($index = 0; $index < size($optionList); $index++) { tokenize($optionList[$index], "=", $optionBreakDown); if ($optionBreakDown[0] == "sc") { float $value = float( $optionBreakDown[1] ); floatFieldGrp -e -v1 $value illustratorScaleFactorVal; } else if ($optionBreakDown[0] == "group") { int $value = 1; if( $optionBreakDown[1] == "on") { $value = 1; } else if( $optionBreakDown[1] == "off") { $value = 0; } else { $value = int( $optionBreakDown[1] ); } if( $value > 0 ) { checkBoxGrp -e -v1 1 illustratorGroupVal; } else { checkBoxGrp -e -v1 0 illustratorGroupVal; } } } } setUITemplate -popTemplate; $result = 1; } else if ($action == "query") { int $check = 1; if (`checkBoxGrp -exists illustratorGroupVal`) { $check = `checkBoxGrp -q -v1 illustratorGroupVal`; } float $value = 0.0; if (`floatFieldGrp -exists illustratorScaleFactorVal`) { $value = `floatFieldGrp -q -v1 illustratorScaleFactorVal`; } $currentOptions = $currentOptions + "sc=" + $value; $currentOptions += ";group=" + $check; eval($resultCallback+" \""+$currentOptions+"\""); $result = 1; } else { $result = 0; } return $result; }