Fix launching of IfcTester webapp with Bonsai

This commit is contained in:
Dion Moult
2025-10-05 15:11:18 +11:00
parent fe333051df
commit add5132dec
3 changed files with 31 additions and 1 deletions
@@ -337,9 +337,21 @@ class StartIfcTesterWebapp(bpy.types.Operator):
websocket_server_thread = threading.Thread(target=run_websocket_server, daemon=True)
websocket_server_thread.start()
py_version = sys.version_info
bonsai_lib_path = (
Path(bpy.utils.user_resource("EXTENSIONS"))
/ ".local"
/ "lib"
/ f"python{py_version.major}.{py_version.minor}"
/ "site-packages"
)
env = os.environ.copy()
env["BONSAI_LIB_PATH"] = str(bonsai_lib_path)
env["BONSAI_VERSION"] = tool.Blender.get_bonsai_version()
# Start the Flask server as subprocess
webapp_process = subprocess.Popen(
[sys.executable, webapp_serve_path, "--host", "127.0.0.1", "--port", str(webapp_port)]
[sys.executable, webapp_serve_path, "--host", "127.0.0.1", "--port", str(webapp_port)], env=env
)
# Update properties
@@ -174,6 +174,14 @@ If there are changes to the IfcOpenShell binaries, you may replace the two
``*ifcopenshell_wrapper*`` files with new ones downloaded from the automated
`IfcOpenShell builds directory <https://builds.ifcopenshell.org/>`__.
If you wish to run the IfcTester webapp, you will also need to have ``npm`` and
setup IfcTester:
.. code-block:: bash
cd src/ifctester
make webapp-prepare
.. seealso::
There is a `useful Blender Addon
+10
View File
@@ -17,8 +17,18 @@
# along with IfcTester. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
import argparse
import mimetypes
bonsai_lib_path = os.environ.get("BONSAI_LIB_PATH")
print(os.environ)
print(bonsai_lib_path)
bonsai_version = os.environ.get("BONSAI_VERSION")
if bonsai_lib_path:
sys.path.insert(0, bonsai_lib_path)
from flask import Flask, send_from_directory, send_file
# Browsers expecting this specific MIME type for .mjs files,