From 81040d684d372f224269231de09c815fe6ca59ae Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Wed, 5 Feb 2025 10:18:54 +0100 Subject: [PATCH] Core: add Ifcopenshell version in about info clipboard (#19264) * Core: return information about ifcopenshell version in About info clipboard * Core: remove whitespace introduced by mistake * Core: handle case where ifcopenshell is not installed * Core: remove colon for consistency with other library versions * Core: change type of cmd to const char* to avoid allocating memory * Core: make failure to import ifcopenshell a debug message * Core: fix non-existing Debug message with DeveloperWarning * Core: go back to Log() to show info about non-installed ifcopenshell --- src/Gui/Dialogs/DlgAbout.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Gui/Dialogs/DlgAbout.cpp b/src/Gui/Dialogs/DlgAbout.cpp index caebd385a1..191f09517b 100644 --- a/src/Gui/Dialogs/DlgAbout.cpp +++ b/src/Gui/Dialogs/DlgAbout.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -652,6 +653,28 @@ void AboutDialog::copyToClipboard() str << "Qt " << QT_VERSION_STR << ", "; str << "Coin " << COIN_VERSION << ", "; str << "Vtk " << fcVtkVersion << ", "; + + const char* cmd = "import ifcopenshell\n" + "version = ifcopenshell.version"; + PyObject * ifcopenshellVer = nullptr; + + try { + ifcopenshellVer = Base::Interpreter().getValue(cmd, "version"); + } + catch (const Base::Exception& e) { + Base::Console().Log("%s (safe to ignore, unless using the BIM workbench and IFC).\n", e.what()); + } + + if (ifcopenshellVer) { + const char* ifcopenshellVerAsStr = PyUnicode_AsUTF8(ifcopenshellVer); + + if (ifcopenshellVerAsStr) { + str << "IfcOpenShell " << ifcopenshellVerAsStr << ", "; + Py_DECREF(ifcopenshellVerAsStr); + } + Py_DECREF(ifcopenshellVer); + } + #if defined(HAVE_OCC_VERSION) str << "OCC " << OCC_VERSION_MAJOR << "." << OCC_VERSION_MINOR << "." << OCC_VERSION_MAINTENANCE #ifdef OCC_VERSION_DEVELOPMENT