mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 14:31:39 +00:00
Fixes for unicode handling in Python
This commit is contained in:
@@ -56,6 +56,7 @@ FIND_LIBRARY(icu "icuuc" /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 ${I
|
|||||||
IF(icu)
|
IF(icu)
|
||||||
MESSAGE(STATUS "ICU libraries found")
|
MESSAGE(STATUS "ICU libraries found")
|
||||||
ADD_DEFINITIONS(-DHAVE_ICU)
|
ADD_DEFINITIONS(-DHAVE_ICU)
|
||||||
|
SET(ICU_LIBRARIES icuuc icudata)
|
||||||
ELSE()
|
ELSE()
|
||||||
MESSAGE(STATUS "Unable to find ICU library files, continuing")
|
MESSAGE(STATUS "Unable to find ICU library files, continuing")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
@@ -170,13 +171,13 @@ ADD_EXECUTABLE(IfcConvert
|
|||||||
../src/ifcconvert/util.cpp
|
../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
|
ADD_EXECUTABLE(IfcGeomServer
|
||||||
../src/ifcgeomserver/IfcGeomServer.cpp
|
../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
|
# Build python wrapper using separate CMakeLists.txt
|
||||||
ADD_SUBDIRECTORY(../src/ifcwrap ifcwrap)
|
ADD_SUBDIRECTORY(../src/ifcwrap ifcwrap)
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ class entity_instance(object):
|
|||||||
attr_type = self.attribute_type(idx).title().replace(' ', '')
|
attr_type = self.attribute_type(idx).title().replace(' ', '')
|
||||||
attr_type = attr_type.replace('Binary', 'String')
|
attr_type = attr_type.replace('Binary', 'String')
|
||||||
attr_type = attr_type.replace('Enumeration', '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))
|
getattr(self.wrapped_data, "setArgumentAs%s" % attr_type)(idx, entity_instance.unwrap_value(value))
|
||||||
return value
|
return value
|
||||||
def __len__(self): return len(self.wrapped_data)
|
def __len__(self): return len(self.wrapped_data)
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ UErrorCode IfcCharacterDecoder::status = U_ZERO_ERROR;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ICU
|
#ifdef HAVE_ICU
|
||||||
IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON;
|
IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::UTF8;
|
||||||
|
|
||||||
// Many BIM software (eg. Revit, ArchiCAD, ...) has wrong behavior
|
// Many BIM software (eg. Revit, ArchiCAD, ...) has wrong behavior
|
||||||
bool IfcCharacterDecoder::compatibility_mode = false;
|
bool IfcCharacterDecoder::compatibility_mode = false;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ SET(CMAKE_SWIG_FLAGS "")
|
|||||||
|
|
||||||
SET_SOURCE_FILES_PROPERTIES(IfcPython.i PROPERTIES CPLUSPLUS ON)
|
SET_SOURCE_FILES_PROPERTIES(IfcPython.i PROPERTIES CPLUSPLUS ON)
|
||||||
SWIG_ADD_MODULE(ifcopenshell_wrapper python IfcPython.i)
|
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
|
# 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())"
|
EXECUTE_PROCESS(COMMAND python -c "import sys; from distutils.sysconfig import get_python_lib; sys.stdout.write(get_python_lib())"
|
||||||
|
|||||||
@@ -110,7 +110,7 @@
|
|||||||
PyObject* pythonize(const unsigned int& t) { return PyInt_FromLong(t); }
|
PyObject* pythonize(const unsigned int& t) { return PyInt_FromLong(t); }
|
||||||
PyObject* pythonize(const bool& t) { return PyBool_FromLong(t); }
|
PyObject* pythonize(const bool& t) { return PyBool_FromLong(t); }
|
||||||
PyObject* pythonize(const double& t) { return PyFloat_FromDouble(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); }
|
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
|
// 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); }
|
PyObject* pythonize(const IfcGeom::Material& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(&t), SWIGTYPE_p_IfcGeom__Material, 0); }
|
||||||
|
|||||||
Reference in New Issue
Block a user