diff --git a/PyRxCore/PyBrxBim.cpp b/PyRxCore/PyBrxBim.cpp index 86339af1..cb194379 100644 --- a/PyRxCore/PyBrxBim.cpp +++ b/PyRxCore/PyBrxBim.cpp @@ -210,18 +210,18 @@ BOOST_PYTHON_MODULE(PyBrxBim) .export_values() ; enum_("IfcValueType") - .value("eBool,", Ice::IfcApi::ValueType::eBool) - .value("eInt,", Ice::IfcApi::ValueType::eInt) - .value("eUInt,", Ice::IfcApi::ValueType::eUInt) - .value("eReal,", Ice::IfcApi::ValueType::eReal) - .value("eString,", Ice::IfcApi::ValueType::eString) - .value("eEntity,", Ice::IfcApi::ValueType::eEntity) + .value("eBool", Ice::IfcApi::ValueType::eBool) + .value("eInt", Ice::IfcApi::ValueType::eInt) + .value("eUInt", Ice::IfcApi::ValueType::eUInt) + .value("eReal", Ice::IfcApi::ValueType::eReal) + .value("eString", Ice::IfcApi::ValueType::eString) + .value("eEntity", Ice::IfcApi::ValueType::eEntity) .value("eLogical", Ice::IfcApi::ValueType::eLogical) - .value("eBinary,", Ice::IfcApi::ValueType::eBinary) - .value("eGuid,", Ice::IfcApi::ValueType::eGuid) - .value("eEnum,", Ice::IfcApi::ValueType::eEnum) - .value("eSelect,", Ice::IfcApi::ValueType::eSelect) - .value("eVector,", Ice::IfcApi::ValueType::eVector) + .value("eBinary", Ice::IfcApi::ValueType::eBinary) + .value("eGuid", Ice::IfcApi::ValueType::eGuid) + .value("eEnum", Ice::IfcApi::ValueType::eEnum) + .value("eSelect", Ice::IfcApi::ValueType::eSelect) + .value("eVector", Ice::IfcApi::ValueType::eVector) .value("eEmpty", Ice::IfcApi::ValueType::eEmpty) .export_values() ; diff --git a/PyRxCore/PyBrxIFC.cpp b/PyRxCore/PyBrxIFC.cpp index e5c7d135..f5718d55 100644 --- a/PyRxCore/PyBrxIFC.cpp +++ b/PyRxCore/PyBrxIFC.cpp @@ -80,8 +80,14 @@ Ice::IfcApi::Guid* PyIfcGuid::impObj(const std::source_location& src /*= std::so //PyIfcString void makePyIfcStringWrapper() { + constexpr const std::string_view ctor = "Overloads:\n" + "- None: Any\n" + "- text: str\n"; + PyDocString DS("IfcString"); class_("IfcString") + .def(init<>()) + .def(init(DS.CTOR(ctor))) .def("getEncoded", &PyIfcString::getEncoded, DS.ARGS()) .def("c_str", &PyIfcString::c_str, DS.ARGS()) .def("isEmpty", &PyIfcString::isEmpty, DS.ARGS()) @@ -106,6 +112,11 @@ PyIfcString::PyIfcString(const Ice::IfcApi::String& pObject) { } +PyIfcString::PyIfcString(const std::string& val) + : PyIfcString(new Ice::IfcApi::String(utf8_to_wstr(val).c_str()), true) +{ +} + const std::string PyIfcString::getEncoded() const { return std::string{ impObj()->getEncoded() }; diff --git a/PyRxCore/PyBrxIFC.h b/PyRxCore/PyBrxIFC.h index 7977ba36..b3317940 100644 --- a/PyRxCore/PyBrxIFC.h +++ b/PyRxCore/PyBrxIFC.h @@ -39,6 +39,7 @@ class PyIfcString { public: PyIfcString(); + PyIfcString(const std::string& val); PyIfcString(const Ice::IfcApi::String& pObject); PyIfcString(Ice::IfcApi::String* pObject, bool autoDelete); ~PyIfcString() = default; diff --git a/PyRxStubs/PyBrxBim.pyi b/PyRxStubs/PyBrxBim.pyi index 5ef53b1b..cdafc6ef 100644 --- a/PyRxStubs/PyBrxBim.pyi +++ b/PyRxStubs/PyBrxBim.pyi @@ -1282,11 +1282,16 @@ class IfcSelectorDesc(object): ... class IfcString(object): - def __init__ (self, *args, **kwargs)-> None : - '''__init__( (object)arg1) -> None : - C++ signature : - void __init__(struct _object * __ptr64)''' + @overload + def __init__ (self, /)-> None : ... + @overload + def __init__ (self, text: str)-> None : ... + def __init__ (self, *args, **kwargs)-> None : + '''Overloads: + - None: Any + - text: str + ''' ... def c_str (self)-> str : ''' ''' @@ -1312,43 +1317,43 @@ class IfcString(object): ... class IfcValueType(object): - def eBinary, (self, *args, **kwargs)-> None : + def eBinary (self, *args, **kwargs)-> None : '''None''' ... - def eBool, (self, *args, **kwargs)-> None : + def eBool (self, *args, **kwargs)-> None : '''None''' ... def eEmpty (self, *args, **kwargs)-> None : '''None''' ... - def eEntity, (self, *args, **kwargs)-> None : + def eEntity (self, *args, **kwargs)-> None : '''None''' ... - def eEnum, (self, *args, **kwargs)-> None : + def eEnum (self, *args, **kwargs)-> None : '''None''' ... - def eGuid, (self, *args, **kwargs)-> None : + def eGuid (self, *args, **kwargs)-> None : '''None''' ... - def eInt, (self, *args, **kwargs)-> None : + def eInt (self, *args, **kwargs)-> None : '''None''' ... def eLogical (self, *args, **kwargs)-> None : '''None''' ... - def eReal, (self, *args, **kwargs)-> None : + def eReal (self, *args, **kwargs)-> None : '''None''' ... - def eSelect, (self, *args, **kwargs)-> None : + def eSelect (self, *args, **kwargs)-> None : '''None''' ... - def eString, (self, *args, **kwargs)-> None : + def eString (self, *args, **kwargs)-> None : '''None''' ... - def eUInt, (self, *args, **kwargs)-> None : + def eUInt (self, *args, **kwargs)-> None : '''None''' ... - def eVector, (self, *args, **kwargs)-> None : + def eVector (self, *args, **kwargs)-> None : '''None''' ... @@ -1433,6 +1438,9 @@ class IfcVariant(object): def setVector (self, val: PyBrxBim.IfcVectorValue)-> None : ''' ''' ... + def type (self)-> PyBrxBim.IfcValueType : + ''' ''' + ... class IfcVectorDesc(object): def __init__ (self, *args, **kwargs)-> None : diff --git a/PySamples/PyBrxBim/importTest.py b/PySamples/PyBrxBim/importTest.py index 50ef7c4e..0b1b88bc 100644 --- a/PySamples/PyBrxBim/importTest.py +++ b/PySamples/PyBrxBim/importTest.py @@ -48,15 +48,22 @@ def onIfcProduct(self, context, entity, isParent, parentEntity): self.m_onProductCalled = True print("onIfcProduct") if entity.isKindOf(Bim.IfcEntityDesc.IfcWindow()): - print(entity.getAttribute("OverallHeight")) - mat = context.getLocalPlacement(entity) - createBoxSolid(100.0, 100.0, 100.0, mat.getTranslation(), 1) - return True + + # print(entity.IfcId()) + + # w = entity.getAttribute("OverallWidth") + # print("Width", w.type(), w.getReal()) + + # h = entity.getAttribute("OverallHeight") + # print("Height", h.type(), h.getReal()) + + #mat = context.getLocalPlacement(entity) + #createBoxSolid(100.0, 100.0, 100.0, mat.getTranslation(), 1) + return False + return True except Exception as err: traceback.print_exception(err) - finally: - return False def beforeCompletion(self, context, success): try: diff --git a/unitTests/UnitTestPyBcadBim.py b/unitTests/UnitTestPyBcadBim.py new file mode 100644 index 00000000..f710ec43 --- /dev/null +++ b/unitTests/UnitTestPyBcadBim.py @@ -0,0 +1,61 @@ +import os +import unittest +import math +import testcfg + +import PyRx as Rx +import PyGe as Ge +import PyGi as Gi +import PyDb as Db +import PyAp as Ap +import PyEd as Ed +import PyBrxBim as Bm + +host = Ap.Application.hostAPI() + + +class TestBCadBim(unittest.TestCase): + def __init__(self, *args, **kwargs): + super(TestBCadBim, self).__init__(*args, **kwargs) + + def __del__(self): + pass + + def test_IfcVariant(self): + v = Bm.IfcVariant() + + v.setBool(True) + self.assertEqual(v.type(), Bm.IfcValueType.eBool) + self.assertEqual(v.getBool(), True) + + v.setInt(42) + self.assertEqual(v.type(), Bm.IfcValueType.eInt) + self.assertEqual(v.getInt(), 42) + + v.setUInt(44) + self.assertEqual(v.type(), Bm.IfcValueType.eUInt) + self.assertEqual(v.getUInt(), 44) + + v.setReal(3.14) + self.assertEqual(v.type(), Bm.IfcValueType.eReal) + self.assertEqual(v.getReal(), 3.14) + + vs = Bm.IfcString("OMG YAY") + v.setString(vs) + self.assertEqual(v.type(), Bm.IfcValueType.eString) + self.assertEqual(v.getString().c_str(), "OMG YAY") + + +def pybcbimtest(): + try: + suite = unittest.TestLoader().loadTestsFromTestCase(TestBCadBim) + if testcfg.logToFile: + with open(testcfg.logFileName, "a") as f: + f.write("\n{:*^60s}\n".format("TestBricsCADBim")) + runner = unittest.TextTestRunner(f, verbosity=testcfg.testVerbosity) + runner.run(suite) + else: + print("TestBricsCADBim") + print(unittest.TextTestRunner(verbosity=testcfg.testVerbosity).run(suite)) + except Exception as err: + print(err) diff --git a/unitTests/UnitTestRunner.py b/unitTests/UnitTestRunner.py index 7e7a12dc..b9e222e0 100644 --- a/unitTests/UnitTestRunner.py +++ b/unitTests/UnitTestRunner.py @@ -27,6 +27,7 @@ if "BRX" in host: import UnitTestPyBcadCivil + import UnitTestPyBcadBim print("\nadded command = runtests: ") @@ -51,6 +52,7 @@ def OnPyReload() -> None: if "BRX" in host: importlib.reload(UnitTestPyBcadCivil) + importlib.reload(UnitTestPyBcadBim) if not "BRX" in host: importlib.reload(UnitTestDocString) @@ -94,6 +96,7 @@ def PyRxCmd_runtests() -> None: if "BRX" in host: UnitTestPyBcadCivil.pybcciviltest() + UnitTestPyBcadBim.pybcbimtest() if not "BRX" in host: UnitTestDocString.docstringtester()