# 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, FBComponent.Name # from pyfbsdk import FBSystem, FBMessageBoxGetUserValue, FBPopupInputType # Get the value of the suffix to remove from the user. (lRes, lSuffix ) = FBMessageBoxGetUserValue( "Enter suffix", "Enter suffix to remove: ", "_1", FBPopupInputType.kFBPopupString, "OK", "Cancel" ) # Insure that the suffix is valid (i.e. not None) and that the user clicked # on the "OK" button. if lSuffix and lRes == 1: # Get the scene from the system. lScene = FBSystem().Scene # Now iterate the flat list of components in the system. for lComponent in lScene.Components: # Insure that we have a valid component. if lComponent: # Let's see if the name of the component ends with the # suffix to be removed. if lComponent.Name.endswith( lSuffix ): # Rename the component when necessary. lComponent.Name = lComponent.Name.replace( lSuffix, "" ) # Cleanup. del( lComponent ) # Cleanup. del( lScene ) # Cleanup. # Cleanup local variables. del( lRes, lSuffix ) # Cleanup things from pyfbsdk. del( FBSystem, FBMessageBoxGetUserValue, FBPopupInputType )