TrackCollection.Filter.2.pys Example
Applies To
TrackCollection.Filter method
Description
This example demonstrates how to use the Filter method to find any owners who are of a specific family (in this case, the "Groups" family). It also demonstrates a number of issues related to working with Python in the SDK, such as how to call commands and methods or properties on global objects (instrinsic), and how to get around using output arguments. Set up a new scene (Python needs all commands to be treated as methods of the Application object and all global objects to be explicitly named)
Code
Application.NewScene( "", 0 ) # Python can't handle the output object, so we use an ISIVTCollection instead # when we add a new camera to the scene cam3DObj = Application.SIGetPrimCamera( "Camera" )(0) Application.LogMessage( "Collection contains these items:" ) for i in cam3DObj.Owners: Application.LogMessage( " - item " + i.Name ) Application.LogMessage( "------------" ) # The Family filter criteria will include both groups and cameras family_list = [ "Groups", "Camera" ] # Get a list of owners for the new camera (but only if they are members # of either the "Groups" or "Camera" families coll2filter = cam3DObj.Owners.Filter( "", family_list ) Application.LogMessage( "Filtered collection now contains these items:" ) for fi in coll2filter: Application.LogMessage( "found item " + fi.Name ) # Output of the above script: #INFO : Collection contains these items: #INFO : - item Scene_Root #INFO : - item Layer_Default #INFO : ------------ #INFO : Filtered collection now contains these items: #INFO : found item Layer_Default
Related Examples
Keywords
TrackCollection Filter
Autodesk Softimage 2011