Tasks/DeleteHierarchy.py

Tasks/DeleteHierarchy.py
1 # Copyright 2009 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 #
6 # Topic: FBDelete
7 #
8 
9 from pyfbsdk import FBGetSelectedModels, FBModelList
10 
11 def DestroyModel( pModel ):
12  # Always destroy from the last children to the first
13  while len( pModel.Children ) > 0:
14  DestroyModel( pModel.Children[-1] )
15  print "Destroying model: '%s'" % pModel.Name
16  pModel.FBDelete()
17 
18 
19 # Get the list of selected objects, if any.
20 lModelList = FBModelList()
21 FBGetSelectedModels( lModelList )
22 
23 # Iterate thru the list, and delete each one of them...
24 if lModelList.count() > 0:
25  DestroyModel( lModelList[0] )
26 
27 
28 # Cleanup
29 
30 # Cleanup local variables
31 del( lModelList, DestroyModel )
32 
33 # Cleanup things from pyfbsdk
34 del( FBGetSelectedModels, FBModelList )