// =========================================================================== // 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. // =========================================================================== // // // Creation Date: 17 April 2007 // // Description: // This procedure adds property sheet controls for // a new (multi) compound attribute. This is for internal // use only. // // Input Arguments: // The name of the plug for the attribute // The name of the attribute // // Return Value: // The name of the newly-created control. // proc string AEgetAttributeTypeProc(string $type, int $isColor) { string $proc = ""; if($isColor) { $proc = "AEnewColor"; } else if( $type == "long" ) { $proc = "AEnewInt"; } else if( $type == "bool" ) { // Note: Do not use AEnewBooleanGroup // because AEnewBooleanGroup creates a form layout $proc = "AEnewBool"; } else if($type == "time") { $proc = "AEnewTime"; } else if( $type == "enum" ) { if( !`exists AEnewEnumWithoutItems` ){ eval("source \"AEnewEnum.mel\""); } $proc = "AEnewEnumWithoutItems"; } else if( $type == "float" || $type == "double" || $type == "doubleAngle" ) { $proc = "AEnewFloat"; } else if( $type == "matrix" ) { $proc = "AEnewMatrix"; } else if( $type == "string" ) { $proc = "AEnewString"; } else if( $type == "float3" ) { $proc = "AEnewVector"; } else if( $type == "message" ) { $proc = "AEnewMessage"; } else { $proc = "AEnewOther"; } return $proc; } global proc string AEnewCompound ( string $plugName, string $attrName, string $changedCommand ) { string $createdControl = ""; // Get node name and attr name string $buffer[]; tokenize($plugName, ".", $buffer); string $node = $buffer[0]; string $compoundParent = $buffer[1]; // $compoundMultiParent is compound parent attr with [ ] (in case multi) or without [ ] (if not multi) // $compoundParent is compound parent attr ALWAYS WITHOUT [ ] $compoundMultiParent = $compoundParent; string $compoundMultiParentNice = `attributeName -nice $plugName`; int $isMulti = 0; // Is this multi compound? // if so, $plugname looks like this: attrname[n] clear($buffer); tokenize($compoundParent, "[",$buffer); // Yes. multi compound if( size($buffer) >1 ) { $compoundParent = $buffer[0]; $isMulti = 1; } // attributeQuery does NOT take multi attr. // For ex, `attributeQuery -node "myNode" -listChildren "colors[0]"` is error // Instead, use `attributeQuery -node "myNode" -listChildren "colors" // So, we have to use $compoundParent string $childAttrs[] = `attributeQuery -node $node -listChildren $compoundParent`; // No child! // This attr is not compound. // Return. int $numChildren = size($childAttrs); if( $numChildren == 0 ) return AEnewOther($plugName, $attrName, $changedCommand); string $childType, $childPlug, $childAttrName; // Build UI setUITemplate -pst attributeEditorTemplate; $createdControl = `frameLayout -collapsable true -label $compoundMultiParentNice -borderVisible true -collapse false`; columnLayout -adjustableColumn true; // Check if the child attribute is a multi int $isMultiAttr; for($i=0; $i<$numChildren; $i++) { $childAttrName = $childAttrs[$i]; // Skip attributes that are hidden if(`attributeQuery -hidden -node $node $childAttrName`) { continue; } $childPlug = ($node + "." + $compoundMultiParent + "." + $childAttrName); $childAttrNice = `attributeName -nice $childPlug`; $childType = `getAttr -type $childPlug`; $isMultiAttr = `attributeQuery -node $node -multi $childAttrName`; if($isMultiAttr){ if($isMulti) { // The attribute is an array in an array and this is not supported AEnewOther($childPlug, $childAttrName, $changedCommand); } else { if ($childType == "TdataCompound"){ // Sometimes getAttr -type and attributeQuery -attributeType return different // values. // It would return the same value if we did a call of getAttr -type on one // of the multi child. $childType = `attributeQuery -node $node -attributeType $childAttrName`; } int $indices[] = `getAttr -multiIndices $childPlug`; string $proc = AEgetAttributeTypeProc($childType, `attributeQuery -node $node -usedAsColor $childAttrName`); AEnewNonNumericMulti( $plugName, $childAttrName, $childAttrNice, $changedCommand, $proc, $indices); } } else { string $proc = AEgetAttributeTypeProc($childType, `attributeQuery -node $node -usedAsColor $childAttrName`); string $cc = "\"\""; if ($changedCommand != "") { $cc = ("("+$changedCommand+" \""+$plugName+"\")"); } string $cmd = ($proc + " \"" + $childPlug + "\" \"" + $childAttrNice + "\" " + $cc); eval($cmd); } } if( $isMulti ) { // Delete button setUITemplate -pst attributeEditorMultiTemplate; rowLayout -nc 3; text -label ""; symbolButton -image "smallTrash.png" -command ("AEremoveMultiElement " + $plugName); text -label ""; setParent ..; setUITemplate -ppt; } setParent ..; // columnLayout setParent ..; // frameLayout setUITemplate -popTemplate; return $createdControl; }