Python Reference Guide
 
Loading...
Searching...
No Matches
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
9from pyfbsdk import FBGetSelectedModels, FBModelList
10
11def 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.
20lModelList = FBModelList()
21FBGetSelectedModels( lModelList )
22
23# Iterate thru the list, and delete each one of them...
24if lModelList.count() > 0:
25 DestroyModel( lModelList[0] )
26
27
28# Cleanup
29
30# Cleanup local variables
31del( lModelList, DestroyModel )
32
33# Cleanup things from pyfbsdk
34del( FBGetSelectedModels, FBModelList )
FBGetSelectedModels(FBModelList pList, FBModel pParent=None, bool pSelected=True, bool pSortBySelectOrder=False)
Find all models that are selected (if pSelected is true) Searches recursively from a root model for m...