diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 429920293e..7431c8d566 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -56,6 +56,7 @@ FIND_LIBRARY(icu "icuuc" /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 ${I IF(icu) MESSAGE(STATUS "ICU libraries found") ADD_DEFINITIONS(-DHAVE_ICU) + SET(ICU_LIBRARIES icuuc icudata) ELSE() MESSAGE(STATUS "Unable to find ICU library files, continuing") ENDIF() @@ -170,13 +171,13 @@ ADD_EXECUTABLE(IfcConvert ../src/ifcconvert/util.cpp ) -TARGET_LINK_LIBRARIES (IfcConvert IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKSTEP TKSTEPBase TKSTEPAttr TKXSBase TKSTEP209 TKIGES TKOffset ${Boost_LIBRARIES} ${OPENCOLLADA_LIBRARIES}) +TARGET_LINK_LIBRARIES (IfcConvert IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKSTEP TKSTEPBase TKSTEPAttr TKXSBase TKSTEP209 TKIGES TKOffset ${Boost_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${ICU_LIBRARIES}) ADD_EXECUTABLE(IfcGeomServer ../src/ifcgeomserver/IfcGeomServer.cpp ) -TARGET_LINK_LIBRARIES (IfcGeomServer IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKSTEP TKSTEPBase TKSTEPAttr TKXSBase TKSTEP209 TKIGES TKOffset) +TARGET_LINK_LIBRARIES (IfcGeomServer IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKSTEP TKSTEPBase TKSTEPAttr TKXSBase TKSTEP209 TKIGES TKOffset ${ICU_LIBRARIES}) # Build python wrapper using separate CMakeLists.txt ADD_SUBDIRECTORY(../src/ifcwrap ifcwrap) diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index 388581942b..eb14ece33a 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -82,6 +82,9 @@ class entity_instance(object): attr_type = self.attribute_type(idx).title().replace(' ', '') attr_type = attr_type.replace('Binary', 'String') attr_type = attr_type.replace('Enumeration', 'String') + try: + if isinstance(value, unicode): value = value.encode("utf-8") + except: pass getattr(self.wrapped_data, "setArgumentAs%s" % attr_type)(idx, entity_instance.unwrap_value(value)) return value def __len__(self): return len(self.wrapped_data) diff --git a/src/ifcparse/IfcCharacterDecoder.cpp b/src/ifcparse/IfcCharacterDecoder.cpp index c3eeb186d7..a3aad64c1e 100644 --- a/src/ifcparse/IfcCharacterDecoder.cpp +++ b/src/ifcparse/IfcCharacterDecoder.cpp @@ -288,7 +288,7 @@ UErrorCode IfcCharacterDecoder::status = U_ZERO_ERROR; #endif #ifdef HAVE_ICU -IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON; +IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::UTF8; // Many BIM software (eg. Revit, ArchiCAD, ...) has wrong behavior bool IfcCharacterDecoder::compatibility_mode = false; diff --git a/src/ifcwrap/CMakeLists.txt b/src/ifcwrap/CMakeLists.txt index ba87b658c9..a5a2f36e22 100644 --- a/src/ifcwrap/CMakeLists.txt +++ b/src/ifcwrap/CMakeLists.txt @@ -16,7 +16,7 @@ SET(CMAKE_SWIG_FLAGS "") SET_SOURCE_FILES_PROPERTIES(IfcPython.i PROPERTIES CPLUSPLUS ON) SWIG_ADD_MODULE(ifcopenshell_wrapper python IfcPython.i) -SWIG_LINK_LIBRARIES(ifcopenshell_wrapper ${PYTHON_LIBRARIES} IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKOffset) +SWIG_LINK_LIBRARIES(ifcopenshell_wrapper ${PYTHON_LIBRARIES} IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKOffset ${ICU_LIBRARIES}) # To install IfcPython let's get the site-packages dir from python EXECUTE_PROCESS(COMMAND python -c "import sys; from distutils.sysconfig import get_python_lib; sys.stdout.write(get_python_lib())" diff --git a/src/ifcwrap/utils/type_conversion.i b/src/ifcwrap/utils/type_conversion.i index 1f83559a5f..6c739033d7 100644 --- a/src/ifcwrap/utils/type_conversion.i +++ b/src/ifcwrap/utils/type_conversion.i @@ -110,7 +110,7 @@ PyObject* pythonize(const unsigned int& t) { return PyInt_FromLong(t); } PyObject* pythonize(const bool& t) { return PyBool_FromLong(t); } PyObject* pythonize(const double& t) { return PyFloat_FromDouble(t); } - PyObject* pythonize(const std::string& t) { return PyString_FromString(t.c_str()); } + PyObject* pythonize(const std::string& t) { return PyUnicode_FromString(t.c_str()); } PyObject* pythonize(const IfcUtil::IfcBaseClass* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__IfcLateBoundEntity, 0); } // NB: This cannot be temporary as a Python object is constructed from a pointer to the address of this object PyObject* pythonize(const IfcGeom::Material& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(&t), SWIGTYPE_p_IfcGeom__Material, 0); }