Tasks/DeleteUnusedMedia.py

Tasks/DeleteUnusedMedia.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: FBTexture, FBScene, FBVideo
7 #
8 
9 from pyfbsdk import FBSystem, FBComponent
10 
11 lSystem = FBSystem()
12 
13 # Since the videos are parented to textures, we need to removed unused
14 # textures before removing the unused videos.
15 
16 # Delete any texture whose only parent is Scene.
17 lList = [ lTexture for lTexture in lSystem.Scene.Textures if (len( lTexture.Parents ) == 1 and lTexture.Parents[0].Name=="Scene") ]
18 map( FBComponent.FBDelete, lList )
19 
20 # Delete any VideoClip whose only parent is Scene.
21 lList = [ lMedia for lMedia in lSystem.Scene.VideoClips if (len( lMedia.Parents ) == 1 and lMedia.Parents[0].Name=="Scene") ]
22 map( FBComponent.FBDelete, lList )
23 
24 
25 # Cleanup
26 
27 # Conditional cleanup
28 if dir().__contains__( 'lTexture' ): del( lTexture )
29 if dir().__contains__( 'lMedia' ): del( lMedia )
30 
31 # Cleanup local variables
32 del( lSystem, lList )
33 
34 # Cleanup things from pyfbsdk
35 del( FBSystem, FBComponent )