diff --git a/src/ifcblender/io_import_scene_ifc/__init__.py b/src/ifcblender/io_import_scene_ifc/__init__.py index 6070b0c8e9..4a9b82ed0c 100644 --- a/src/ifcblender/io_import_scene_ifc/__init__.py +++ b/src/ifcblender/io_import_scene_ifc/__init__.py @@ -44,11 +44,15 @@ if "bpy" in locals(): if "IfcImport" in locals(): imp.reload(IfcImport) +import sys import bpy import mathutils from bpy.props import StringProperty, IntProperty, BoolProperty from bpy_extras.io_utils import ImportHelper +wrong_unicode = sys.platform[0:5] == 'linux' and sys.maxunicode==(2**16-1) +warned_about_wrong_unicode = False + bpy.types.Object.ifc_id = IntProperty(name="IFC Entity ID", description="The STEP entity instance name") bpy.types.Object.ifc_guid = StringProperty(name="IFC Entity GUID", @@ -62,7 +66,7 @@ bpy.types.Object.ifc_type = StringProperty(name="IFC Entity Type", def import_ifc(filename, use_names, process_relations): from . import IfcImport print("Reading %s..."%bpy.path.basename(filename)) - if not IfcImport.Init(filename): + if (wrong_unicode and not IfcImport.InitUCS2(''.join(['\0']+['\0%s'%s for s in filename]+['\0\0']))) or (not wrong_unicode and not IfcImport.Init(filename)): return False print("Done reading file") id_to_object = {} @@ -205,6 +209,16 @@ class ImportIFC(bpy.types.Operator, ImportHelper): default=False) def execute(self, context): + global wrong_unicode,warned_about_wrong_unicode + if wrong_unicode and not warned_about_wrong_unicode: + warned_about_wrong_unicode = True + self.report({'WARNING'}, + """This addon has been built with a different unicode configuration +This will result in incorrectly imported text and may result in undefined behaviour +Additionally it will result in IfcSpaces and IfcOpeningElements being visible by default +You can use the offical builds from the blender.org website instead +Sorry for the inconvenience""" + ) if not import_ifc(self.filepath, self.use_names, self.process_relations): self.report({'ERROR'}, 'Unable to parse .ifc file or no geometrical entities found' diff --git a/src/ifcgeom/IfcGeomObjects.cpp b/src/ifcgeom/IfcGeomObjects.cpp index 1b227a0b58..6a8990d63a 100644 --- a/src/ifcgeom/IfcGeomObjects.cpp +++ b/src/ifcgeom/IfcGeomObjects.cpp @@ -435,6 +435,9 @@ const IfcGeomObjects::IfcGeomObject* IfcGeomObjects::Get() { bool IfcGeomObjects::Init(const std::string fn) { return IfcGeomObjects::Init(fn, 0, 0); } +bool IfcGeomObjects::InitUCS2(char* fn) { + return IfcGeomObjects::Init(fn+1, 0, 0); +} bool _Init() { shapereps = Ifc::EntitiesByType(); if ( ! shapereps ) return false; diff --git a/src/ifcgeom/IfcGeomObjects.h b/src/ifcgeom/IfcGeomObjects.h index f24af91d49..6ee2093601 100644 --- a/src/ifcgeom/IfcGeomObjects.h +++ b/src/ifcgeom/IfcGeomObjects.h @@ -116,6 +116,7 @@ namespace IfcGeomObjects { }; bool Init(const std::string fn); + bool InitUCS2(char* fn); bool Init(void* data, int len); bool Init(const std::string fn, std::ostream* log1= 0, std::ostream* log2= 0); bool Init(std::istream& f, int len, std::ostream* log1= 0, std::ostream* log2= 0); diff --git a/src/ifcwrap/Interface.h b/src/ifcwrap/Interface.h index abdcac6d23..333370ddc1 100644 --- a/src/ifcwrap/Interface.h +++ b/src/ifcwrap/Interface.h @@ -49,6 +49,7 @@ namespace IfcGeomObjects { bool Next(); const IfcGeomObject* Get(); bool Init(const std::string fn); + bool InitUCS2(char* fn); void Settings(int setting, bool value); int Progress(); const IfcObject* GetObject(int id);