# Copyright 2009 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. # # Topic: FBmessageBoxGetUserValue, FBPopupInputType, FBModelRoot, FBScene # from pyfbsdk import FBSystem, FBMessageBoxGetUserValue, FBPopupInputType # This recursive function selects the children that match the pattern and # calls itself to inspect the whole hierarchy. def SelectModels( pRoot, pPattern ): # Insure that we have a valid root and pattern. if pRoot and pPattern: # For each children, tag it if necessary and see its own children. for lChild in pRoot.Children: # If the pattern is not found, -1 is returned. Any other values # means success. if lChild.Name.find( pPattern ) != -1: lChild.Selected = True # Recurse. SelectModels( lChild, pPattern ) # Get the substring that we want to match in the model name. (lRes, lPattern ) = FBMessageBoxGetUserValue( "Enter pattern", "Enter pattern of model name to select: ", "Cube", FBPopupInputType.kFBPopupString, "OK", "Cancel" ) # Insure that the pattern is valid (i.e. not None) and that the user clicked # on the "OK" button. if lPattern and lRes == 1: # Get the scene from the system. lScene = FBSystem().Scene # Start the search. SelectModels( lScene.RootModel, lPattern ) # Cleanup. del( lScene ) # Cleanup. # Cleanup local variables. del( lRes, lPattern ) # Cleanup local functions. del( SelectModels ) # Cleanup things from pyfbsdk. del( FBSystem, FBMessageBoxGetUserValue, FBPopupInputType )