Writing Property Filters

In a 3D view, a property filter can filter the selection of constraints, joints, and operators.

In a schematic view, a property filter can filter the selection of materials (and of particle types). Note that in a schematic view, property filters do not modify the selection of constraint and operator links: Softimage does not call the filter when a user selects a link in the schematic view.

Property filters are not available in explorer views.

The following example shows a property filter that filters out inactive constraints, so that only active constraints are selected.

function ActiveConstraints_Match( oContext )
{
   // Get the Constraint object
   var oObject = oContext.GetAttribute( "Input" );
   var bMatch = false;

   // Check if the object is an active constraint
   if ( oObject.BelongsTo( siConstraintFamily ) && oObject.Parameters.Item("active").Value == true )
   {
       bMatch = true;
   }

   return( bMatch );
}

Property filters that work with constraints, joints, and operators require certain camera visibility options in a 3D view:

• For constraints and operators, relation links must be visible in the 3D view (press Shift+S, and on the Attributes property page, select the Relations check boxes).

• For joints, the joints must be visible in the 3D view (press Shift+S, and on the Attributes property page, select the Chain Joint Rotation Limits check boxes).

Note that clicking anywhere in a 3D view triggers the Match callback for each constraint, joint, and operator in the scene, but Softimage selects only the properties, if any, the user clicked.

You can also use a property filter to select objects based on their properties. For example, Softimage includes a Local Material property filter that selects objects with local materials. The Local Material filter shipped with Softimage is written in VBScript; a JScript version is shown below.

function MyLocalMaterial_Match( oContext )
{
   // Get the input object, which could a Primitive, X3DObject, Constraint, Joint, ...
   var oInput = oContext.GetAttribute( "Input" );

   // Return value
   var bMatch = false;

   // Try to get a 3D object from the input object
   var o3DObject = Get3DObject( oInput );

   // If we have a 3D object, check its local properties for a material
   if ( o3DObject != null && classname( o3DObject ) == "X3DObject" )
   {
       for (var enumerator = new Enumerator( o3DObject.LocalProperties ) ; !enumerator.atEnd(); enumerator.moveNext())
       {
          var oProperty = enumerator.item();
          if ( classname( oProperty ) == "Material" )
          {
              bMatch = true;
              break;
          }
       }

   }

   return ( bMatch );
}

Property filters have to be able to handle any type of object, because they don't always get a 3D object from Softimage. For example, when a user uses the mouse to select objects in a 3D view, the filter gets Primitive objects, not X3DObjects. In addition, Softimage calls the Match callback for every constraint, joint, and operator in the scene.

function Get3DObject( oObject )
{
   var o3DObject = null;

   if ( classname( oObject ) == "X3DObject"  )
   {
       o3DObject = oObject ;
   }
   else if ( classname( oObject ) == "Primitive" )
   {
       o3DObject = oObject.Parent;
   }

   return( o3DObject );
}


Autodesk Softimage 2011