From c0f2ac592e406128c9c4945a51e40b50f58bfe56 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 22 Jul 2024 13:07:40 +0200 Subject: [PATCH 01/42] Consider edge orientation in faceset helper for advanced planar breps #4895 --- src/ifcgeom/kernels/opencascade/faceset_helper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ifcgeom/kernels/opencascade/faceset_helper.cpp b/src/ifcgeom/kernels/opencascade/faceset_helper.cpp index fa7716abe5..3436b67bbd 100644 --- a/src/ifcgeom/kernels/opencascade/faceset_helper.cpp +++ b/src/ifcgeom/kernels/opencascade/faceset_helper.cpp @@ -42,7 +42,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper( loops.push_back(l); for (auto& e : l->children) { // @todo make sure only cartesian points are provided here - auto& p = boost::get(e->start); + auto& p = boost::get(e->orientation.get_value_or(true) ? e->start : e->end); if (point_identities_visited.find(p->identity()) == point_identities_visited.end()) { point_identities_visited.insert(p->identity()); points.push_back(p); @@ -201,10 +201,10 @@ void IfcGeom::OpenCascadeKernel::faceset_helper::loop_(const ifcopenshell::geome return; } - auto a = boost::get(ps->children.back()->start); + auto a = boost::get(ps->children.back()->orientation.get_value_or(true) ? ps->children.back()->start : ps->children.back()->end); auto A = a->identity(); for (auto& b : ps->children) { - auto B = boost::get(b->start)->identity(); + auto B = boost::get(b->orientation.get_value_or(true) ? b->start : b->end)->identity(); auto C = vertex_mapping_[A], D = vertex_mapping_[B]; bool fwd = C < D; if (!b->orientation) { From 1281eb4aeaea3f781e3d192be1d62a9c50fdfd62 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 11:56:42 +0500 Subject: [PATCH 02/42] fix download urls in startup error handler after d96f96031 --- src/blenderbim/blenderbim/__init__.py | 48 ++++++++++++++++++--------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/blenderbim/blenderbim/__init__.py b/src/blenderbim/blenderbim/__init__.py index 37e778d398..b168a681c6 100644 --- a/src/blenderbim/blenderbim/__init__.py +++ b/src/blenderbim/blenderbim/__init__.py @@ -52,19 +52,35 @@ def get_last_commit_hash() -> Union[str, None]: last_error = None last_actions: deque = deque(maxlen=10) +bbim_semver: dict[str, Any] = {} + + +def initialize_bbim_semver(): + """Initialize `bbim_semver` dictionary. + + Blender doesn't seem to store a full extension version (only major-minor-patch) + in `addon_utils.modules()->bl_info['version']`, + therefore we just parse it from .toml. + """ + import tomllib + + toml_path = Path(__file__).parent / "blender_manifest.toml" + with open(toml_path, "rb") as f: + manifest = tomllib.load(f) + semver_pattern = r"^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$" + version_str = manifest["version"] + re_version = re.match(semver_pattern, version_str) + assert re_version + global bbim_semver + bbim_semver = re_version.groupdict() + bbim_semver["version"] = version_str + + +initialize_bbim_semver() def get_debug_info(): - version = ".".join( - [ - str(x) - for x in [ - addon.bl_info.get("version", (-1, -1, -1)) - for addon in addon_utils.modules() - if addon.bl_info["name"] == "BlenderBIM" - ][0] - ] - ) + bbim_version = bbim_semver["version"] return { "os": platform.system(), @@ -74,7 +90,7 @@ def get_debug_info(): "machine": platform.machine(), "processor": platform.processor(), "blender_version": bpy.app.version_string, - "blenderbim_version": version, + "blenderbim_version": bbim_version, "blenderbim_commit_hash": get_last_commit_hash(), "last_actions": last_actions, "last_error": last_error, @@ -229,15 +245,15 @@ if IN_BLENDER: bbim_version = info["blenderbim_version"] py_tag = py.replace(".", "") if "Linux" in info["os"]: - os = "linux" + os = "linux-x64" elif "Darwin" in info["os"]: if "arm64" in info["machine"]: - os = "macosm1" + os = "macos-arm64" else: - os = "macos" + os = "macos-x64" else: - os = "win" - op.uri = f"https://github.com/IfcOpenShell/IfcOpenShell/releases/download/blenderbim-{bbim_version}/blenderbim-{bbim_version}-py{py_tag}-{os}.zip" + os = "windows-x64" + op.uri = f"https://github.com/IfcOpenShell/IfcOpenShell/releases/download/blenderbim-{bbim_version}/blenderbim_py{py_tag}-{bbim_version}-{os}.zip" class OpenUri(bpy.types.Operator): bl_idname = "bim.open_uri" From 1d12f54c36abb0b7acea433cb861a7aaa4da29e7 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 12:06:00 +0500 Subject: [PATCH 03/42] reuse tool.Blender.get_blenderbim_version --- src/blenderbim/blenderbim/__init__.py | 1 - src/blenderbim/blenderbim/bim/export_ifc.py | 15 ------------- src/blenderbim/blenderbim/bim/handler.py | 15 +------------ .../blenderbim/bim/module/augin/operator.py | 12 ++--------- src/blenderbim/blenderbim/bim/ui.py | 1 - src/blenderbim/blenderbim/tool/blender.py | 21 ++++++++----------- 6 files changed, 12 insertions(+), 53 deletions(-) diff --git a/src/blenderbim/blenderbim/__init__.py b/src/blenderbim/blenderbim/__init__.py index b168a681c6..5bfbbc2ec0 100644 --- a/src/blenderbim/blenderbim/__init__.py +++ b/src/blenderbim/blenderbim/__init__.py @@ -27,7 +27,6 @@ import sys IN_BLENDER = sys.modules.get("bpy", None) if IN_BLENDER: import bpy - import addon_utils import re import platform diff --git a/src/blenderbim/blenderbim/bim/export_ifc.py b/src/blenderbim/blenderbim/bim/export_ifc.py index b99bdfa65e..991f152cab 100644 --- a/src/blenderbim/blenderbim/bim/export_ifc.py +++ b/src/blenderbim/blenderbim/bim/export_ifc.py @@ -167,21 +167,6 @@ class IfcExporter: def get_application_name(self) -> str: return "BlenderBIM" - def get_application_version(self) -> str: - version = ".".join( - [ - str(x) - for x in [ - addon.bl_info.get("version", (-1, -1, -1)) - for addon in addon_utils.modules() - if addon.bl_info["name"] == "BlenderBIM" - ][0] - ] - ) - if commit_hash := tool.Blender.get_last_commit_hash(): - version += f"-{commit_hash}" - return version - class IfcExportSettings: def __init__(self): diff --git a/src/blenderbim/blenderbim/bim/handler.py b/src/blenderbim/blenderbim/bim/handler.py index dbbf59ed3a..53cb68639e 100644 --- a/src/blenderbim/blenderbim/bim/handler.py +++ b/src/blenderbim/blenderbim/bim/handler.py @@ -222,7 +222,7 @@ def redo_post(scene): def get_application(ifc: ifcopenshell.file) -> ifcopenshell.entity_instance: # TODO: cache this for even faster application retrieval. It honestly makes a difference on long scripts. - version = get_application_version() + version = tool.Blender.get_blenderbim_version() for element in ifc.by_type("IfcApplication"): if element.ApplicationIdentifier == "BlenderBIM" and element.Version == version: return element @@ -248,19 +248,6 @@ def get_user(ifc: ifcopenshell.file) -> Union[ifcopenshell.entity_instance, None return pao -def get_application_version() -> str: - return ".".join( - [ - str(x) - for x in [ - addon.bl_info.get("version", (-1, -1, -1)) - for addon in addon_utils.modules() - if addon.bl_info["name"] == "BlenderBIM" - ][0] - ] - ) - - def viewport_shading_changed_callback(area): shading = area.spaces.active.shading.type if shading == "RENDERED": diff --git a/src/blenderbim/blenderbim/bim/module/augin/operator.py b/src/blenderbim/blenderbim/bim/module/augin/operator.py index 62f5c3b09d..c3ca3a7bd1 100644 --- a/src/blenderbim/blenderbim/bim/module/augin/operator.py +++ b/src/blenderbim/blenderbim/bim/module/augin/operator.py @@ -26,6 +26,7 @@ import requests import tempfile import datetime import addon_utils +import blenderbim.tool as tool class AuginLogin(bpy.types.Operator): @@ -77,16 +78,7 @@ class AuginCreateNewModel(bpy.types.Operator): props.project_filename = "BBM{}{}".format( datetime.datetime.now().strftime("%Y%m%d%H%M%S"), "".join(random.choice(chars) for _ in range(6)) ) - addon_version = ".".join( - [ - str(x) - for x in [ - addon.bl_info.get("version", (-1, -1, -1)) - for addon in addon_utils.modules() - if addon.bl_info["name"] == "BlenderBIM" - ][0] - ] - ) + addon_version = tool.Blender.get_blenderbim_version() payload = { "user_token": props.token, diff --git a/src/blenderbim/blenderbim/bim/ui.py b/src/blenderbim/blenderbim/bim/ui.py index b9ad27592f..3a4b93f9c4 100644 --- a/src/blenderbim/blenderbim/bim/ui.py +++ b/src/blenderbim/blenderbim/bim/ui.py @@ -18,7 +18,6 @@ import os import bpy -import addon_utils import platform from pathlib import Path from bpy.types import Panel diff --git a/src/blenderbim/blenderbim/tool/blender.py b/src/blenderbim/blenderbim/tool/blender.py index 978aab0f9c..75db8b2fe3 100644 --- a/src/blenderbim/blenderbim/tool/blender.py +++ b/src/blenderbim/blenderbim/tool/blender.py @@ -26,8 +26,8 @@ import ifcopenshell.util.element import blenderbim.core.tool import blenderbim.tool as tool import blenderbim.bim -import addon_utils import types +import importlib from mathutils import Vector from pathlib import Path from blenderbim.bim.ifc import IFC_CONNECTED_TYPE @@ -930,17 +930,9 @@ class Blender(blenderbim.core.tool.Blender): return commit_hash[:7] @classmethod - def get_blenderbim_version(cls): - version = ".".join( - [ - str(x) - for x in [ - addon.bl_info.get("version", (-1, -1, -1)) - for addon in addon_utils.modules() - if addon.bl_info["name"] == "BlenderBIM" - ][0] - ] - ) + def get_blenderbim_version(cls) -> str: + bbim = cls.get_bbim_extension_package() + version = bbim.bbim_semver["version"] if commit_hash := cls.get_last_commit_hash(): version += f"-{commit_hash}" return version @@ -1114,6 +1106,11 @@ class Blender(blenderbim.core.tool.Blender): return package_name return "blenderbim" + @classmethod + def get_bbim_extension_package(cls) -> types.ModuleType: + name = cls.get_blender_addon_package_name() + return importlib.import_module(name) + @classmethod def get_addon_preferences(cls) -> blenderbim.bim.ui.BIM_ADDON_preferences: blender_package_name = cls.get_blender_addon_package_name() From 51e96268093ce86e8853e3a70780e8db8d22ebb4 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 12:26:51 +0500 Subject: [PATCH 04/42] installation.rst - update platform names --- src/blenderbim/docs/devs/installation.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/blenderbim/docs/devs/installation.rst b/src/blenderbim/docs/devs/installation.rst index 7d90211538..7e0bcb804f 100644 --- a/src/blenderbim/docs/devs/installation.rst +++ b/src/blenderbim/docs/devs/installation.rst @@ -22,8 +22,8 @@ You will need to choose which build to download. - If you are on Blender >=4.1, choose py311 - If you are on Blender >=3.1 and <=4.0, choose py310 - If you are on Blender >=2.93 and <3.1, choose py39 -- Choose ``linux``, ``macos`` (Apple Intel), ``macosm1`` (Apple Silicon), or - ``win`` depending on your operating system +- Choose ``linux-x64``, ``macos-x64`` (Apple Intel), ``macos-arm64`` (Apple Silicon), or + ``windows-x64`` depending on your operating system For users who don't follow the `VFX Platform `_ standard, we also provide py312 builds. From 845b3e0f6bce70c0f80a0da564d727e45b699ce8 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 12:46:49 +0500 Subject: [PATCH 05/42] dev installation - move dev environment scripts to separate files --- src/blenderbim/docs/devs/installation.rst | 133 +----------------- .../scripts/installation/dev_environment.bat | 63 +++++++++ .../scripts/installation/dev_environment.sh | 60 ++++++++ 3 files changed, 129 insertions(+), 127 deletions(-) create mode 100644 src/blenderbim/scripts/installation/dev_environment.bat create mode 100644 src/blenderbim/scripts/installation/dev_environment.sh diff --git a/src/blenderbim/docs/devs/installation.rst b/src/blenderbim/docs/devs/installation.rst index 7e0bcb804f..cb9be95372 100644 --- a/src/blenderbim/docs/devs/installation.rst +++ b/src/blenderbim/docs/devs/installation.rst @@ -75,138 +75,17 @@ restart Blender to see changes). For Linux or Mac: -.. code-block:: bash - - git clone https://github.com/IfcOpenShell/IfcOpenShell.git - cd IfcOpenShell - - # path to BlenderBIM addon - # default path on Mac: "/Users/$USER/Library/Application Support/Blender/X.X/scripts/addons/blenderbim" - # default path on Linux: "$HOME/.config/blender/X.X/" - BLENDER_ADDON_PATH="/path/to/blender/X.XX/scripts/addons/blenderbim" - - # Remove the Blender add-on Python code - rm -r $BLENDER_ADDON_PATH/core/ - rm -r $BLENDER_ADDON_PATH/tool/ - rm -r $BLENDER_ADDON_PATH/bim/ - - # Replace them with links to the Git repository - ln -s $PWD/src/blenderbim/blenderbim/core $BLENDER_ADDON_PATH/core - ln -s $PWD/src/blenderbim/blenderbim/tool $BLENDER_ADDON_PATH/tool - ln -s $PWD/src/blenderbim/blenderbim/bim $BLENDER_ADDON_PATH/bim - - # Copy over compiled IfcOpenShell files - cp $BLENDER_ADDON_PATH/libs/site/packages/ifcopenshell/*_wrapper* $PWD/src/ifcopenshell-python/ifcopenshell/ - - # Remove the IfcOpenShell dependency - rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifcopenshell - - # Replace them with links to the Git repository - ln -s $PWD/src/ifcopenshell-python/ifcopenshell $BLENDER_ADDON_PATH/libs/site/packages/ifcopenshell - - # Remove and link other IfcOpenShell utilities - rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifccsv.py - rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifcdiff.py - rm -r $BLENDER_ADDON_PATH/libs/site/packages/bsdd.py - rm -r $BLENDER_ADDON_PATH/libs/site/packages/bcf - rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifc4d - rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifc5d - rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifccityjson - rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifcclash - rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifcpatch - rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifctester - rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifcfm - rm -r $BLENDER_ADDON_PATH/libs/Desktop - - ln -s $PWD/src/ifccsv/ifccsv.py $BLENDER_ADDON_PATH/libs/site/packages/ifccsv.py - ln -s $PWD/src/ifcdiff/ifcdiff.py $BLENDER_ADDON_PATH/libs/site/packages/ifcdiff.py - ln -s $PWD/src/bsdd/bsdd.py $BLENDER_ADDON_PATH/libs/site/packages/bsdd.py - ln -s $PWD/src/bcf/src/bcf $BLENDER_ADDON_PATH/libs/site/packages/bcf - ln -s $PWD/src/ifc4d/ifc4d $BLENDER_ADDON_PATH/libs/site/packages/ifc4d - ln -s $PWD/src/ifc5d/ifc5d $BLENDER_ADDON_PATH/libs/site/packages/ifc5d - ln -s $PWD/src/ifccityjson/ifccityjson $BLENDER_ADDON_PATH/libs/site/packages/ifccityjson - ln -s $PWD/src/ifcclash/ifcclash $BLENDER_ADDON_PATH/libs/site/packages/ifcclash - ln -s $PWD/src/ifcpatch/ifcpatch $BLENDER_ADDON_PATH/libs/site/packages/ifcpatch - ln -s $PWD/src/ifctester/ifctester $BLENDER_ADDON_PATH/libs/site/packages/ifctester - ln -s $PWD/src/ifcfm/ifcfm $BLENDER_ADDON_PATH/libs/site/packages/ifcfm - ln -s $PWD/src/blenderbim/blenderbim/libs/desktop $BLENDER_ADDON_PATH/libs/Desktop - - # Manually download some third party dependencies - cd $BLENDER_ADDON_PATH/bim/data/gantt - wget https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.js - wget https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.css - cd $BLENDER_ADDON_PATH/bim/schema - wget https://github.com/BrickSchema/Brick/releases/download/nightly/Brick.ttl +.. literalinclude:: ../../scripts/installation/dev_environment.sh + :language: bash + :caption: dev_environment.sh Or, if you're on Windows, you can use the batch script below. You need to run it as an administrator. Before running it follow the instructions descibed in the `rem` tags. -.. code-block:: bat - - @echo off - - rem SETUP BLENDER-BIM LIVE DEVELOPMENT ENVIRONMENT - rem Setup blenderbim addon location below (probably just need to change "x.x" for your Blender version). - rem Put the script to the folder where IfcOpenShell git repository is located - rem (script will try to clone IfcOpenShell.git if it's not present). - SET blenderbim=%appdata%\Blender Foundation\Blender\x.x\scripts\addons\blenderbim - - git clone https://github.com/IfcOpenShell/IfcOpenShell.git - cd IfcOpenShell - - echo Removing the Blender add-on Python code... - rd /S /Q "%blenderbim%\core\" - rd /S /Q "%blenderbim%\tool\" - rd /S /Q "%blenderbim%\bim\" - - echo Replacing them with links to the Git repository... - mklink /D "%blenderbim%\core" "%cd%\src\blenderbim\blenderbim\core" - mklink /D "%blenderbim%\tool" "%cd%\src\blenderbim\blenderbim\tool" - mklink /D "%blenderbim%\bim" "%cd%\src\blenderbim\blenderbim\bim" - - echo Copy over compiled IfcOpenShell files... - copy "%blenderbim%\libs\site\packages\ifcopenshell\*_wrapper*" "%cd%\src\ifcopenshell-python\ifcopenshell\" - - echo Remove the IfcOpenShell dependency... - rd /S /Q "%blenderbim%\libs\site\packages\ifcopenshell" - - echo Replace them with links to the Git repository... - mklink /D "%blenderbim%\libs\site\packages\ifcopenshell" "%cd%\src\ifcopenshell-python\ifcopenshell" - - echo Remove and link other IfcOpenShell utilities... - del "%blenderbim%\libs\site\packages\ifccsv.py" - del "%blenderbim%\libs\site\packages\ifcdiff.py" - del "%blenderbim%\libs\site\packages\bsdd.py" - rd /S /Q "%blenderbim%\libs\site\packages\bcf" - rd /S /Q "%blenderbim%\libs\site\packages\ifc4d" - rd /S /Q "%blenderbim%\libs\site\packages\ifc5d" - rd /S /Q "%blenderbim%\libs\site\packages\ifccityjson" - rd /S /Q "%blenderbim%\libs\site\packages\ifcclash" - rd /S /Q "%blenderbim%\libs\site\packages\ifcpatch" - rd /S /Q "%blenderbim%\libs\site\packages\ifctester" - rd /S /Q "%blenderbim%\libs\site\packages\ifcfm" - rd /S /Q "%blenderbim%\libs\desktop" - - mklink "%blenderbim%\libs\site\packages\ifccsv.py" "%cd%\src\ifccsv\ifccsv.py" - mklink "%blenderbim%\libs\site\packages\ifcdiff.py" "%cd%\src\ifcdiff\ifcdiff.py" - mklink "%blenderbim%\libs\site\packages\bsdd.py" "%cd%\src\bsdd\bsdd.py" - mklink /D "%blenderbim%\libs\site\packages\bcf" "%cd%\src\bcf\src\bcf" - mklink /D "%blenderbim%\libs\site\packages\ifc4d" "%cd%\src\ifc4d\ifc4d" - mklink /D "%blenderbim%\libs\site\packages\ifc5d" "%cd%\src\ifc5d\ifc5d" - mklink /D "%blenderbim%\libs\site\packages\ifccityjson" "%cd%\src\ifccityjson\ifccityjson" - mklink /D "%blenderbim%\libs\site\packages\ifcclash" "%cd%\src\ifcclash\ifcclash" - mklink /D "%blenderbim%\libs\site\packages\ifcpatch" "%cd%\src\ifcpatch\ifcpatch" - mklink /D "%blenderbim%\libs\site\packages\ifctester" "%cd%\src\ifctester\ifctester" - mklink /D "%blenderbim%\libs\site\packages\ifcfm" "%cd%\src\ifcfm\ifcfm" - mklink /D "%blenderbim%\libs\desktop" "%cd%\src\blenderbim\blenderbim\libs\desktop" - - echo Manually downloading some third party dependencies... - curl https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.js -o "%blenderbim%\bim\data\gantt\jsgantt.js" - curl https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.css -o "%blenderbim%\bim\data\gantt\jsgantt.css" - curl -L https://github.com/BrickSchema/Brick/releases/download/nightly/Brick.ttl -o "%blenderbim%\bim\schema\Brick.ttl" - - pause +.. literalinclude:: ../../scripts/installation/dev_environment.bat + :language: bat + :caption: dev_environment.bat After you modify your code in the Git repository, you will need to restart Blender for the changes to take effect. diff --git a/src/blenderbim/scripts/installation/dev_environment.bat b/src/blenderbim/scripts/installation/dev_environment.bat new file mode 100644 index 0000000000..2b659f39ff --- /dev/null +++ b/src/blenderbim/scripts/installation/dev_environment.bat @@ -0,0 +1,63 @@ +@echo off + +rem SETUP BLENDER-BIM LIVE DEVELOPMENT ENVIRONMENT +rem Setup blenderbim addon location below (probably just need to change "x.x" for your Blender version). +rem Put the script to the folder where IfcOpenShell git repository is located +rem (script will try to clone IfcOpenShell.git if it's not present). +SET blenderbim=%appdata%\Blender Foundation\Blender\x.x\scripts\addons\blenderbim + +git clone https://github.com/IfcOpenShell/IfcOpenShell.git +cd IfcOpenShell + +echo Removing the Blender add-on Python code... +rd /S /Q "%blenderbim%\core\" +rd /S /Q "%blenderbim%\tool\" +rd /S /Q "%blenderbim%\bim\" + +echo Replacing them with links to the Git repository... +mklink /D "%blenderbim%\core" "%cd%\src\blenderbim\blenderbim\core" +mklink /D "%blenderbim%\tool" "%cd%\src\blenderbim\blenderbim\tool" +mklink /D "%blenderbim%\bim" "%cd%\src\blenderbim\blenderbim\bim" + +echo Copy over compiled IfcOpenShell files... +copy "%blenderbim%\libs\site\packages\ifcopenshell\*_wrapper*" "%cd%\src\ifcopenshell-python\ifcopenshell\" + +echo Remove the IfcOpenShell dependency... +rd /S /Q "%blenderbim%\libs\site\packages\ifcopenshell" + +echo Replace them with links to the Git repository... +mklink /D "%blenderbim%\libs\site\packages\ifcopenshell" "%cd%\src\ifcopenshell-python\ifcopenshell" + +echo Remove and link other IfcOpenShell utilities... +del "%blenderbim%\libs\site\packages\ifccsv.py" +del "%blenderbim%\libs\site\packages\ifcdiff.py" +del "%blenderbim%\libs\site\packages\bsdd.py" +rd /S /Q "%blenderbim%\libs\site\packages\bcf" +rd /S /Q "%blenderbim%\libs\site\packages\ifc4d" +rd /S /Q "%blenderbim%\libs\site\packages\ifc5d" +rd /S /Q "%blenderbim%\libs\site\packages\ifccityjson" +rd /S /Q "%blenderbim%\libs\site\packages\ifcclash" +rd /S /Q "%blenderbim%\libs\site\packages\ifcpatch" +rd /S /Q "%blenderbim%\libs\site\packages\ifctester" +rd /S /Q "%blenderbim%\libs\site\packages\ifcfm" +rd /S /Q "%blenderbim%\libs\desktop" + +mklink "%blenderbim%\libs\site\packages\ifccsv.py" "%cd%\src\ifccsv\ifccsv.py" +mklink "%blenderbim%\libs\site\packages\ifcdiff.py" "%cd%\src\ifcdiff\ifcdiff.py" +mklink "%blenderbim%\libs\site\packages\bsdd.py" "%cd%\src\bsdd\bsdd.py" +mklink /D "%blenderbim%\libs\site\packages\bcf" "%cd%\src\bcf\src\bcf" +mklink /D "%blenderbim%\libs\site\packages\ifc4d" "%cd%\src\ifc4d\ifc4d" +mklink /D "%blenderbim%\libs\site\packages\ifc5d" "%cd%\src\ifc5d\ifc5d" +mklink /D "%blenderbim%\libs\site\packages\ifccityjson" "%cd%\src\ifccityjson\ifccityjson" +mklink /D "%blenderbim%\libs\site\packages\ifcclash" "%cd%\src\ifcclash\ifcclash" +mklink /D "%blenderbim%\libs\site\packages\ifcpatch" "%cd%\src\ifcpatch\ifcpatch" +mklink /D "%blenderbim%\libs\site\packages\ifctester" "%cd%\src\ifctester\ifctester" +mklink /D "%blenderbim%\libs\site\packages\ifcfm" "%cd%\src\ifcfm\ifcfm" +mklink /D "%blenderbim%\libs\desktop" "%cd%\src\blenderbim\blenderbim\libs\desktop" + +echo Manually downloading some third party dependencies... +curl https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.js -o "%blenderbim%\bim\data\gantt\jsgantt.js" +curl https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.css -o "%blenderbim%\bim\data\gantt\jsgantt.css" +curl -L https://github.com/BrickSchema/Brick/releases/download/nightly/Brick.ttl -o "%blenderbim%\bim\schema\Brick.ttl" + +pause diff --git a/src/blenderbim/scripts/installation/dev_environment.sh b/src/blenderbim/scripts/installation/dev_environment.sh new file mode 100644 index 0000000000..255a17a515 --- /dev/null +++ b/src/blenderbim/scripts/installation/dev_environment.sh @@ -0,0 +1,60 @@ +git clone https://github.com/IfcOpenShell/IfcOpenShell.git +cd IfcOpenShell + +# path to BlenderBIM addon +# default path on Mac: "/Users/$USER/Library/Application Support/Blender/X.X/scripts/addons/blenderbim" +# default path on Linux: "$HOME/.config/blender/X.X/" +BLENDER_ADDON_PATH="/path/to/blender/X.XX/scripts/addons/blenderbim" + +# Remove the Blender add-on Python code +rm -r $BLENDER_ADDON_PATH/core/ +rm -r $BLENDER_ADDON_PATH/tool/ +rm -r $BLENDER_ADDON_PATH/bim/ + +# Replace them with links to the Git repository +ln -s $PWD/src/blenderbim/blenderbim/core $BLENDER_ADDON_PATH/core +ln -s $PWD/src/blenderbim/blenderbim/tool $BLENDER_ADDON_PATH/tool +ln -s $PWD/src/blenderbim/blenderbim/bim $BLENDER_ADDON_PATH/bim + +# Copy over compiled IfcOpenShell files +cp $BLENDER_ADDON_PATH/libs/site/packages/ifcopenshell/*_wrapper* $PWD/src/ifcopenshell-python/ifcopenshell/ + +# Remove the IfcOpenShell dependency +rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifcopenshell + +# Replace them with links to the Git repository +ln -s $PWD/src/ifcopenshell-python/ifcopenshell $BLENDER_ADDON_PATH/libs/site/packages/ifcopenshell + +# Remove and link other IfcOpenShell utilities +rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifccsv.py +rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifcdiff.py +rm -r $BLENDER_ADDON_PATH/libs/site/packages/bsdd.py +rm -r $BLENDER_ADDON_PATH/libs/site/packages/bcf +rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifc4d +rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifc5d +rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifccityjson +rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifcclash +rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifcpatch +rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifctester +rm -r $BLENDER_ADDON_PATH/libs/site/packages/ifcfm +rm -r $BLENDER_ADDON_PATH/libs/Desktop + +ln -s $PWD/src/ifccsv/ifccsv.py $BLENDER_ADDON_PATH/libs/site/packages/ifccsv.py +ln -s $PWD/src/ifcdiff/ifcdiff.py $BLENDER_ADDON_PATH/libs/site/packages/ifcdiff.py +ln -s $PWD/src/bsdd/bsdd.py $BLENDER_ADDON_PATH/libs/site/packages/bsdd.py +ln -s $PWD/src/bcf/src/bcf $BLENDER_ADDON_PATH/libs/site/packages/bcf +ln -s $PWD/src/ifc4d/ifc4d $BLENDER_ADDON_PATH/libs/site/packages/ifc4d +ln -s $PWD/src/ifc5d/ifc5d $BLENDER_ADDON_PATH/libs/site/packages/ifc5d +ln -s $PWD/src/ifccityjson/ifccityjson $BLENDER_ADDON_PATH/libs/site/packages/ifccityjson +ln -s $PWD/src/ifcclash/ifcclash $BLENDER_ADDON_PATH/libs/site/packages/ifcclash +ln -s $PWD/src/ifcpatch/ifcpatch $BLENDER_ADDON_PATH/libs/site/packages/ifcpatch +ln -s $PWD/src/ifctester/ifctester $BLENDER_ADDON_PATH/libs/site/packages/ifctester +ln -s $PWD/src/ifcfm/ifcfm $BLENDER_ADDON_PATH/libs/site/packages/ifcfm +ln -s $PWD/src/blenderbim/blenderbim/libs/desktop $BLENDER_ADDON_PATH/libs/Desktop + +# Manually download some third party dependencies +cd $BLENDER_ADDON_PATH/bim/data/gantt +wget https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.js +wget https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.css +cd $BLENDER_ADDON_PATH/bim/schema +wget https://github.com/BrickSchema/Brick/releases/download/nightly/Brick.ttl From 1ca6c489b19bff16498eb13ea2feb5c3154fa514 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 12:47:29 +0500 Subject: [PATCH 06/42] dev installation - update windows script for Blender 4.2 --- .../scripts/installation/dev_environment.bat | 79 ++++++++++--------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/src/blenderbim/scripts/installation/dev_environment.bat b/src/blenderbim/scripts/installation/dev_environment.bat index 2b659f39ff..85b6dd591d 100644 --- a/src/blenderbim/scripts/installation/dev_environment.bat +++ b/src/blenderbim/scripts/installation/dev_environment.bat @@ -1,63 +1,66 @@ @echo off rem SETUP BLENDER-BIM LIVE DEVELOPMENT ENVIRONMENT -rem Setup blenderbim addon location below (probably just need to change "x.x" for your Blender version). +rem Update BLENDER_VERSION, PYTHON_VERSION, BBIM_REPO in the script bellow. rem Put the script to the folder where IfcOpenShell git repository is located rem (script will try to clone IfcOpenShell.git if it's not present). -SET blenderbim=%appdata%\Blender Foundation\Blender\x.x\scripts\addons\blenderbim +SET BLENDER_VERSION=4.2 +SET PYTHON_VERSION=3.11 +SET BBIM_REPO=user_default + +SET BLENDER=%appdata%\Blender Foundation\Blender\%BLENDER_VERSION% +SET BLENDER_LOCAL=%BLENDER%\extensions\.local\lib\python%PYTHON_VERSION%\site-packages +SET BLENDERBIM=%BLENDER_LOCAL%\blenderbim +SET BLENDER_EXT=%BLENDER%\extensions\%BBIM_REPO%\blenderbim git clone https://github.com/IfcOpenShell/IfcOpenShell.git cd IfcOpenShell echo Removing the Blender add-on Python code... -rd /S /Q "%blenderbim%\core\" -rd /S /Q "%blenderbim%\tool\" -rd /S /Q "%blenderbim%\bim\" +del "%BLENDER_EXT%\__init__.py" +rd /S /Q "%BLENDERBIM%" echo Replacing them with links to the Git repository... -mklink /D "%blenderbim%\core" "%cd%\src\blenderbim\blenderbim\core" -mklink /D "%blenderbim%\tool" "%cd%\src\blenderbim\blenderbim\tool" -mklink /D "%blenderbim%\bim" "%cd%\src\blenderbim\blenderbim\bim" +mklink "%BLENDER_EXT%\__init__.py" "%CD%\src\blenderbim\blenderbim\__init__.py" +mklink /D "%BLENDERBIM%" "%CD%\src\blenderbim\blenderbim" echo Copy over compiled IfcOpenShell files... -copy "%blenderbim%\libs\site\packages\ifcopenshell\*_wrapper*" "%cd%\src\ifcopenshell-python\ifcopenshell\" +copy "%BLENDER_LOCAL%\ifcopenshell\*_wrapper*" "%CD%\src\ifcopenshell-python\ifcopenshell\" echo Remove the IfcOpenShell dependency... -rd /S /Q "%blenderbim%\libs\site\packages\ifcopenshell" +rd /S /Q "%BLENDER_LOCAL%\ifcopenshell" echo Replace them with links to the Git repository... -mklink /D "%blenderbim%\libs\site\packages\ifcopenshell" "%cd%\src\ifcopenshell-python\ifcopenshell" +mklink /D "%BLENDER_LOCAL%\ifcopenshell" "%CD%\src\ifcopenshell-python\ifcopenshell" echo Remove and link other IfcOpenShell utilities... -del "%blenderbim%\libs\site\packages\ifccsv.py" -del "%blenderbim%\libs\site\packages\ifcdiff.py" -del "%blenderbim%\libs\site\packages\bsdd.py" -rd /S /Q "%blenderbim%\libs\site\packages\bcf" -rd /S /Q "%blenderbim%\libs\site\packages\ifc4d" -rd /S /Q "%blenderbim%\libs\site\packages\ifc5d" -rd /S /Q "%blenderbim%\libs\site\packages\ifccityjson" -rd /S /Q "%blenderbim%\libs\site\packages\ifcclash" -rd /S /Q "%blenderbim%\libs\site\packages\ifcpatch" -rd /S /Q "%blenderbim%\libs\site\packages\ifctester" -rd /S /Q "%blenderbim%\libs\site\packages\ifcfm" -rd /S /Q "%blenderbim%\libs\desktop" +del "%BLENDER_LOCAL%\ifccsv.py" +del "%BLENDER_LOCAL%\ifcdiff.py" +del "%BLENDER_LOCAL%\bsdd.py" +rd /S /Q "%BLENDER_LOCAL%\bcf" +rd /S /Q "%BLENDER_LOCAL%\ifc4d" +rd /S /Q "%BLENDER_LOCAL%\ifc5d" +rd /S /Q "%BLENDER_LOCAL%\ifccityjson" +rd /S /Q "%BLENDER_LOCAL%\ifcclash" +rd /S /Q "%BLENDER_LOCAL%\ifcpatch" +rd /S /Q "%BLENDER_LOCAL%\ifctester" +rd /S /Q "%BLENDER_LOCAL%\ifcfm" -mklink "%blenderbim%\libs\site\packages\ifccsv.py" "%cd%\src\ifccsv\ifccsv.py" -mklink "%blenderbim%\libs\site\packages\ifcdiff.py" "%cd%\src\ifcdiff\ifcdiff.py" -mklink "%blenderbim%\libs\site\packages\bsdd.py" "%cd%\src\bsdd\bsdd.py" -mklink /D "%blenderbim%\libs\site\packages\bcf" "%cd%\src\bcf\src\bcf" -mklink /D "%blenderbim%\libs\site\packages\ifc4d" "%cd%\src\ifc4d\ifc4d" -mklink /D "%blenderbim%\libs\site\packages\ifc5d" "%cd%\src\ifc5d\ifc5d" -mklink /D "%blenderbim%\libs\site\packages\ifccityjson" "%cd%\src\ifccityjson\ifccityjson" -mklink /D "%blenderbim%\libs\site\packages\ifcclash" "%cd%\src\ifcclash\ifcclash" -mklink /D "%blenderbim%\libs\site\packages\ifcpatch" "%cd%\src\ifcpatch\ifcpatch" -mklink /D "%blenderbim%\libs\site\packages\ifctester" "%cd%\src\ifctester\ifctester" -mklink /D "%blenderbim%\libs\site\packages\ifcfm" "%cd%\src\ifcfm\ifcfm" -mklink /D "%blenderbim%\libs\desktop" "%cd%\src\blenderbim\blenderbim\libs\desktop" +mklink "%BLENDER_LOCAL%\ifccsv.py" "%CD%\src\ifccsv\ifccsv.py" +mklink "%BLENDER_LOCAL%\ifcdiff.py" "%CD%\src\ifcdiff\ifcdiff.py" +mklink "%BLENDER_LOCAL%\bsdd.py" "%CD%\src\bsdd\bsdd.py" +mklink /D "%BLENDER_LOCAL%\bcf" "%CD%\src\bcf\src\bcf" +mklink /D "%BLENDER_LOCAL%\ifc4d" "%CD%\src\ifc4d\ifc4d" +mklink /D "%BLENDER_LOCAL%\ifc5d" "%CD%\src\ifc5d\ifc5d" +mklink /D "%BLENDER_LOCAL%\ifccityjson" "%CD%\src\ifccityjson\ifccityjson" +mklink /D "%BLENDER_LOCAL%\ifcclash" "%CD%\src\ifcclash\ifcclash" +mklink /D "%BLENDER_LOCAL%\ifcpatch" "%CD%\src\ifcpatch\ifcpatch" +mklink /D "%BLENDER_LOCAL%\ifctester" "%CD%\src\ifctester\ifctester" +mklink /D "%BLENDER_LOCAL%\ifcfm" "%CD%\src\ifcfm\ifcfm" echo Manually downloading some third party dependencies... -curl https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.js -o "%blenderbim%\bim\data\gantt\jsgantt.js" -curl https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.css -o "%blenderbim%\bim\data\gantt\jsgantt.css" -curl -L https://github.com/BrickSchema/Brick/releases/download/nightly/Brick.ttl -o "%blenderbim%\bim\schema\Brick.ttl" +curl https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.js -o "%BLENDERBIM%\bim\data\gantt\jsgantt.js" +curl https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.css -o "%BLENDERBIM%\bim\data\gantt\jsgantt.css" +curl -L https://github.com/BrickSchema/Brick/releases/download/nightly/Brick.ttl -o "%BLENDERBIM%\bim\schema\Brick.ttl" pause From ffbade0f7a75f564b3359c7b4af0dd308e7588f7 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 13:43:39 +0500 Subject: [PATCH 07/42] fix bcf paths after 237cd99 --- .github/workflows/ci-blenderbim-daily.yml | 2 +- src/blenderbim/scripts/installation/dev_environment.bat | 2 +- src/blenderbim/scripts/installation/dev_environment.sh | 2 +- src/ifcopenshell-python/docs/conf.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-blenderbim-daily.yml b/.github/workflows/ci-blenderbim-daily.yml index 7ac376895f..0e4321aece 100644 --- a/.github/workflows/ci-blenderbim-daily.yml +++ b/.github/workflows/ci-blenderbim-daily.yml @@ -6,7 +6,7 @@ on: - '.github/workflows/ci-blenderbim-daily.yml' - 'src/blenderbim/**' - 'src/ifcopenshell-python/ifcopenshell/**' - - 'src/bcf/src/bcf/**' + - 'src/bcf/bcf/**' - 'src/ifcclash/ifcclash/**' - 'src/ifccobie/**' - 'src/ifcdiff/**' diff --git a/src/blenderbim/scripts/installation/dev_environment.bat b/src/blenderbim/scripts/installation/dev_environment.bat index 85b6dd591d..c56f544092 100644 --- a/src/blenderbim/scripts/installation/dev_environment.bat +++ b/src/blenderbim/scripts/installation/dev_environment.bat @@ -49,7 +49,7 @@ rd /S /Q "%BLENDER_LOCAL%\ifcfm" mklink "%BLENDER_LOCAL%\ifccsv.py" "%CD%\src\ifccsv\ifccsv.py" mklink "%BLENDER_LOCAL%\ifcdiff.py" "%CD%\src\ifcdiff\ifcdiff.py" mklink "%BLENDER_LOCAL%\bsdd.py" "%CD%\src\bsdd\bsdd.py" -mklink /D "%BLENDER_LOCAL%\bcf" "%CD%\src\bcf\src\bcf" +mklink /D "%BLENDER_LOCAL%\bcf" "%CD%\src\bcf\bcf" mklink /D "%BLENDER_LOCAL%\ifc4d" "%CD%\src\ifc4d\ifc4d" mklink /D "%BLENDER_LOCAL%\ifc5d" "%CD%\src\ifc5d\ifc5d" mklink /D "%BLENDER_LOCAL%\ifccityjson" "%CD%\src\ifccityjson\ifccityjson" diff --git a/src/blenderbim/scripts/installation/dev_environment.sh b/src/blenderbim/scripts/installation/dev_environment.sh index 255a17a515..fa1e6cd8f4 100644 --- a/src/blenderbim/scripts/installation/dev_environment.sh +++ b/src/blenderbim/scripts/installation/dev_environment.sh @@ -42,7 +42,7 @@ rm -r $BLENDER_ADDON_PATH/libs/Desktop ln -s $PWD/src/ifccsv/ifccsv.py $BLENDER_ADDON_PATH/libs/site/packages/ifccsv.py ln -s $PWD/src/ifcdiff/ifcdiff.py $BLENDER_ADDON_PATH/libs/site/packages/ifcdiff.py ln -s $PWD/src/bsdd/bsdd.py $BLENDER_ADDON_PATH/libs/site/packages/bsdd.py -ln -s $PWD/src/bcf/src/bcf $BLENDER_ADDON_PATH/libs/site/packages/bcf +ln -s $PWD/src/bcf/bcf $BLENDER_ADDON_PATH/libs/site/packages/bcf ln -s $PWD/src/ifc4d/ifc4d $BLENDER_ADDON_PATH/libs/site/packages/ifc4d ln -s $PWD/src/ifc5d/ifc5d $BLENDER_ADDON_PATH/libs/site/packages/ifc5d ln -s $PWD/src/ifccityjson/ifccityjson $BLENDER_ADDON_PATH/libs/site/packages/ifccityjson diff --git a/src/ifcopenshell-python/docs/conf.py b/src/ifcopenshell-python/docs/conf.py index e89a42a31a..7a31cbb0e2 100644 --- a/src/ifcopenshell-python/docs/conf.py +++ b/src/ifcopenshell-python/docs/conf.py @@ -81,10 +81,10 @@ autoapi_add_toctree_entry = True autoapi_type = "python" # autoapi works by reading source code instead of importing modules -autoapi_dirs = ['../ifcopenshell', '../../bcf/src', '../../bsdd', '../../ifccsv', '../../ifcdiff', '../../ifcpatch/ifcpatch', '../../ifctester/ifctester'] +autoapi_dirs = ['../ifcopenshell', '../../bcf/bcf', '../../bsdd', '../../ifccsv', '../../ifcdiff', '../../ifcpatch/ifcpatch', '../../ifctester/ifctester'] # autoapi_dirs = ['../../ifcdiff'] # autoapi_dirs = ['../../ifcdiff', '../ifcopenshell/util'] -# autoapi_dirs = ['../../bcf/src', '../../bsdd', '../../ifccsv', '../../ifcdiff', '../../ifcpatch/ifcpatch', '../../ifctester/ifctester'] +# autoapi_dirs = ['../../bcf/bcf', '../../bsdd', '../../ifccsv', '../../ifcdiff', '../../ifcpatch/ifcpatch', '../../ifctester/ifctester'] # These are auto-generated based on the IFC schema, so exclude them autoapi_ignore = ['*ifcopenshell/express/rules*'] From 44fc5768afb802aa9e8cde44c59a3658f8d93319 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 14:06:51 +0500 Subject: [PATCH 08/42] blender 4.2 - fix errors detecting last commit hash 1) __file__ / bim no longer exists as 'bim' is moved to the wheel 2) there also was an issue detecting hash after it was moved from bim to blenderbim package in c0635af --- src/blenderbim/blenderbim/__init__.py | 3 +-- src/blenderbim/blenderbim/bim/__init__.py | 1 - src/blenderbim/blenderbim/tool/blender.py | 3 ++- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/blenderbim/blenderbim/__init__.py b/src/blenderbim/blenderbim/__init__.py index 5bfbbc2ec0..166590c6bb 100644 --- a/src/blenderbim/blenderbim/__init__.py +++ b/src/blenderbim/blenderbim/__init__.py @@ -147,8 +147,7 @@ if IN_BLENDER: # We can't just use __file__ as blenderbim/__init__.py is typically not symlinked # as Blender have errors symlinking main addon package file. - path = Path(__file__).parent / "bim" / "__init__.py" - path = path.resolve().parent + path = Path(__file__).resolve().parent repo = git.Repo(str(path), search_parent_directories=True) last_commit_hash = repo.head.object.hexsha except: diff --git a/src/blenderbim/blenderbim/bim/__init__.py b/src/blenderbim/blenderbim/bim/__init__.py index 3f1808562d..51f2c02614 100644 --- a/src/blenderbim/blenderbim/bim/__init__.py +++ b/src/blenderbim/blenderbim/bim/__init__.py @@ -196,7 +196,6 @@ for mod in modules.values(): addon_keymaps = [] icons = None is_registering = False -last_commit_hash = "8888888" original_scene_panels_polls: dict[bpy.types.Panel, Union[Callable, None]] = dict() diff --git a/src/blenderbim/blenderbim/tool/blender.py b/src/blenderbim/blenderbim/tool/blender.py index 75db8b2fe3..004c4cc34b 100644 --- a/src/blenderbim/blenderbim/tool/blender.py +++ b/src/blenderbim/blenderbim/tool/blender.py @@ -920,7 +920,8 @@ class Blender(blenderbim.core.tool.Blender): @classmethod def get_last_commit_hash(cls) -> Union[str, None]: """Get 8 symbols of last commit hash if it's present or return None otherwise.""" - commit_hash = blenderbim.bim.last_commit_hash + bbim = cls.get_bbim_extension_package() + commit_hash = bbim.last_commit_hash # Commit hash is unset - user is using __init__ from repo # without setting up git repository. From 4c5388124211ca4164e8e4dd2897f87b342c5f78 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 14:33:37 +0500 Subject: [PATCH 09/42] blenderbim makefile - safeguards for wheels used in the build --- src/blenderbim/Makefile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/blenderbim/Makefile b/src/blenderbim/Makefile index 1c0976a156..584466e9ba 100644 --- a/src/blenderbim/Makefile +++ b/src/blenderbim/Makefile @@ -297,6 +297,27 @@ ifeq ($(PLATFORM), macos) mv "$$prev_whl_name" "$$whl_name"; endif + # Safeguard for unhandled universal files. + @wheels=$$(find build/blenderbim/wheels/*universal2*.whl); \ + if [ -n "$$wheels" ]; then \ + echo "Found universal2 wheel files:"; \ + echo "$$wheels"; \ + echo "Error: universal2 wheel files are not supported by Blender!"; \ + exit 1; \ + fi + +ifneq ($(PLATFORM), linux) + # Safeguard: in case one of `pip download` will break, + # it will produce a linux wheel for non-linux build (our github action machine is using linux). + @wheels=$$(find build/blenderbim/wheels/*manylinux_*.whl); \ + if [ -n "$$wheels" ]; then \ + echo "Found linux wheel files in non-linux build:"; \ + echo "$$wheels"; \ + echo "Error: linux wheels are incompatible with build $(PLATFORM)!"; \ + exit 1; \ + fi +endif + $(PYTHON) scripts/get_wheels.py build/blenderbim/wheels build/blenderbim/blender_manifest.toml rm -rf build/blenderbim/bim/ rm -rf build/blenderbim/core/ From 797e3e8d8ce38e211c6bf75dc0bcb49eacddbac3 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 15:43:17 +0500 Subject: [PATCH 10/42] bbim_translations - not to fail if user has fake-bpy-module --- src/blenderbim/scripts/bbim_translations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/blenderbim/scripts/bbim_translations.py b/src/blenderbim/scripts/bbim_translations.py index 62f87e093c..653eca7ebb 100644 --- a/src/blenderbim/scripts/bbim_translations.py +++ b/src/blenderbim/scripts/bbim_translations.py @@ -1,5 +1,8 @@ try: import bpy + # Ensure it's not fake-bpy-module. + if not hasattr(bpy, "context"): + raise ModuleNotFoundError import bl_i18n_utils import addon_utils From 1fbdb4811de7915126541411976f3f6c19539e10 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 15:44:04 +0500 Subject: [PATCH 11/42] makefile - move ifcopenshell packages wheels instead of copy to keep it clean --- src/blenderbim/Makefile | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/blenderbim/Makefile b/src/blenderbim/Makefile index 584466e9ba..9dfe80597d 100644 --- a/src/blenderbim/Makefile +++ b/src/blenderbim/Makefile @@ -114,19 +114,19 @@ endif mkdir -p build/wheels # Provides IfcOpenShell Python functionality - cd ../ifcopenshell-python && make dist PLATFORM=$(PLATFORM)64 PYVERSION=$(PYVERSION) && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../bcf && make dist && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../ifcclash && make dist && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../ifcbimtester && make dist && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../ifctester && make dist && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../ifcfm && make dist && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../bsdd && make dist && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../ifcdiff && make dist && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../ifccsv && make dist && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../ifcpatch && make dist && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../ifc4d && make dist && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../ifc5d && make dist && cp dist/*.whl ../blenderbim/build/wheels/ - cd ../ifccityjson && make dist && cp dist/*.whl ../blenderbim/build/wheels/ + cd ../ifcopenshell-python && make dist PLATFORM=$(PLATFORM)64 PYVERSION=$(PYVERSION) && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../bcf && make dist && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../ifcclash && make dist && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../ifcbimtester && make dist && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../ifctester && make dist && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../ifcfm && make dist && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../bsdd && make dist && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../ifcdiff && make dist && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../ifccsv && make dist && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../ifcpatch && make dist && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../ifc4d && make dist && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../ifc5d && make dist && mv dist/*.whl ../blenderbim/build/wheels/ + cd ../ifccityjson && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd build && . env/$(VENV_ACTIVATE) && $(PIP) download GitPython --dest=./wheels # Provides audio playback for costing # This is a REALLY IMPORTANT feature @@ -255,6 +255,15 @@ endif $(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' build/pyproject.toml cd build && . env/$(VENV_ACTIVATE) && $(PYTHON) -m build cp build/dist/*.whl build/wheels/ + + # Safeguard for non-wheel dependencies slipping in. + wheels=$$(find build/wheels/* ! -name "*.whl"); \ + if [ -n "$$wheels" ]; then \ + echo "Found non-wheel dependencies:"; \ + echo "$$wheels"; \ + echo "Error: non-wheel dependencies are not supported by Blender!"; \ + exit 1; \ + fi mv build/wheels/*.whl build/blenderbim/wheels/ # Ugly patch to accomodate MacOS universal builds not being recognized by Blender. @@ -298,7 +307,7 @@ ifeq ($(PLATFORM), macos) endif # Safeguard for unhandled universal files. - @wheels=$$(find build/blenderbim/wheels/*universal2*.whl); \ + wheels=$$(find build/blenderbim/wheels/*universal2*.whl); \ if [ -n "$$wheels" ]; then \ echo "Found universal2 wheel files:"; \ echo "$$wheels"; \ @@ -309,7 +318,7 @@ endif ifneq ($(PLATFORM), linux) # Safeguard: in case one of `pip download` will break, # it will produce a linux wheel for non-linux build (our github action machine is using linux). - @wheels=$$(find build/blenderbim/wheels/*manylinux_*.whl); \ + wheels=$$(find build/blenderbim/wheels/*manylinux_*.whl); \ if [ -n "$$wheels" ]; then \ echo "Found linux wheel files in non-linux build:"; \ echo "$$wheels"; \ From a7e856c311c6769904d30cbf525af760614504d9 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 16:10:02 +0500 Subject: [PATCH 12/42] Update ci-blenderbim.yml after all makefile changes --- .github/workflows/ci-blenderbim.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-blenderbim.yml b/.github/workflows/ci-blenderbim.yml index fff54a5909..f683594063 100644 --- a/.github/workflows/ci-blenderbim.yml +++ b/.github/workflows/ci-blenderbim.yml @@ -1,5 +1,10 @@ name: ci-blenderbim +# Differences from ci-blenderbim-daily.yml: +# - make has IS_STABLE=TRUE +# - action is never triggered and executed only manually +# - doesn't add a current date to the release and tag + on: workflow_dispatch: @@ -48,15 +53,20 @@ jobs: run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT - name: Compile run: | - cp -r src/blenderbim src/blenderbim_${{ matrix.config.short_name }}_${{ matrix.pyver }} && - cd src/blenderbim_${{ matrix.config.short_name }}_${{ matrix.pyver }} && + cd src/blenderbim && make dist PLATFORM=${{ matrix.config.short_name }} PYVERSION=${{ matrix.pyver }} IS_STABLE=TRUE + - name: Find zip file name + id: find_zip + run: | + filepath=$(ls src/blenderbim/dist/blenderbim_*.zip) + echo "filepath=$filepath" >> $GITHUB_OUTPUT + echo "filename=$(basename $filepath)" >> $GITHUB_OUTPUT - name: Upload zip file to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: src/blenderbim_${{ matrix.config.short_name }}_${{ matrix.pyver }}/dist/blenderbim-${{steps.version.outputs.version}}-${{ matrix.pyver }}-${{ matrix.config.short_name }}.zip - asset_name: blenderbim-${{steps.version.outputs.version}}-${{ matrix.pyver }}-${{ matrix.config.short_name }}.zip + file: ${{ steps.find_zip.outputs.filepath }} + asset_name: ${{ steps.find_zip.outputs.filename }} release_name: "blenderbim-${{steps.version.outputs.version}}" tag: "blenderbim-${{steps.version.outputs.version}}" overwrite: true From 93fe2e9b0fc97347c46efb21ed71c1d68d0b18ae Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 22 Jul 2024 17:26:59 +0500 Subject: [PATCH 13/42] bim.assing_class - add description, add poll check for selected objs also added description to pie menu entry --- src/blenderbim/blenderbim/bim/module/model/pie.py | 1 + src/blenderbim/blenderbim/bim/module/root/operator.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/pie.py b/src/blenderbim/blenderbim/bim/module/model/pie.py index 799673bffd..e76a5eb52e 100644 --- a/src/blenderbim/blenderbim/bim/module/model/pie.py +++ b/src/blenderbim/blenderbim/bim/module/model/pie.py @@ -26,6 +26,7 @@ from blenderbim.bim.ifc import IfcStore class OpenPieClass(bpy.types.Operator): bl_idname = "bim.open_pie_class" bl_label = "Open Pie Class" + bl_description = "Assign the IFC Class to the selected objects" def execute(self, context): bpy.ops.wm.call_menu_pie(name="VIEW3D_MT_PIE_bim_class") diff --git a/src/blenderbim/blenderbim/bim/module/root/operator.py b/src/blenderbim/blenderbim/bim/module/root/operator.py index b306086e2b..f58077282a 100644 --- a/src/blenderbim/blenderbim/bim/module/root/operator.py +++ b/src/blenderbim/blenderbim/bim/module/root/operator.py @@ -166,7 +166,7 @@ class AssignClass(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.assign_class" bl_label = "Assign IFC Class" bl_options = {"REGISTER", "UNDO"} - bl_description = "Assign the IFC Class to the selected object" + bl_description = "Assign the IFC Class to the selected objects" obj: bpy.props.StringProperty() ifc_class: bpy.props.StringProperty() predefined_type: bpy.props.StringProperty() @@ -175,6 +175,13 @@ class AssignClass(bpy.types.Operator, tool.Ifc.Operator): should_add_representation: bpy.props.BoolProperty(default=True) ifc_representation_class: bpy.props.StringProperty() + @classmethod + def poll(cls, context): + if not context.active_object and not context.selected_objects: + cls.poll_message_set("No object selected.") + return False + return True + def _execute(self, context): props = context.scene.BIMRootProperties objects = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects or [context.active_object] From 54131b3fe5af14c8a43dca8faff3869f933dcec2 Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Mon, 22 Jul 2024 13:21:49 -0700 Subject: [PATCH 14/42] IfcSectionedSolidHorizontal logs warning if Directrix is not a piecewise function, rather than silently failing. --- src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp b/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp index 7f5593bbfd..74e6e4cd89 100644 --- a/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp +++ b/src/ifcgeom/mapping/IfcSectionedSolidHorizontal.cpp @@ -52,7 +52,8 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSolidHorizontal* in auto pwf = taxonomy::dcast(dir); if (!pwf) { // Only implement on alignment curves - return nullptr; + Logger::Warning("IfcSectionedSolidHorizontal is only implemented for piecewise function Directrix curves", inst); + return nullptr; } { @@ -111,6 +112,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSectionedSolidHorizontal* in loft->axis = nullptr; // @todo currently only the case is handled where directrix returns a piecewise_function + // @todo this "if" statement is not really required because the function returns at the start if the Directrix is not a piecewise function if (pwf) { double start = std::max(0., cross_sections.front().dist_along); double end = std::min(pwf->length(), cross_sections.back().dist_along); From 96b4ad8cd39fa60530e8129d2a9aff2dd86d140b Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 23 Jul 2024 11:41:46 +1000 Subject: [PATCH 15/42] No longer ship bbim addon with bimtester --- src/blenderbim/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/src/blenderbim/Makefile b/src/blenderbim/Makefile index 9dfe80597d..1388975b42 100644 --- a/src/blenderbim/Makefile +++ b/src/blenderbim/Makefile @@ -117,7 +117,6 @@ endif cd ../ifcopenshell-python && make dist PLATFORM=$(PLATFORM)64 PYVERSION=$(PYVERSION) && mv dist/*.whl ../blenderbim/build/wheels/ cd ../bcf && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifcclash && make dist && mv dist/*.whl ../blenderbim/build/wheels/ - cd ../ifcbimtester && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifctester && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifcfm && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../bsdd && make dist && mv dist/*.whl ../blenderbim/build/wheels/ From 5d4a3d504c8f52890ecdd81b2800010794f6e993 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 23 Jul 2024 17:00:22 +1000 Subject: [PATCH 16/42] Support alpha versions for all wheels --- .github/workflows/ci-bcf-pypi.yml | 2 +- .github/workflows/ci-bsdd-pypi.yaml | 2 +- .github/workflows/ci-ifc4d-pypi.yaml | 2 +- .github/workflows/ci-ifc5d-pypi.yaml | 2 +- .github/workflows/ci-ifccityjson-pypi.yaml | 2 +- .github/workflows/ci-ifcclash-pypi.yaml | 2 +- .github/workflows/ci-ifccsv-pypi.yaml | 2 +- .github/workflows/ci-ifcdiff-pypi.yaml | 2 +- .github/workflows/ci-ifcfm-pypi.yaml | 2 +- .github/workflows/ci-ifcopenshell-python-pypi.yml | 2 +- .github/workflows/ci-ifcpatch-pypi.yaml | 2 +- .github/workflows/ci-ifctester-pypi.yml | 2 +- src/blenderbim/Makefile | 4 ++++ src/common.mk | 11 +++++++++++ src/ifcopenshell-python/Makefile | 15 +++++++++++++-- 15 files changed, 40 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci-bcf-pypi.yml b/.github/workflows/ci-bcf-pypi.yml index 7fed2dc053..4b70c77e0a 100644 --- a/.github/workflows/ci-bcf-pypi.yml +++ b/.github/workflows/ci-bcf-pypi.yml @@ -32,7 +32,7 @@ jobs: run: | pip install build cd src/bcf && - make dist + make dist IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/.github/workflows/ci-bsdd-pypi.yaml b/.github/workflows/ci-bsdd-pypi.yaml index 67da096296..a1f68bf236 100644 --- a/.github/workflows/ci-bsdd-pypi.yaml +++ b/.github/workflows/ci-bsdd-pypi.yaml @@ -26,7 +26,7 @@ jobs: run: | pip install build cd src/bsdd && - make dist + make dist IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/.github/workflows/ci-ifc4d-pypi.yaml b/.github/workflows/ci-ifc4d-pypi.yaml index 79707a5881..d2fa648ddb 100644 --- a/.github/workflows/ci-ifc4d-pypi.yaml +++ b/.github/workflows/ci-ifc4d-pypi.yaml @@ -26,7 +26,7 @@ jobs: run: | pip install build cd src/ifc4d && - make dist + make dist IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/.github/workflows/ci-ifc5d-pypi.yaml b/.github/workflows/ci-ifc5d-pypi.yaml index b626316267..c4669e1af2 100644 --- a/.github/workflows/ci-ifc5d-pypi.yaml +++ b/.github/workflows/ci-ifc5d-pypi.yaml @@ -26,7 +26,7 @@ jobs: run: | pip install build cd src/ifc5d && - make dist + make dist IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/.github/workflows/ci-ifccityjson-pypi.yaml b/.github/workflows/ci-ifccityjson-pypi.yaml index 2003acf169..f3c921b094 100644 --- a/.github/workflows/ci-ifccityjson-pypi.yaml +++ b/.github/workflows/ci-ifccityjson-pypi.yaml @@ -26,7 +26,7 @@ jobs: run: | pip install build cd src/ifccityjson && - make dist + make dist IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/.github/workflows/ci-ifcclash-pypi.yaml b/.github/workflows/ci-ifcclash-pypi.yaml index bd2875e138..e53c12ab67 100644 --- a/.github/workflows/ci-ifcclash-pypi.yaml +++ b/.github/workflows/ci-ifcclash-pypi.yaml @@ -26,7 +26,7 @@ jobs: run: | pip install build cd src/ifcclash && - make dist + make dist IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/.github/workflows/ci-ifccsv-pypi.yaml b/.github/workflows/ci-ifccsv-pypi.yaml index 50803918d7..d1a40f94ab 100644 --- a/.github/workflows/ci-ifccsv-pypi.yaml +++ b/.github/workflows/ci-ifccsv-pypi.yaml @@ -26,7 +26,7 @@ jobs: run: | pip install build cd src/ifccsv && - make dist + make dist IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/.github/workflows/ci-ifcdiff-pypi.yaml b/.github/workflows/ci-ifcdiff-pypi.yaml index 654357409b..6fc88a6059 100644 --- a/.github/workflows/ci-ifcdiff-pypi.yaml +++ b/.github/workflows/ci-ifcdiff-pypi.yaml @@ -26,7 +26,7 @@ jobs: run: | pip install build cd src/ifcdiff && - make dist + make dist IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/.github/workflows/ci-ifcfm-pypi.yaml b/.github/workflows/ci-ifcfm-pypi.yaml index 177ba6d01e..576d150dc4 100644 --- a/.github/workflows/ci-ifcfm-pypi.yaml +++ b/.github/workflows/ci-ifcfm-pypi.yaml @@ -26,7 +26,7 @@ jobs: run: | pip install build cd src/ifcfm && - make dist + make dist IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/.github/workflows/ci-ifcopenshell-python-pypi.yml b/.github/workflows/ci-ifcopenshell-python-pypi.yml index 6a87361157..73199521bb 100644 --- a/.github/workflows/ci-ifcopenshell-python-pypi.yml +++ b/.github/workflows/ci-ifcopenshell-python-pypi.yml @@ -57,7 +57,7 @@ jobs: pip install build cp -r src/ifcopenshell-python src/ifcopenshell_${{ matrix.config.short_name }}_${{ matrix.pyver }} && cd src/ifcopenshell_${{ matrix.config.short_name }}_${{ matrix.pyver }} && - make dist PLATFORM=${{ matrix.config.short_name }} PYVERSION=${{ matrix.pyver }} + make dist PLATFORM=${{ matrix.config.short_name }} PYVERSION=${{ matrix.pyver }} IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/.github/workflows/ci-ifcpatch-pypi.yaml b/.github/workflows/ci-ifcpatch-pypi.yaml index 2b39a77bea..cdeb78c27d 100644 --- a/.github/workflows/ci-ifcpatch-pypi.yaml +++ b/.github/workflows/ci-ifcpatch-pypi.yaml @@ -26,7 +26,7 @@ jobs: run: | pip install build cd src/ifcpatch && - make dist + make dist IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/.github/workflows/ci-ifctester-pypi.yml b/.github/workflows/ci-ifctester-pypi.yml index f7e29ac111..51835418e7 100644 --- a/.github/workflows/ci-ifctester-pypi.yml +++ b/.github/workflows/ci-ifctester-pypi.yml @@ -26,7 +26,7 @@ jobs: run: | pip install build cd src/ifctester && - make dist + make dist IS_STABLE=TRUE - name: Publish a Python distribution to PyPI uses: ortega2247/pypi-upload-action@master with: diff --git a/src/blenderbim/Makefile b/src/blenderbim/Makefile index 1388975b42..f1e4f1a01f 100644 --- a/src/blenderbim/Makefile +++ b/src/blenderbim/Makefile @@ -251,7 +251,11 @@ endif $(SED) "s/os-arch/$(BLENDER_PLATFORM)/" build/blenderbim/blender_manifest.toml # Provides BlenderBIM Add-on functionality +ifeq ($(IS_STABLE), TRUE) $(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' build/pyproject.toml +else + $(SED) 's/version = "0.0.0"/version = "$(VERSION)a$(VERSION_DATE)"/' build/pyproject.toml +endif cd build && . env/$(VENV_ACTIVATE) && $(PYTHON) -m build cp build/dist/*.whl build/wheels/ diff --git a/src/common.mk b/src/common.mk index 22428cdbdb..0d8742a40f 100644 --- a/src/common.mk +++ b/src/common.mk @@ -1,6 +1,8 @@ +IS_STABLE:=FALSE PYTHON:=python3.11 PIP:=pip3.11 VERSION:=$(shell cat ../../VERSION) +VERSION_DATE:=$(shell date '+%y%m%d') SED:=sed -i VENV_BIN:=bin @@ -23,11 +25,20 @@ dist: mkdir -p dist cp -r $(PACKAGE_NAME) build/ cp pyproject.toml build/ +ifeq ($(IS_STABLE), TRUE) $(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' build/pyproject.toml ifdef IS_MODULE $(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' build/$(PACKAGE_NAME) else $(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' build/$(PACKAGE_NAME)/__init__.py +endif +else + $(SED) 's/version = "0.0.0"/version = "$(VERSION)a$(VERSION_DATE)"/' build/pyproject.toml +ifdef IS_MODULE + $(SED) 's/version = "0.0.0"/version = "$(VERSION)-alpha$(VERSION_DATE)"/' build/$(PACKAGE_NAME) +else + $(SED) 's/version = "0.0.0"/version = "$(VERSION)-alpha$(VERSION_DATE)"/' build/$(PACKAGE_NAME)/__init__.py +endif endif cd build && $(PYTHON) -m venv env && . env/$(VENV_ACTIVATE) && $(PIP) install build cd build && . env/$(VENV_ACTIVATE) && $(PYTHON) -m build diff --git a/src/ifcopenshell-python/Makefile b/src/ifcopenshell-python/Makefile index 93df7edfaf..4e125af5b5 100644 --- a/src/ifcopenshell-python/Makefile +++ b/src/ifcopenshell-python/Makefile @@ -1,4 +1,6 @@ +IS_STABLE:=FALSE VERSION:=$(shell cat ../../VERSION) +VERSION_DATE:=$(shell date '+%y%m%d') PYVERSION:=py311 PLATFORM:=linux64 @@ -120,11 +122,20 @@ endif cp -r build/botbuild/ifcopenshell/*ifcopenshell_wrapper* build/ifcopenshell/ cp ../../README.md build/ cp pyproject.toml build/ +ifeq ($(IS_STABLE), TRUE) $(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' build/pyproject.toml $(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' build/ifcopenshell/__init__.py +else + $(SED) 's/version = "0.0.0"/version = "$(VERSION)a$(VERSION_DATE)"/' build/pyproject.toml + $(SED) 's/version = "0.0.0"/version = "$(VERSION)-alpha$(VERSION_DATE)"/' build/ifcopenshell/__init__.py +endif cd build && $(PYTHON) -m venv env && . env/$(VENV_ACTIVATE) && $(PIP) install build cd build && . env/$(VENV_ACTIVATE) && $(PYTHON) -m build - mv build/dist/ifcopenshell-$(VERSION)-py3-none-any.whl dist/ifcopenshell-$(VERSION)-$(PYVERSION)-none-$(PLATFORMTAG).whl - rm -rf build +ifeq ($(IS_STABLE), TRUE) + mv build/dist/ifcopenshell-*.whl dist/ifcopenshell-$(VERSION)-$(PYVERSION)-none-$(PLATFORMTAG).whl +else + cp build/dist/ifcopenshell-*.whl dist/ifcopenshell-$(VERSION)a$(VERSION_DATE)-$(PYVERSION)-none-$(PLATFORMTAG).whl +endif + # rm -rf build From f7a3b0706b8bbbd87504eb0c13bd4ee1e5182f46 Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:24:49 +0300 Subject: [PATCH 17/42] fix: using blender python executable --- src/blenderbim/blenderbim/tool/web.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/tool/web.py b/src/blenderbim/blenderbim/tool/web.py index 1b38949ccc..109b426fc9 100644 --- a/src/blenderbim/blenderbim/tool/web.py +++ b/src/blenderbim/blenderbim/tool/web.py @@ -22,6 +22,7 @@ import blenderbim.core.tool import blenderbim.tool as tool import ifcopenshell.api.sequence import socket +import sys import os import subprocess import webbrowser @@ -71,7 +72,9 @@ class Web(blenderbim.core.tool.Web): ws_path = os.path.join(webui_path, "sioserver.py") - ws_process = subprocess.Popen(["python", ws_path, "--p", str(port), "--host", "127.0.0.1"], cwd=webui_path) + ws_process = subprocess.Popen( + [sys.executable, ws_path, "--p", str(port), "--host", "127.0.0.1"], cwd=webui_path + ) cls.open_web_browser(port) cls.set_is_running(True) From 4e79384c8e241def4d08de9c2349ca113912d530 Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:41:05 +0300 Subject: [PATCH 18/42] fix packages path when using dev setup with symlinks --- src/blenderbim/blenderbim/bim/data/webui/sioserver.py | 8 ++++++++ src/blenderbim/blenderbim/tool/web.py | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/data/webui/sioserver.py b/src/blenderbim/blenderbim/bim/data/webui/sioserver.py index d367c4d579..b497c456be 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/sioserver.py +++ b/src/blenderbim/blenderbim/bim/data/webui/sioserver.py @@ -1,3 +1,11 @@ +import sys +import os + +blenderbim_path = os.environ.get("blenderbim_path") +if blenderbim_path: + blenderbim_lib_path = os.path.join(blenderbim_path, "libs", "site", "packages") + sys.path.insert(0, blenderbim_lib_path) + import argparse from aiohttp import web import socketio diff --git a/src/blenderbim/blenderbim/tool/web.py b/src/blenderbim/blenderbim/tool/web.py index 109b426fc9..7227bf196f 100644 --- a/src/blenderbim/blenderbim/tool/web.py +++ b/src/blenderbim/blenderbim/tool/web.py @@ -66,14 +66,21 @@ class Web(blenderbim.core.tool.Web): @classmethod def start_websocket_server(cls, port): + import addon_utils + global ws_process webui_path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "webui") - ws_path = os.path.join(webui_path, "sioserver.py") + addon = [a for a in addon_utils.modules() if a.bl_info["name"] == "BlenderBIM"][0] + blenderbim_path = os.path.dirname(addon.__file__) + + env = os.environ.copy() + env["blenderbim_path"] = blenderbim_path + ws_process = subprocess.Popen( - [sys.executable, ws_path, "--p", str(port), "--host", "127.0.0.1"], cwd=webui_path + [sys.executable, ws_path, "--p", str(port), "--host", "127.0.0.1"], cwd=webui_path, env=env ) cls.open_web_browser(port) cls.set_is_running(True) From 216b3a4e374484cbef71ee7146e653897f529161 Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:42:23 +0300 Subject: [PATCH 19/42] rename variables to have more meaningful names --- .../blenderbim/bim/module/csv/operator.py | 4 +--- src/blenderbim/blenderbim/tool/sequence.py | 8 +++++--- src/blenderbim/blenderbim/tool/web.py | 16 +++++++--------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/csv/operator.py b/src/blenderbim/blenderbim/bim/module/csv/operator.py index 08ae965395..e6049c912c 100644 --- a/src/blenderbim/blenderbim/bim/module/csv/operator.py +++ b/src/blenderbim/blenderbim/bim/module/csv/operator.py @@ -254,9 +254,7 @@ class ExportIfcCsv(bpy.types.Operator): schedule_creator = scheduler.Scheduler() schedule_creator.schedule(self.filepath, tool.Drawing.get_path_with_ext(self.filepath, "svg")) if props.format == "web": - tool.Web.send_webui_data( - extra_data=ifc_csv.dataframe.to_csv(index=False), extra_data_key="csv_data", event="csv_data" - ) + tool.Web.send_webui_data(data=ifc_csv.dataframe.to_csv(index=False), data_key="csv_data", event="csv_data") self.report({"INFO"}, f"Data is exported to {props.format.upper()}.") return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/tool/sequence.py b/src/blenderbim/blenderbim/tool/sequence.py index b01ef21a42..2382224e0b 100644 --- a/src/blenderbim/blenderbim/tool/sequence.py +++ b/src/blenderbim/blenderbim/tool/sequence.py @@ -1546,14 +1546,16 @@ class Sequence(blenderbim.core.tool.Sequence): ) -> None: if bpy.context.scene.WebProperties.is_connected: gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)} - tool.Web.send_webui_data(extra_data=gantt_data, extra_data_key="gantt_data", event="gantt_data") + tool.Web.send_webui_data(data=gantt_data, data_key="gantt_data", event="gantt_data") return - + with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"), "w") as f: with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.mustache"), "r") as t: task_b64 = base64.b64encode(bytes(json.dumps(task_json), "utf-8")).decode("utf-8") f.write( - pystache.render(t.read(), {"json_data": task_b64, "data": json.dumps(work_schedule.get_info(recursive=True))}) + pystache.render( + t.read(), {"json_data": task_b64, "data": json.dumps(work_schedule.get_info(recursive=True))} + ) ) webbrowser.open("file://" + os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html")) diff --git a/src/blenderbim/blenderbim/tool/web.py b/src/blenderbim/blenderbim/tool/web.py index 7227bf196f..2f4af1bda7 100644 --- a/src/blenderbim/blenderbim/tool/web.py +++ b/src/blenderbim/blenderbim/tool/web.py @@ -136,22 +136,20 @@ class Web(blenderbim.core.tool.Web): print("Websocket server terminated successfully") @classmethod - def send_webui_data( - cls, extra_data=None, extra_data_key="data", event="data", namespace="/blender", use_web_data=True - ): + def send_webui_data(cls, data=None, data_key="data", event="data", namespace="/blender", use_web_data=True): global ws_thread - data = {} + payload = {} if use_web_data: if not WebData.is_loaded: WebData.load() - data = WebData.data + payload = WebData.data - if extra_data is not None: - data[extra_data_key] = extra_data + if data is not None: + payload[data_key] = data if ws_thread is not None and bpy.context.scene.WebProperties.is_connected: - ws_thread.run_coro(cls.sio_send(data, event, namespace)) + ws_thread.run_coro(cls.sio_send(payload, event, namespace)) @classmethod def check_operator_queue(cls): @@ -210,7 +208,7 @@ class Web(blenderbim.core.tool.Web): work_schedule = ifc_file.by_id(operator_data["workScheduleId"]) task_json = tool.Sequence.create_tasks_json(work_schedule) gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)} - cls.send_webui_data(extra_data=gantt_data, extra_data_key="gantt_data", event="gantt_data") + cls.send_webui_data(data=gantt_data, data_key="gantt_data", event="gantt_data") @classmethod def open_web_browser(cls, port): From 6defdc63b558997d154041442b8b1cf9278cd7a9 Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:48:12 +0300 Subject: [PATCH 20/42] add type hints and docstring to send_webui_data function --- src/blenderbim/blenderbim/tool/web.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/tool/web.py b/src/blenderbim/blenderbim/tool/web.py index 2f4af1bda7..04a369891b 100644 --- a/src/blenderbim/blenderbim/tool/web.py +++ b/src/blenderbim/blenderbim/tool/web.py @@ -21,6 +21,7 @@ from blenderbim.bim.module.web.data import WebData import blenderbim.core.tool import blenderbim.tool as tool import ifcopenshell.api.sequence +from typing import Any, Dict, Optional import socket import sys import os @@ -136,7 +137,25 @@ class Web(blenderbim.core.tool.Web): print("Websocket server terminated successfully") @classmethod - def send_webui_data(cls, data=None, data_key="data", event="data", namespace="/blender", use_web_data=True): + def send_webui_data( + cls, + data: Optional[Any] = None, + data_key: str = "data", + event: str = "data", + namespace: str = "/blender", + use_web_data: bool = True, + ) -> None: + """ + Sends data to the Web UI via Websocket connection. + + Args: + - data (Optional[Any]): The data to send. If None, just sends data from WebData. + - data_key (str): The key under which to store the data in the payload. Defaults to "data". + - event (str): The WebSocket event to emit. Defaults to "data". + - namespace (str): The namespace for the WebSocket event. Defaults to "/blender". + - use_web_data (bool): Whether to use data from WebData. Defaults to True. + """ + global ws_thread payload = {} From 500587f267d889e08bf077ce5bd71b09eeda06b5 Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:45:31 +0300 Subject: [PATCH 21/42] make webdata ifc_file only show filename instead of full path --- src/blenderbim/blenderbim/bim/module/web/data.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/module/web/data.py b/src/blenderbim/blenderbim/bim/module/web/data.py index c13920e47a..812a4d3ca1 100644 --- a/src/blenderbim/blenderbim/bim/module/web/data.py +++ b/src/blenderbim/blenderbim/bim/module/web/data.py @@ -18,6 +18,7 @@ import bpy import blenderbim.tool as tool +import os def refresh(): @@ -37,4 +38,5 @@ class WebData: @classmethod def ifc_file_name(cls): - return bpy.context.scene.BIMProperties.ifc_file + filename = os.path.basename(bpy.context.scene.BIMProperties.ifc_file) + return filename From 7851efd0c82eaf5eabbd102e376a7e8d956de9f6 Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:49:32 +0300 Subject: [PATCH 22/42] use ifc_file instead of IFC_File --- src/blenderbim/blenderbim/bim/data/webui/static/js/gantt.js | 5 ++--- src/blenderbim/blenderbim/bim/data/webui/static/js/index.js | 2 +- src/blenderbim/blenderbim/bim/module/web/data.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/js/gantt.js b/src/blenderbim/blenderbim/bim/data/webui/static/js/gantt.js index b318aa0788..b15396bf9f 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/js/gantt.js +++ b/src/blenderbim/blenderbim/bim/data/webui/static/js/gantt.js @@ -61,7 +61,7 @@ function handleGanttData(data) { console.log(data); - const filename = data["data"]["IFC_File"]; + const filename = data["data"]["ifc_file"]; const ganttTasks = data["data"]["gantt_data"]["tasks"]; const ganttWorkSched = data["data"]["gantt_data"]["work_schedule"]; // const ganttWorkSched = {}; @@ -233,8 +233,7 @@ function addGanttElement(blenderId, tasks, workSched, filename) { addEventListener("afterprint", (event) => { g.setEditable(true); - },); - + }); let css = "@media print {\n" + diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js b/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js index 39e2bee442..907c5a3d08 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js +++ b/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js @@ -41,7 +41,7 @@ function handleBlenderDisconnect(blenderId) { function handleCsvData(data) { const blenderId = data["blenderId"]; const csvData = data["data"]["csv_data"]; - const filename = data["data"]["IFC_File"]; + const filename = data["data"]["ifc_file"]; console.log(data); if (connectedClients.hasOwnProperty(blenderId)) { diff --git a/src/blenderbim/blenderbim/bim/module/web/data.py b/src/blenderbim/blenderbim/bim/module/web/data.py index 812a4d3ca1..b6966d07bd 100644 --- a/src/blenderbim/blenderbim/bim/module/web/data.py +++ b/src/blenderbim/blenderbim/bim/module/web/data.py @@ -32,7 +32,7 @@ class WebData: @classmethod def load(cls): cls.data = { - "IFC_File": cls.ifc_file_name(), + "ifc_file": cls.ifc_file_name(), } cls.is_loaded = True From 84d4bf16c3825e5b6b9f6500c4141d1db7a0db8e Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:24:47 +0300 Subject: [PATCH 23/42] remoce unnecessary div element --- .../blenderbim/bim/data/webui/static/css/gantt.css | 9 +-------- .../blenderbim/bim/data/webui/static/css/index.css | 10 +--------- .../blenderbim/bim/data/webui/templates/gantt.html | 7 +++++-- .../blenderbim/bim/data/webui/templates/index.html | 7 +++++-- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css b/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css index 82354d6760..c7bf7c5bb0 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css +++ b/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css @@ -26,6 +26,7 @@ nav { display: flex; align-items: center; position: relative; + border-bottom: 2px solid #25682a; } nav .logo { @@ -58,14 +59,6 @@ nav ul li a.active { color: #3fb449; } -nav .bottom-bar { - position: absolute; - bottom: 0; - left: 0; - width: 100%; - height: 2px; - background-color: #25682a; -} .table-description { margin-bottom: 1rem; diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css b/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css index ddcf94cace..290f42b430 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css +++ b/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css @@ -34,6 +34,7 @@ nav { display: flex; align-items: center; position: relative; + border-bottom: 2px solid #25682a; } nav .logo { @@ -64,13 +65,4 @@ nav ul li a { nav ul li a:hover, nav ul li a.active { color: #3fb449; -} - -nav .bottom-bar { - position: absolute; - bottom: 0; - left: 0; - width: 100%; - height: 2px; - background-color: #25682a; } \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/data/webui/templates/gantt.html b/src/blenderbim/blenderbim/bim/data/webui/templates/gantt.html index 7f0d22fbb8..d934afd737 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/templates/gantt.html +++ b/src/blenderbim/blenderbim/bim/data/webui/templates/gantt.html @@ -22,12 +22,15 @@
diff --git a/src/blenderbim/blenderbim/bim/data/webui/templates/index.html b/src/blenderbim/blenderbim/bim/data/webui/templates/index.html index 208d51ba35..e726facd0e 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/templates/index.html +++ b/src/blenderbim/blenderbim/bim/data/webui/templates/index.html @@ -28,12 +28,15 @@
From b0fe30c5977276da1e51343d4f28dc2c80b4b837 Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Wed, 17 Jul 2024 22:48:01 +0300 Subject: [PATCH 24/42] add caching of blender messages --- .../blenderbim/bim/data/webui/sioserver.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/data/webui/sioserver.py b/src/blenderbim/blenderbim/bim/data/webui/sioserver.py index b497c456be..c7003576ff 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/sioserver.py +++ b/src/blenderbim/blenderbim/bim/data/webui/sioserver.py @@ -29,6 +29,8 @@ sio = socketio.AsyncServer( app = web.Application() sio.attach(app) + +# represents a caching for blender messages blender_messages = {} @@ -39,6 +41,8 @@ class WebNamespace(socketio.AsyncNamespace): async def on_connect(self, sid, environ): print(f"Web client connected: {sid}") + if blender_messages: + await self.send_cached_messages(sid) async def on_disconnect(self, sid): print(f"Web client disconnected: {sid}") @@ -51,6 +55,14 @@ class WebNamespace(socketio.AsyncNamespace): room=data["blenderId"], ) + async def send_cached_messages(self, sid): + # Send cached messages to the connected web client + for blenderId, messages in blender_messages.items(): + if "csv_data" in messages: + await self.emit("csv_data", {"blenderId": blenderId, "data": messages["csv_data"]}, room=sid) + if "gantt_data" in messages: + await self.emit("gantt_data", {"blenderId": blenderId, "data": messages["gantt_data"]}, room=sid) + # Blender namespace class BlenderNamespace(socketio.AsyncNamespace): From 4912e86e6eed5932c6c89a44fc80a75f348c3dab Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:19:29 +0300 Subject: [PATCH 25/42] fix using errno module instead of hardcoded since error code numbers differ based on OS --- src/blenderbim/blenderbim/tool/web.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/tool/web.py b/src/blenderbim/blenderbim/tool/web.py index 04a369891b..1d62be294b 100644 --- a/src/blenderbim/blenderbim/tool/web.py +++ b/src/blenderbim/blenderbim/tool/web.py @@ -25,6 +25,7 @@ from typing import Any, Dict, Optional import socket import sys import os +import errno import subprocess import webbrowser import asyncio @@ -59,11 +60,11 @@ class Web(blenderbim.core.tool.Web): @classmethod def is_port_available(cls, port): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - # connect_ex returns 0 if the connection succeeds + # connect_ex returns errno.SUCCESS (0) if the connection succeeds # indicating the port is in use - # otherwise returns 10061 if no server is listening + # otherwise returns errno.ECONNREFUSED (111 or 10061) if no server is listening # indicating the port is available for use - return s.connect_ex(("localhost", port)) == 10061 + return s.connect_ex(("localhost", port)) == errno.ECONNREFUSED @classmethod def start_websocket_server(cls, port): From f50bbf9704ee27328bd9b2140fd0e5063e47ca8e Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Thu, 18 Jul 2024 22:50:37 +0300 Subject: [PATCH 26/42] add warning to web ui on changes and is_dirty in web module data --- .../blenderbim/bim/data/webui/sioserver.py | 2 +- .../bim/data/webui/static/css/gantt.css | 7 +++++++ .../bim/data/webui/static/css/index.css | 8 +++++++ .../bim/data/webui/static/js/gantt.js | 21 +++++++++++++++++++ .../bim/data/webui/static/js/index.js | 21 +++++++++++++++++++ .../blenderbim/bim/module/web/data.py | 9 ++++++-- src/blenderbim/blenderbim/tool/web.py | 1 - 7 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/data/webui/sioserver.py b/src/blenderbim/blenderbim/bim/data/webui/sioserver.py index c7003576ff..a109fe5260 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/sioserver.py +++ b/src/blenderbim/blenderbim/bim/data/webui/sioserver.py @@ -85,7 +85,7 @@ class BlenderNamespace(socketio.AsyncNamespace): async def on_data(self, sid, data): print(f"Data from Blender client {sid}") # blender_messages[sid]["default_data"] = data - # await sio.emit("default_data", {"blenderId": sid, "data": data}, namespace="/web") + await sio.emit("default_data", {"blenderId": sid, "data": data}, namespace="/web") async def on_csv_data(self, sid, data): print(f"CSV data from Blender client {sid}") diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css b/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css index c7bf7c5bb0..d7336b8fbb 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css +++ b/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css @@ -59,6 +59,13 @@ nav ul li a.active { color: #3fb449; } +.warning { + color: #ff4c4c; + margin-bottom: 10px; + padding: 2px; + display: none; + /* Initially hidden */ +} .table-description { margin-bottom: 1rem; diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css b/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css index 290f42b430..bb14f4e8e4 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css +++ b/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css @@ -65,4 +65,12 @@ nav ul li a { nav ul li a:hover, nav ul li a.active { color: #3fb449; +} + +.warning { + color: #ff4c4c; + margin-bottom: 10px; + padding: 2px; + display: none; + /* Initially hidden */ } \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/js/gantt.js b/src/blenderbim/blenderbim/bim/data/webui/static/js/gantt.js index b15396bf9f..007e595517 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/js/gantt.js +++ b/src/blenderbim/blenderbim/bim/data/webui/static/js/gantt.js @@ -32,6 +32,7 @@ function connectSocket() { socket.on("blender_connect", handleBlenderConnect); socket.on("blender_disconnect", handleBlenderDisconnect); socket.on("gantt_data", handleGanttData); + socket.on("default_data", handleDefaultData); } // Function to handle 'blender_connect' event @@ -89,6 +90,13 @@ function handleGanttData(data) { } } +function handleDefaultData(data) { + const blenderId = data["blenderId"]; + const isDirty = data["data"]["is_dirty"]; + showWarning(blenderId, isDirty); + console.log(data); +} + // Function to add a new gantt with data and filename function addGanttElement(blenderId, tasks, workSched, filename) { const ganttContainer = $("
") @@ -101,6 +109,13 @@ function addGanttElement(blenderId, tasks, workSched, filename) { .addClass("no-print") .css("margin-bottom", "10px"); + const warning = $("
") + .attr("id", "warning-" + blenderId) + .html( + "⚠ Warning: This Gantt Chart may contain outdated data due to recent changes in Blender." + ) + .addClass("warning no-print"); + const workSchedDiv = $("
").attr("id", "workSched" + blenderId); const scheduleTable = $("
") @@ -148,6 +163,7 @@ function addGanttElement(blenderId, tasks, workSched, filename) { workSchedDiv.append(scheduleTable); ganttContainer.append(ganttTitle); + ganttContainer.append(warning); ganttContainer.append(workSchedDiv); ganttContainer.append(ganttInfoDiv); ganttContainer.append(ganttDiv); @@ -279,6 +295,7 @@ function updateGanttElement(blenderId, tasks, workSched, filename) { g.Draw(); $("#title-" + blenderId).text(filename); + $("#warning-" + blenderId).css("display", "none"); } // Function to remove gantt element @@ -286,6 +303,10 @@ function removeGanttElement(blenderId) { $("#container-" + blenderId).remove(); } +function showWarning(blenderId, isDirty) { + $("#warning-" + blenderId).css("display", "block"); +} + // Utility function to create a tooltip for the gantt chars function generateTooltip(task) { var dataObject = task.getDataObject(); diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js b/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js index 907c5a3d08..2cc94b2f80 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js +++ b/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js @@ -18,6 +18,7 @@ function connectSocket() { socket.on("blender_connect", handleBlenderConnect); socket.on("blender_disconnect", handleBlenderDisconnect); socket.on("csv_data", handleCsvData); + socket.on("default_data", handleDefaultData); } // Function to handle 'blender_connect' event @@ -65,6 +66,13 @@ function handleCsvData(data) { } } +function handleDefaultData(data) { + const blenderId = data["blenderId"]; + const isDirty = data["data"]["is_dirty"]; + showWarning(blenderId, isDirty); + console.log(data); +} + // Function to add a new table with data and filename function addTableElement(blenderId, csvData, filename) { // store headers of the csv data @@ -82,11 +90,19 @@ function addTableElement(blenderId, csvData, filename) { .text(filename) .css("margin-bottom", "10px"); + const warning = $("
") + .attr("id", "warning-" + blenderId) + .html( + "⚠ Warning: This table may contain outdated data due to recent changes in Blender." + ) + .addClass("warning"); + const tableDiv = $("
") .addClass("csv-table") .attr("id", "table-" + blenderId); tableContainer.append(tableTitle); + tableContainer.append(warning); tableContainer.append(tableDiv); $("#container").append(tableContainer); @@ -199,6 +215,7 @@ function updateTableElement(blenderId, csvData, filename) { connectedClients[blenderId].headers = newHeaders; } $("#title-" + blenderId).text(filename); + $("#warning-" + blenderId).css("display", "none"); } } @@ -207,6 +224,10 @@ function removeTableElement(blenderId) { $("#container-" + blenderId).remove(); } +function showWarning(blenderId, isDirty) { + $("#warning-" + blenderId).css("display", "block"); +} + // Utility function to compare two csv header function compareHeaders(headers1, headers2) { if (headers1.length !== headers2.length) { diff --git a/src/blenderbim/blenderbim/bim/module/web/data.py b/src/blenderbim/blenderbim/bim/module/web/data.py index b6966d07bd..298256d8bb 100644 --- a/src/blenderbim/blenderbim/bim/module/web/data.py +++ b/src/blenderbim/blenderbim/bim/module/web/data.py @@ -32,11 +32,16 @@ class WebData: @classmethod def load(cls): cls.data = { - "ifc_file": cls.ifc_file_name(), + "ifc_file": cls.get_ifc_file_name(), + "is_dirty": cls.get_is_dirty(), } cls.is_loaded = True @classmethod - def ifc_file_name(cls): + def get_ifc_file_name(cls): filename = os.path.basename(bpy.context.scene.BIMProperties.ifc_file) return filename + + @classmethod + def get_is_dirty(cls): + return bpy.context.scene.BIMProperties.is_dirty diff --git a/src/blenderbim/blenderbim/tool/web.py b/src/blenderbim/blenderbim/tool/web.py index 1d62be294b..2b53516ec2 100644 --- a/src/blenderbim/blenderbim/tool/web.py +++ b/src/blenderbim/blenderbim/tool/web.py @@ -105,7 +105,6 @@ class Web(blenderbim.core.tool.Web): ws_thread.run_coro(cls.sio_connect(ws_url)) cls.set_is_connected(True) bpy.app.timers.register(cls.check_operator_queue) - cls.send_webui_data() @classmethod def disconnect_websocket_server(cls): From 386caab840291ecab50ec0ec334ef814756541a6 Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Thu, 18 Jul 2024 23:00:52 +0300 Subject: [PATCH 27/42] move intial opening of browser to server on startup event as a band aid fix to handle race condition between starting server and opening of web browser --- src/blenderbim/blenderbim/bim/data/webui/sioserver.py | 6 ++++++ src/blenderbim/blenderbim/tool/web.py | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/data/webui/sioserver.py b/src/blenderbim/blenderbim/bim/data/webui/sioserver.py index a109fe5260..b848a230cf 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/sioserver.py +++ b/src/blenderbim/blenderbim/bim/data/webui/sioserver.py @@ -1,5 +1,6 @@ import sys import os +import webbrowser blenderbim_path = os.environ.get("blenderbim_path") if blenderbim_path: @@ -119,10 +120,15 @@ async def gantt(request): return web.Response(text=html_content, content_type="text/html") +async def open_web_browser(app): + webbrowser.open(f"http://127.0.0.1:{sio_port}/") + + app.router.add_get("/", index) app.router.add_get("/gantt", gantt) app.router.add_static("/jsgantt/", path="../gantt", name="jsgantt") app.router.add_static("/static/", path="./static", name="static") +app.on_startup.append(open_web_browser) def main(): diff --git a/src/blenderbim/blenderbim/tool/web.py b/src/blenderbim/blenderbim/tool/web.py index 2b53516ec2..b4b2ffb7ab 100644 --- a/src/blenderbim/blenderbim/tool/web.py +++ b/src/blenderbim/blenderbim/tool/web.py @@ -84,7 +84,10 @@ class Web(blenderbim.core.tool.Web): ws_process = subprocess.Popen( [sys.executable, ws_path, "--p", str(port), "--host", "127.0.0.1"], cwd=webui_path, env=env ) - cls.open_web_browser(port) + # moved intial opening of web browser to server on startup event + # to handle race condition between starting server and openning browser + # TODO: a better way to handle race condition + # cls.open_web_browser(port) cls.set_is_running(True) @classmethod From 61dfb42ceed3cace5c54d7cdae0dd1aff4265b5a Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Thu, 18 Jul 2024 23:07:05 +0300 Subject: [PATCH 28/42] edit warning text color --- src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css | 2 +- src/blenderbim/blenderbim/bim/data/webui/static/css/index.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css b/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css index d7336b8fbb..34431a5d49 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css +++ b/src/blenderbim/blenderbim/bim/data/webui/static/css/gantt.css @@ -60,7 +60,7 @@ nav ul li a.active { } .warning { - color: #ff4c4c; + color: #FFDB8F; margin-bottom: 10px; padding: 2px; display: none; diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css b/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css index bb14f4e8e4..4efd5b95bb 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css +++ b/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css @@ -68,7 +68,7 @@ nav ul li a.active { } .warning { - color: #ff4c4c; + color: #FFDB8F; margin-bottom: 10px; padding: 2px; display: none; From 6b4c695942e32fd510ba45fda5ebbdbf3c1cd02e Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Fri, 19 Jul 2024 15:18:58 +0300 Subject: [PATCH 29/42] add writing/removing webserver pid to a json file on starting and killing the webserver subprocess --- src/blenderbim/blenderbim/tool/web.py | 32 +++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/blenderbim/blenderbim/tool/web.py b/src/blenderbim/blenderbim/tool/web.py index b4b2ffb7ab..caceecc78f 100644 --- a/src/blenderbim/blenderbim/tool/web.py +++ b/src/blenderbim/blenderbim/tool/web.py @@ -32,6 +32,7 @@ import asyncio import socketio import threading import queue +import json from time import sleep sio = None @@ -43,7 +44,6 @@ IFC_TASK_ATTRIBUTE_MAP = { "pStart": "ScheduleStart", "pEnd": "ScheduleFinish", "pName": "Name", - "pRes": "", } @@ -84,10 +84,24 @@ class Web(blenderbim.core.tool.Web): ws_process = subprocess.Popen( [sys.executable, ws_path, "--p", str(port), "--host", "127.0.0.1"], cwd=webui_path, env=env ) + # moved intial opening of web browser to server on startup event # to handle race condition between starting server and openning browser - # TODO: a better way to handle race condition # cls.open_web_browser(port) + + pid_file = os.path.join(webui_path, "running_pid.json") + + if os.path.exists(pid_file): + with open(pid_file, "r") as f: + pids = json.load(f) + else: + pids = {} + + pids[str(ws_process.pid)] = port + + with open(pid_file, "w") as f: + json.dump(pids, f, indent=4) + cls.set_is_running(True) @classmethod @@ -129,14 +143,24 @@ class Web(blenderbim.core.tool.Web): if bpy.context.scene.WebProperties.is_connected: cls.disconnect_websocket_server() - sleep(0.5) + # sleep(0.5) + webui_path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "webui") + pid_file = os.path.join(webui_path, "running_pid.json") + with open(pid_file, "r") as f: + pids = json.load(f) + + if str(ws_process.pid) in pids: + del pids[str(ws_process.pid)] + + # Write the updated PIDs back to the file + with open(pid_file, "w") as f: + json.dump(pids, f, indent=4) ws_process.terminate() ws_process.wait() ws_process = None cls.set_is_running(False) - print("Websocket server terminated successfully") @classmethod From ad17a610eb3a2c7d57485429de887bc249e05ea5 Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Fri, 19 Jul 2024 22:40:49 +0300 Subject: [PATCH 30/42] edit css for csv tables to have two themes --- .../bim/data/webui/static/css/index.css | 91 ++++++++++++++----- .../bim/data/webui/templates/index.html | 2 +- 2 files changed, 67 insertions(+), 26 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css b/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css index 4efd5b95bb..0a1e41737b 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css +++ b/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css @@ -1,27 +1,57 @@ :root { - color-scheme: dark; + --font-family: Arial, sans-serif; + --margin-small: 0.625rem; + --margin-medium: 1.25rem; + --margin-large: 2.5rem; + --padding-small: 0.125rem; + --padding-medium: 1rem; + --font-size-large: 1.2rem; +} + +:root.dark { + --bg-color: #252525; + --text-color: #e0e0e0; + --nav-bg-color: #121212; + --nav-border-color: #25682a; + --nav-link-color: #fff; + --nav-link-hover-color: #3fb449; + --warning-color: #FFDB8F; +} + +:root.light { + --bg-color: #ffffff; + --text-color: #000000; + --nav-bg-color: #f8f8f8; + --nav-border-color: #cccccc; + --nav-link-color: #000000; + --nav-link-hover-color: #38a63d; + --warning-color: #FF4500; +} + +html { + font-size: var(--base-font-size); } body { - background-color: #252525; - color: #e0e0e0; + background-color: var(--bg-color); + color: var(--text-color); margin: 0; - font-family: Arial, sans-serif; + font-family: var(--font-family); } #container { - margin-top: 20px; - margin-left: 10px; - margin-right: 10px; - margin-bottom: 20px + margin-top: var(--margin-medium); + margin-left: var(--margin-small); + margin-right: var(--margin-small); + margin-bottom: var(--margin-medium); } .table-container { - margin-bottom: 40px; + margin-bottom: var(--margin-large); } .csv-table { - margin-top: 10px; + margin-top: var(--margin-small); } h3 { @@ -29,48 +59,59 @@ h3 { } nav { - background-color: #121212; - padding: 1em 0; + background-color: var(--nav-bg-color); + padding: var(--padding-medium) 0; display: flex; align-items: center; position: relative; - border-bottom: 2px solid #25682a; + border-bottom: 2px solid var(--nav-border-color); } nav .logo { - margin-left: 40px; - height: 40px; - /* Adjust height as needed */ + margin-left: var(--margin-large); + height: 2.5rem; } nav ul { list-style-type: none; margin: 0; - margin-left: 1px; + margin-left: 0.0625rem; display: flex; flex-grow: 1; justify-content: center; } nav ul li { - margin-right: 50px; + margin-right: 3.125rem; } nav ul li a { text-decoration: none; - color: #fff; - font-size: 1.2em; + color: var(--nav-link-color); + font-size: var(--font-size-large); } nav ul li a:hover, nav ul li a.active { - color: #3fb449; + color: var(--nav-link-hover-color); } .warning { - color: #FFDB8F; - margin-bottom: 10px; - padding: 2px; + color: var(--warning-color); + margin-bottom: var(--margin-small); + padding: var(--padding-small); display: none; - /* Initially hidden */ +} + +/* ------------ Overwriting Tabulator CSS rules ------------ */ + +:root.light .tabulator-header, +:root.light .tabulator .tabulator-header .tabulator-col { + background: var(--nav-bg-color) !important; + color: var(--text-color); +} + +:root.light .tabulator { + border-top: 1px solid #222; + border-bottom: 2px solid #222; } \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/data/webui/templates/index.html b/src/blenderbim/blenderbim/bim/data/webui/templates/index.html index e726facd0e..88a4306cda 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/templates/index.html +++ b/src/blenderbim/blenderbim/bim/data/webui/templates/index.html @@ -1,5 +1,5 @@ - + From c852e624e90eb9d96b507236d633ec0578b56962 Mon Sep 17 00:00:00 2001 From: Ziad-I <68874104+Ziad-I@users.noreply.github.com> Date: Sat, 20 Jul 2024 15:35:06 +0300 Subject: [PATCH 31/42] add theme switching for tables page --- .../bim/data/webui/static/css/index.css | 17 +++++++++- .../bim/data/webui/static/js/index.js | 34 +++++++++++++++++++ .../bim/data/webui/templates/index.html | 8 +++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css b/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css index 0a1e41737b..7a480b42c8 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css +++ b/src/blenderbim/blenderbim/bim/data/webui/static/css/index.css @@ -6,9 +6,11 @@ --padding-small: 0.125rem; --padding-medium: 1rem; --font-size-large: 1.2rem; + --logo-height: 2.5rem; } :root.dark { + color-scheme: dark; --bg-color: #252525; --text-color: #e0e0e0; --nav-bg-color: #121212; @@ -19,6 +21,7 @@ } :root.light { + color-scheme: light; --bg-color: #ffffff; --text-color: #000000; --nav-bg-color: #f8f8f8; @@ -69,7 +72,7 @@ nav { nav .logo { margin-left: var(--margin-large); - height: 2.5rem; + height: var(--logo-height); } nav ul { @@ -103,6 +106,18 @@ nav ul li a.active { display: none; } +#toggle-theme { + border: none; + background: none; + cursor: pointer; + font-size: var(--font-size-large); + margin-right: var(--margin-medium); +} + +#toggle-theme:focus { + outline: none; +} + /* ------------ Overwriting Tabulator CSS rules ------------ */ :root.light .tabulator-header, diff --git a/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js b/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js index 2cc94b2f80..0d4db42480 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js +++ b/src/blenderbim/blenderbim/bim/data/webui/static/js/index.js @@ -5,6 +5,12 @@ let socket; // Document ready function $(document).ready(function () { + var systemTheme = window.matchMedia("(prefers-color-scheme: light)").matches + ? "light" + : "dark"; + var theme = localStorage.getItem("theme") || systemTheme; + setTheme(theme); + connectSocket(); }); @@ -240,3 +246,31 @@ function compareHeaders(headers1, headers2) { } return true; } + +function setTheme(theme) { + var stylesheet = $("#tabulator-stylesheet"); + if (theme === "light") { + stylesheet.attr( + "href", + "https://unpkg.com/tabulator-tables/dist/css/tabulator_site.min.css" + ); + $("html").removeClass("dark").addClass("light"); + $("#toggle-theme").html(''); + } else { + stylesheet.attr( + "href", + "https://unpkg.com/tabulator-tables/dist/css/tabulator_site_dark.min.css" + ); + $("html").removeClass("light").addClass("dark"); + $("#toggle-theme").html(''); + } + localStorage.setItem("theme", theme); +} + +function toggleTheme() { + if ($("html").hasClass("dark")) { + setTheme("light"); + } else { + setTheme("dark"); + } +} diff --git a/src/blenderbim/blenderbim/bim/data/webui/templates/index.html b/src/blenderbim/blenderbim/bim/data/webui/templates/index.html index 88a4306cda..e948b4c4be 100644 --- a/src/blenderbim/blenderbim/bim/data/webui/templates/index.html +++ b/src/blenderbim/blenderbim/bim/data/webui/templates/index.html @@ -7,8 +7,13 @@ +