diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-05-11 17:37:02 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-05-11 17:37:02 +0300 |
commit | 9524a08a60cf570e9b0540a6ae195a269b403817 (patch) | |
tree | cb5a09ecb36adbcd8c45ea041fea1d1f5745853d | |
parent | 1b00d422461a917623b751b3eb82ad7b522fc273 (diff) |
Fix (unreported) broken FBX import due to API change.
Sequell to rB55d0ff708c617f, grrrrr....
-rw-r--r-- | io_scene_fbx/__init__.py | 2 | ||||
-rw-r--r-- | io_scene_fbx/import_fbx.py | 28 |
2 files changed, 14 insertions, 16 deletions
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py index 693cfe7d..dfe55f17 100644 --- a/io_scene_fbx/__init__.py +++ b/io_scene_fbx/__init__.py @@ -21,7 +21,7 @@ bl_info = { "name": "FBX format", "author": "Campbell Barton, Bastien Montagne, Jens Restemeier", - "version": (4, 14, 7), + "version": (4, 14, 8), "blender": (2, 80, 0), "location": "File > Import-Export", "description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions", diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index 26e31363..92f9bef4 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -1928,7 +1928,7 @@ class FbxImportHelperNode: child_connect_finalize(bone, connect_ctx) return bone - def build_node_obj(self, fbx_tmpl, settings): + def build_node_obj(self, fbx_tmpl, settings, view_layer): if self.bl_obj: return self.bl_obj @@ -1948,13 +1948,19 @@ class FbxImportHelperNode: # Misc Attributes obj.color[0:3] = elem_props_get_color_rgb(fbx_props, b'Color', (0.8, 0.8, 0.8)) - obj.hide_viewport = not bool(elem_props_get_visibility(fbx_props, b'Visibility', 1.0)) obj.matrix_basis = self.get_matrix() if settings.use_custom_props: blen_read_custom_properties(self.fbx_elem, obj, settings) + # Instance in scene. + view_layer.active_layer_collection.collection.objects.link(obj) + + # This has to be done after instancing in scene. + obj.hide_set(not bool(elem_props_get_visibility(fbx_props, b'Visibility', 1.0))) + obj.select_set(True) + return obj def build_skeleton_children(self, fbx_tmpl, settings, scene, view_layer): @@ -1966,7 +1972,7 @@ class FbxImportHelperNode: return None else: # child is not a bone - obj = self.build_node_obj(fbx_tmpl, settings) + obj = self.build_node_obj(fbx_tmpl, settings, view_layer) if obj is None: return None @@ -1976,10 +1982,6 @@ class FbxImportHelperNode: continue child.build_skeleton_children(fbx_tmpl, settings, scene, view_layer) - # instance in scene - view_layer.active_layer_collection.collection.objects.link(obj) - obj.select_set(True) - return obj def link_skeleton_children(self, fbx_tmpl, settings, scene): @@ -2112,8 +2114,8 @@ class FbxImportHelperNode: # Switch to Edit mode. view_layer.objects.active = arm - is_hidden = arm.hide_viewport - arm.hide_viewport = False # Can't switch to Edit mode hidden objects... + is_hidden = arm.hide_get() + arm.hide_set(False) # Can't switch to Edit mode hidden objects... bpy.ops.object.mode_set(mode='EDIT') for child in self.children: @@ -2124,7 +2126,7 @@ class FbxImportHelperNode: bpy.ops.object.mode_set(mode='OBJECT') - arm.hide_viewport = is_hidden + arm.hide_set(is_hidden) # Set pose matrix for child in self.children: @@ -2141,16 +2143,12 @@ class FbxImportHelperNode: return arm elif self.fbx_elem and not self.is_bone: - obj = self.build_node_obj(fbx_tmpl, settings) + obj = self.build_node_obj(fbx_tmpl, settings, view_layer) # walk through children for child in self.children: child.build_hierarchy(fbx_tmpl, settings, scene, view_layer) - # instance in scene - view_layer.active_layer_collection.collection.objects.link(obj) - obj.select_set(True) - return obj else: for child in self.children: |