Groups > Design > Autodesk MotionBuilder Python > Re: Materials not Deleting




Re: Materials not Deleting

Re: Materials not Deleting
Tue, 22 May 2007 17:04:02 +000
This is code I use for deleting groups.

I imagine you could replaced "Groups" with "Materials" but
it's a bit more complex that that.
---------------------------------------------
from pyfbsdk import *

lScene = FBSystem().Scene
allGroups = lScene.Groups
for group in allGroups:
...print group
...group.FBDelete[-1]
...del (group)
----------------------------------------------

From the MotionBuilder examples from the "Delete Unused Media"
script:

-------------------------------------------------------------
from pyfbsdk import FBSystem, FBComponent

lSystem = FBSystem()

# Since the videos are parented to textures, we need to removed unused
# textures before removing the unused videos.

# If the texture does not have any parents, we delete it.
lList = [ lTexture for lTexture in lSystem.Textures if len( lTexture.Parents )
== 0 ]
map( FBComponent.FBDelete, lList )

# If the media does not have any parents, we delete it.
lList = [ lMedia for lMedia in lSystem.Media if len( lMedia.Parents ) == 0 ]
map( FBComponent.FBDelete, lList )

# Cleanup

# Conditional cleanup
if dir().__contains__( 'lTexture' ): del( lTexture )
if dir().__contains__( 'lMedia' ): del( lMedia )

# Cleanup local variables
del( lSystem, lList )

# Cleanup things from pyfbsdk
del( FBSystem, FBComponent )
-------------------------------------------------------------
So it looks like you have to delete the Materials AND the Video as well. I just
replaced the "==" to Not Equal or "!=" and it rips out all
media
Post Reply
about | contact