From 63e39003ae8aed86dc33824c19f6f4dcdc751ca5 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 6 Dec 2011 11:04:05 +0000 Subject: [PATCH] Correct parent names if using the unicode compatibilty layer --- .../io_import_scene_ifc/__init__.py | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/ifcblender/io_import_scene_ifc/__init__.py b/src/ifcblender/io_import_scene_ifc/__init__.py index 7c57f5af79..dc8d025936 100644 --- a/src/ifcblender/io_import_scene_ifc/__init__.py +++ b/src/ifcblender/io_import_scene_ifc/__init__.py @@ -165,9 +165,20 @@ def import_ifc(filename, use_names, process_relations): if parent_ob.id == -1: bob = None else: + if wrong_unicode: + parent_ob_name = ''.join( + [chr(c) for c in parent_ob.name_as_intvector()]) + parent_ob_type = ''.join( + [chr(c) for c in parent_ob.type_as_intvector()]) + parent_ob_guid = ''.join( + [chr(c) for c in parent_ob.guid_as_intvector()]) + else: + parent_ob_name, parent_ob_type, parent_ob_guid = \ + parent_ob.name, parent_ob.type, parent_ob.guid + m = parent_ob.matrix - nm = parent_ob.name if len(parent_ob.name) and use_names \ - else parent_ob.guid + nm = parent_ob_name if len(parent_ob_name) and use_names \ + else parent_ob_guid bob = bpy.data.objects.new(nm, None) id_to_matrix[parent_ob.id] = mathutils.Matrix(( [m[0], m[1], m[2], 0], @@ -177,14 +188,8 @@ def import_ifc(filename, use_names, process_relations): bpy.context.scene.objects.link(bob) bob.ifc_id = parent_ob.id - if wrong_unicode: - bob.ifc_name = ''.join([chr(c) for c in parent_ob.name_as_intvector()]) - bob.ifc_type = ''.join([chr(c) for c in parent_ob.type_as_intvector()]) - bob.ifc_guid = ''.join([chr(c) for c in parent_ob.guid_as_intvector()]) - else: - bob.ifc_name = parent_ob.name - bob.ifc_type = parent_ob.type - bob.ifc_guid = parent_ob.guid + bob.ifc_name, bob.ifc_type, bob.ifc_guid = \ + parent_ob_name, parent_ob_type, parent_ob_guid if parent_ob.parent_id > 0: id_to_parent[parent_id] = parent_ob.parent_id @@ -240,7 +245,7 @@ class ImportIFC(bpy.types.Operator, ImportHelper): 'Your version of Blender is incompatible with IfcBlender\n' \ 'Please use the offical release from http://blender.org instead' ) - if not import_ifc(self.filepath, self.use_names, self.process_relations): + elif not import_ifc(self.filepath, self.use_names, self.process_relations): self.report({'ERROR'}, 'Unable to parse .ifc file or no geometrical entities found' )