# 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: FBDelete
#

from pyfbsdk import FBGetSelectedModels, FBModelList

def DestroyModel( pModel ):
    # Always destroy from the last children to the first
    while len( pModel.Children ) > 0:
        DestroyModel( pModel.Children[-1] )
    print "Destroying model: '%s'" % pModel.Name
    pModel.FBDelete()


# Get the list of selected objects, if any.
lModelList = FBModelList()
FBGetSelectedModels( lModelList )

# Iterate thru the list, and delete each one of them...
for lModel in lModelList:
    DestroyModel( lModel )


# Cleanup

# Cleanup local variables
del( lModelList, DestroyModel )

# Cleanup things from pyfbsdk
del( FBGetSelectedModels, FBModelList )