@@ -46,43 +46,46 @@ def execute(self, context):
4646 self .filepath = self .filepath .rsplit (sep = "\\ " , maxsplit = 1 )[0 ] + "\\ "
4747
4848 # export model
49+ bpy .ops .object .select_all (action = 'DESELECT' )
4950 for CurrentModel in bpy .data .objects :
5051 if CurrentModel .name .find ("afx." ) != - 1 :
51- # select root
52- CurrentModel .select_set (1 )
53- # select childrens
54- for CurrentChildren in CurrentModel .children :
55- CurrentChildren .select_set (1 )
56- # rename top to root
57- CurrentObjectName = CurrentModel .name
58- CurrentModel .name = self .root_name
59- # export single objects as fbx
60- fullfiles = self .filepath + "/" + CurrentObjectName + ".fbx"
61- if self .skip_meshes :
62- bpy .ops .export_scene .fbx (
63- filepath = fullfiles ,
64- object_types = {'ARMATURE' },
65- use_selection = True ,
66- global_scale = self .global_scale ,
67- bake_anim_use_nla_strips = False ,
68- bake_anim_use_all_actions = False ,
69- bake_anim_simplify_factor = 0 ,
70- add_leaf_bones = False )
71- else :
72- bpy .ops .export_scene .fbx (
73- filepath = fullfiles ,
74- object_types = {'ARMATURE' , 'MESH' },
75- use_selection = True ,
76- global_scale = self .global_scale ,
77- bake_anim_use_nla_strips = False ,
78- bake_anim_use_all_actions = False ,
79- bake_anim_simplify_factor = 0 ,
80- add_leaf_bones = False )
81- # undo all changes
82- CurrentModel .name = CurrentObjectName
83- CurrentModel .select_set (0 )
84- for CurrentChildren in CurrentModel .children :
85- CurrentChildren .select_set (0 )
52+ for o in context .scene .objects :
53+ if o .name == CurrentModel .name :
54+ # select root
55+ CurrentModel .select_set (1 )
56+ # select childrens
57+ for CurrentChildren in CurrentModel .children :
58+ CurrentChildren .select_set (1 )
59+ # rename top to root
60+ CurrentObjectName = CurrentModel .name
61+ CurrentModel .name = self .root_name
62+ # export single objects as fbx
63+ fullfiles = self .filepath + "/" + CurrentObjectName + ".fbx"
64+ if self .skip_meshes :
65+ bpy .ops .export_scene .fbx (
66+ filepath = fullfiles ,
67+ object_types = {'ARMATURE' },
68+ use_selection = True ,
69+ global_scale = self .global_scale ,
70+ bake_anim_use_nla_strips = False ,
71+ bake_anim_use_all_actions = False ,
72+ bake_anim_simplify_factor = 0 ,
73+ add_leaf_bones = False )
74+ else :
75+ bpy .ops .export_scene .fbx (
76+ filepath = fullfiles ,
77+ object_types = {'ARMATURE' , 'MESH' },
78+ use_selection = True ,
79+ global_scale = self .global_scale ,
80+ bake_anim_use_nla_strips = False ,
81+ bake_anim_use_all_actions = False ,
82+ bake_anim_simplify_factor = 0 ,
83+ add_leaf_bones = False )
84+ # undo all changes
85+ CurrentModel .name = CurrentObjectName
86+ CurrentModel .select_set (0 )
87+ for CurrentChildren in CurrentModel .children :
88+ CurrentChildren .select_set (0 )
8689
8790 # export camera
8891 for CameraData in bpy .data .objects :
0 commit comments