March 2019: ewertb.soundlinker.com is getting relocated to ewertb.mayasound.com, please update your bookmarks.

MEL How-To #71

Back · Previous · Next Maya

How do I determine what Blind Data types are defined and assigned?

MEL includes 'blindDataType', 'polyBlindData' and 'polyQueryBlindData' commands to control and query Blind Data. It is these commands which are used by Maya's Blind Data Editor. To fully understand how and why Blind Data does what it does it's useful to know how Maya stores Blind Data within a scene.

When you create a Blind Data Type in the Blind Data Editor, Maya creates a ‘blindDataTemplate’ node with this information. The ".typeID" is a native attributes of this node, and any attributes you create for the Type are added as Extra Attributes to this node.

When you assign this Blind Data Type to a poly object, Maya creates a ‘polyBlindData’ node, assigned with the ID for the Type, and attaches it upstream of the object. The assignment data is written as attributes to this node.


blindDataTemplate

To find the nodes representing which Blind Data Types are currently defined in the scene:

ls -type "blindDataTemplate";
Example:
string $blindDataTemplates[] = `ls -type "blindDataTemplate"`;

for ( $template in $blindDataTemplates )
{
  int $id = `getAttr ( $template + ".typeId" )`;

  print ( "Blind Data ID #" + $id + " found.\n" );
};
Blind Data ID #1222 found.
Blind Data ID #9001 found.
The configuration for the Blind Data type is defined via its compound attribute ".bdUserInfo". You can use this attribute to determine the association type for the Blind Data, for example.
string $blindDataTemplates[] = `ls -type "blindDataTemplate"`;

for ( $template in $blindDataTemplates )
{
  int $id = `getAttr ( $template + ".typeId" )`;

  print ( "Blind Data ID #" + $id + " found.\n" );

  // Get configuration info for this Blind Data
  int $compoundSize = `getAttr -size ( $template + ".bdui" )`;

  string $userInfoName;
  string $userInfoValue;
  string $attrInfoName;
  string $attrInfoValue;

  for ( $i = 0; $i < $compoundSize; $i++ )
  {
    // String assignments expanded for clarity

    // start with node
    $attrInfoName = $template;
    // extend to array element for .bdUserInfo
    $attrInfoName += ( ".bdui[" + $i + "]" );
    // extend to .bdUserInfoName
    $attrInfoName += ( ".bdun" );

    $userInfoName = `getAttr $attrInfoName`;

    // start with node
    $attrInfoValue = $template;
    // extend to array element for .bdUserInfo
    $attrInfoValue += ( ".bdui[" + $i + "]" );
    // extend to .bdUserInfoValue
    $attrInfoValue += ( ".bduv" );

    $userInfoValue = `getAttr $attrInfoValue`;

    // Skip if name is blank
    if ( $userInfoName != "" )
    {
      print ( $userInfoName + " = \"" + $userInfoValue + "\"\n" );
    }
  }

  print "\n";
};
Blind Data ID #1222 found.
typeTag = "groupID"
assocType = "vertex"
freeSet = "1"
dataCount = "1"
group = "int"

Blind Data ID #9001 found.
typeTag = "collisionType"
assocType = "object"
freeSet = "1"
dataCount = "1"
sector = "int"

polyBlindData

To find the nodes representing Blind Data that has been assigned to polymesh components:

ls -type "polyBlindData";
// Result: polyBlindData1 polyBlindData2 //

You'll need to do a bit more work to determine to which objects this polyBlindData is assigned. These nodes are part of the object's upstream graph, so you can use the listConnections MEL command to trace downstream from the polyBlindData node until you find the object at the end of the chain.

If the Blind Data assignment is part of the object's Construction History then it will be networked from the ‘polyBlindData.outMesh’ attribute to the object's ‘.inMesh’. If the Construction History has been collapsed then it will be networked from the ‘polyBlindData.message’ attribute into the object's ‘.blindDataNodes[]’ array attribute.

listConnections -shapes true -plugs true polyBlindData2.message;
// Result: pCylinderShape1.blindDataNodes[0] //

Object-Level Blind Data

The ‘polyBlindData’ nodes are used for component-level Blind Data on polygon objects, but not for object-level Blind Data. Objects are assigned Blind Data via a custom attribute. The name of the attribute is "BlindData####" where "####" is the Type ID for the Blind Data.

listAttr -ud pCylinderShape1;
// Result: BlindData9001 collisionAttr //

Note: As of Maya v4.0 the 'polyQueryBlindData' MEL command is able to query the object-level Blind Data it creates. In previous versions of Maya it is not possible to query object-level Blind Data. Remember that you must specify (or select) the shape node to successfully retrieve Blind Data with an "object" association type.

Friday, August 31, 2001