Instantly share code, notes, and snippets.

What would you like to do?
This is used with the FBX_Scene Class in cleaning up an exported skeletal mesh fbx
import FBX_Scene
import FbxCommon
def clean_character_scene(fbx_filename):
Clean up character fbx file
# open the fbx scenes and get the scene nodes
fbx_file = FBX_Class(fbx_filename)
if not fbx_file:
return False
# remove invalid nodes noted by properties assigned in the DCC application
all_nodes = fbx_file.get_scene_nodes()
remove_names = []
for node in all_nodes:
export_property = fbx_file.get_property(node, 'no_export')
if export_property:
property_value = fbx_file.get_property_value(node, 'no_export')
if property_value == True:
node_name = node.GetName()
# need to disconnect before deleting/removing
# remove the nodes from the scene by name
# remove display layers
# For some reason these change FbxCollection ID and NodeName
layer_nodes = fbx_file.get_class_nodes(fbx.FbxCollectionExclusive.ClassId)
if layer_nodes:
remove_layers(fbx_file, layer_nodes)
# remove FbxContainers
nodes = fbx_file.get_class_nodes(fbx.FbxObject.ClassId)
if nodes:
for node in fbx_objects:
if node.GetClassId().GetName() == 'FbxContainer':
# disconnect the layer from the scene
# remove display layers
display_layers = fbx_file.get_type_nodes( u'DisplayLayer')
if display_layers:
remove_layers(fbx, display_layers)
# save the modified fbx scene
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment