// =========================================================================== // 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. // =========================================================================== proc int isInitialStateAttr( string $attr ) { int $s = size( $attr ); if( $s > 0 ) { string $last = substring( $attr, $s, $s ); if( $last == "0" ) return 1; } return 0; } proc int isCachedAttr( string $attr ) { int $s = size( $attr ); if( $s > 5 ) { string $last5 = substring( $attr, $s - 4, $s ); if( $last5 == "Cache" ) return 1; } if( $s > 6 ) { string $first6 = substring( $attr, 1, 6 ); if( $first6 == "cached" ) return 1; } return 0; } proc int isArrayAttr( string $node, string $attr ) { string $typeStr = `getAttr -type ($node+"."+$attr)`; int $s = size( $typeStr ); if( $s > 5 ) { string $last5 = substring( $typeStr, $s - 4, $s ); if( $last5 == "Array" ) return 1; } return 0; } proc int isSuppressedAttr( string $attr ) { string $suppressedAttrs[]; $suppressedAttrs = { "emitterDataPosition", "emitterDataVelocity", "fieldDataMass", "fieldDataPosition", "fieldDataVelocity", "inputGeometryPoints", "lastCachedPosition", "lastPosition", "lastVelocity", "lastWorldPosition", "lastWorldVelocity", "worldVelocityInObjectSpace" }; $suppressedAttrs = sort( $suppressedAttrs ); if( size($attr) == 0 ) return 0; int $i; for( $i = 0; $i < size($suppressedAttrs); $i ++ ) { int $cmp = strcmp( $suppressedAttrs[$i], $attr ); if( $cmp == 0 ) return 1; if( $cmp > 0 ) return 0; } return 0; } proc int isValidAttr( string $node, string $attr, string $type, int $showAll, int $newOnly ) { if( size( $attr ) ==0 ) return 0; if( $newOnly == 0 ) { if( `attributeQuery -exists -node $node $attr` == 0 ) return 0; } if( $showAll == 0 ) { string $typeStr = `getAttr -type ($node+"."+$attr)`; if( $typeStr != $type ) return 0; } if( isInitialStateAttr( $attr ) ) return 0; if( isCachedAttr( $attr ) ) return 0; if( $newOnly == 0 ) { if( `attributeQuery -multi -node $node $attr` == 1 ) return 0; if( isSuppressedAttr( $attr ) ) return 0; } return 1; } global proc string[] listParticleAttrs( string $particle, string $typeStr, int $showAll ) // // type: // // typeStr: vectorArray, doubleArray, all // // { string $attrs[]; clear( $attrs ); string $defaultVectorAttrs[] = { "acceleration", "force", "position", "rampAcceleration", "rampPosition", "rampVelocity", "velocity", "worldPosition", "worldVelocity" }; string $defaultDoubleAttrs[] = { "age", "birthTime", "mass", "particleId" }; string $defaultAllVectorAttrs[] = { "acceleration", "force", "position", "rampAcceleration", "rampPosition", "rampVelocity", "velocity", "worldPosition", "worldVelocity", "age", "birthTime", "mass", "particleId" }; string $defaultAllDoubleAttrs[] = { "age", "birthTime", "mass", "particleId", "acceleration", "force", "position", "rampAcceleration", "rampPosition", "rampVelocity", "velocity", "worldPosition", "worldVelocity" }; if( ( $typeStr != "vectorArray" ) && ( $typeStr != "doubleArray" ) ) { $showAll = 1; $typeStr = "vectorArray"; } if( $showAll == 0 ) { if( $typeStr == "vectorArray" ) { $attrs = $defaultVectorAttrs; } else { $attrs = $defaultDoubleAttrs; } } else { if( $typeStr == "vectorArray" ) { $attrs = $defaultAllVectorAttrs; } else { $attrs = $defaultAllDoubleAttrs; } } int $exists = `objExists $particle`; if( $exists == 0 ) return $attrs; string $particlesWithThisName[] = `ls -type particle $particle`; int $numParticles = size($particlesWithThisName); if( $numParticles == 0 ) { string $fmt = (uiRes("m_listParticleAttrs.kNoParticleExists")); error( `format -s $particle $fmt` ); return $attrs; } else if( $numParticles > 1 ) { string $fmt = (uiRes("m_listParticleAttrs.kManyParticleExist")); error( `format -s $numParticles -s $particle $fmt` ); return $attrs; } string $allAttrs[]; clear $allAttrs; $allAttrs = `listAttr -a -ud $particle`; int $i; for( $i = 0; $i < size( $allAttrs ); $i ++ ) { if( isValidAttr( $particle, $allAttrs[$i], $typeStr, $showAll, 1 ) ) $attrs[size($attrs)] = $allAttrs[$i]; } // Get any user define attributes that are not array attributes. They where // processed above. // clear $allAttrs; $allAttrs = `listAttr -ud -s $particle`; for( $i = 0 ; $i < size( $allAttrs ); $i ++ ) { if ( isValidAttr( $particle, $allAttrs[$i], $typeStr, $showAll, 1 ) ) $attrs[size( $attrs )] = $allAttrs[$i]; } // $attrs = sort( $attrs ); return $attrs; } // // This is just to keep the initialization of $suppressedAttrs // from being displayed. // print("");