diff --git a/.gersemirc b/.gersemirc index 4d74cb215a..44ff8cc11c 100644 --- a/.gersemirc +++ b/.gersemirc @@ -1,7 +1,8 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/0.24.0/gersemi/configuration.schema.json -# Needed for gersemi to detect custom functions and macros. -definitions: ["./cmake"] +# Gersemi doesn't support autodetection of macros/functions from other files or from the current one +# and requires to explicitly list directories/cmake files that define them. +definitions: ["./cmake", "./src"] disable_formatting: false extensions: [] indent: 4 diff --git a/.github/workflows/build_osx.yml b/.github/workflows/build_osx.yml index 056cf13763..0e15cdc830 100644 --- a/.github/workflows/build_osx.yml +++ b/.github/workflows/build_osx.yml @@ -40,6 +40,8 @@ jobs: # preinstalled: xz, cmake brew install git bison autoconf automake libffi findutils echo "$(brew --prefix findutils)/libexec/gnubin" >> $GITHUB_PATH + # Mac is using bison 2.5 by default, but we need 3.5+ for swig. + echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH - name: Install aws cli run: | @@ -47,11 +49,11 @@ jobs: - name: Unpack Dependencies run: | - install_root=$(find ./build -maxdepth 4 -type d -name install 2>/dev/null | head -n 1 || true) - [ -n "$install_root" ] && find "$install_root" -type f -name 'cache-*.tar.gz' -maxdepth 1 -exec tar -xzf {} -C "$install_root" \; || true + cd build + python ../nix/cache_dependencies.py unpack - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 + uses: hendrikmuhs/ccache-action@v1.2.20 with: key: mac-${{ matrix.arch }} @@ -93,9 +95,7 @@ jobs: - name: Pack Dependencies run: | cd build - for install_dir in $(find $(find . -maxdepth 4 -name install) -mindepth 1 -maxdepth 1 -type d); do - test -f $(dirname "$install_dir")/cache-$(basename "$install_dir").tar.gz || tar -czf $(dirname "$install_dir")/cache-$(basename "$install_dir").tar.gz -C $(dirname "$install_dir") $(basename "$install_dir"); - done + python ../nix/cache_dependencies.py pack - name: Commit and Push Changes to Build Repository run: | diff --git a/.github/workflows/build_pyodide.yml b/.github/workflows/build_pyodide.yml index 744bd9e772..cd162cd9ea 100644 --- a/.github/workflows/build_pyodide.yml +++ b/.github/workflows/build_pyodide.yml @@ -26,10 +26,10 @@ jobs: - name: Unpack Dependencies run: | cd ifcopenshell_build - python ../IfcOpenShell/pyodide/cache_dependencies.py unpack + python ../IfcOpenShell/nix/cache_dependencies.py unpack - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 + uses: hendrikmuhs/ccache-action@v1.2.20 with: key: ubuntu-22.04-${{ runner.arch }} @@ -65,7 +65,7 @@ jobs: - name: Pack Dependencies run: | cd ifcopenshell_build - python ../IfcOpenShell/pyodide/cache_dependencies.py pack + python ../IfcOpenShell/nix/cache_dependencies.py pack - name: Commit and Push Changes to Build Repository run: | diff --git a/.github/workflows/build_rocky.yml b/.github/workflows/build_rocky.yml index 662aa04f26..3fcd759877 100644 --- a/.github/workflows/build_rocky.yml +++ b/.github/workflows/build_rocky.yml @@ -6,13 +6,13 @@ on: jobs: build_ifcopenshell: runs-on: ubuntu-22.04 - container: rockylinux:8 + container: rockylinux:9 steps: - name: Install Dependencies run: | - yum update -y - yum install -y gcc gcc-c++ git autoconf automake bison make zip cmake python3 \ + dnf update -y + dnf install -y gcc gcc-c++ git autoconf automake bison make zip cmake python3 python3-pip \ bzip2 patch mesa-libGL-devel libffi-devel fontconfig-devel \ sqlite-devel bzip2-devel zlib-devel openssl-devel xz-devel \ readline-devel ncurses-devel libffi-devel libuuid-devel git-lfs \ @@ -38,20 +38,19 @@ jobs: with: repository: IfcOpenShell/build-outputs path: ./build - ref: rockylinux8-x64 + ref: rockylinux9-x64 lfs: true token: ${{ secrets.BUILD_REPO_TOKEN }} - name: Unpack Dependencies run: | - install_root=$(find ./build -maxdepth 4 -type d -name install 2>/dev/null | head -n 1 || true) - [ -n "$install_root" ] && find "$install_root" -type f -name 'cache-*.tar.gz' -maxdepth 1 -exec tar -xzf {} -C "$install_root" \; || true + cd build + python3 ../nix/cache_dependencies.py unpack - name: ccache - # TODO: Use tag after 1.2.20 releases. - uses: hendrikmuhs/ccache-action@5ebbd400eff9e74630f759d94ddd7b6c26299639 + uses: hendrikmuhs/ccache-action@v1.2.20 with: - key: ubuntu-22.04-${{ runner.arch }}-rockylinux8 + key: ubuntu-22.04-${{ runner.arch }}-rockylinux9 - name: Run Build Script shell: bash @@ -72,9 +71,7 @@ jobs: - name: Pack Dependencies run: | cd build - for install_dir in $(find $(find . -maxdepth 4 -name install) -mindepth 1 -maxdepth 1 -type d); do - test -f $(dirname "$install_dir")/cache-$(basename "$install_dir").tar.gz || tar -czf $(dirname "$install_dir")/cache-$(basename "$install_dir").tar.gz -C $(dirname "$install_dir") $(basename "$install_dir"); - done + python3 ../nix/cache_dependencies.py pack - name: Commit and Push Changes to Build Repository run: | diff --git a/.github/workflows/build_rocky_arm.yml b/.github/workflows/build_rocky_arm.yml index 445f49658a..cced443ad8 100644 --- a/.github/workflows/build_rocky_arm.yml +++ b/.github/workflows/build_rocky_arm.yml @@ -6,13 +6,13 @@ on: jobs: build_ifcopenshell: runs-on: ubuntu-22.04-arm - container: arm64v8/rockylinux:8 + container: arm64v8/rockylinux:9 steps: - name: Install Dependencies run: | - yum update -y - yum install -y gcc gcc-c++ git autoconf automake bison make zip cmake python3 \ + dnf update -y + dnf install -y gcc gcc-c++ git autoconf automake bison make zip cmake python3 python3-pip \ bzip2 patch mesa-libGL-devel libffi-devel fontconfig-devel \ sqlite-devel bzip2-devel zlib-devel openssl-devel xz-devel \ readline-devel ncurses-devel libffi-devel libuuid-devel git-lfs \ @@ -38,20 +38,19 @@ jobs: with: repository: IfcOpenShell/build-outputs path: ./build - ref: rockylinux8-arm64 + ref: rockylinux9-arm64 lfs: true token: ${{ secrets.BUILD_REPO_TOKEN }} - name: Unpack Dependencies run: | - install_root=$(find ./build -maxdepth 4 -type d -name install 2>/dev/null | head -n 1 || true) - [ -n "$install_root" ] && find "$install_root" -type f -name 'cache-*.tar.gz' -maxdepth 1 -exec tar -xzf {} -C "$install_root" \; || true + cd build + python3 ../nix/cache_dependencies.py unpack - name: ccache - # TODO: Use tag after 1.2.20 releases. - uses: hendrikmuhs/ccache-action@5ebbd400eff9e74630f759d94ddd7b6c26299639 + uses: hendrikmuhs/ccache-action@v1.2.20 with: - key: ubuntu-22.04-${{ runner.arch }}-rockylinux8 + key: ubuntu-22.04-${{ runner.arch }}-rockylinux9 - name: Run Build Script shell: bash @@ -72,9 +71,7 @@ jobs: - name: Pack Dependencies run: | cd build - for install_dir in $(find $(find . -maxdepth 4 -name install) -mindepth 1 -maxdepth 1 -type d); do - test -f $(dirname "$install_dir")/cache-$(basename "$install_dir").tar.gz || tar -czf $(dirname "$install_dir")/cache-$(basename "$install_dir").tar.gz -C $(dirname "$install_dir") $(basename "$install_dir"); - done + python3 ../nix/cache_dependencies.py pack - name: Commit and Push Changes to Build Repository run: | diff --git a/.github/workflows/build_win.yml b/.github/workflows/build_win.yml index ab9d7b6f80..783084c1ae 100644 --- a/.github/workflows/build_win.yml +++ b/.github/workflows/build_win.yml @@ -37,8 +37,7 @@ jobs: } - name: ccache - # TODO: Use tag after 1.2.20 releases. - uses: hendrikmuhs/ccache-action@5ebbd400eff9e74630f759d94ddd7b6c26299639 + uses: hendrikmuhs/ccache-action@v1.2.20 with: key: win-${{ matrix.arch }} # Windows ccache needs ~1GB diff --git a/.github/workflows/ci-bonsai-daily.yml b/.github/workflows/ci-bonsai-daily.yml index 3b52198f3a..ddfa64a47a 100644 --- a/.github/workflows/ci-bonsai-daily.yml +++ b/.github/workflows/ci-bonsai-daily.yml @@ -24,9 +24,15 @@ jobs: runs-on: ubuntu-latest if: | github.repository == 'IfcOpenShell/IfcOpenShell' + outputs: + timestamp: ${{ steps.timestamp.outputs.timestamp }} steps: - - name: Set env - run: echo ok go + - name: Get current timestamp + id: timestamp + # Include hours and minutes to release tag + # to avoid possibility of unstable repo's index.json + # pointing to the new file when index.json itself wasn't yet updated. + run: echo "timestamp=$(date +'%y%m%d%H%M')" >> $GITHUB_OUTPUT build: needs: activate @@ -67,12 +73,6 @@ jobs: - name: Get current version id: version run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT - - name: Get current date - id: date - # Include hours and minutes to release tag - # to avoid possibility of unstable repo's index.json - # pointing to the new file when index.json itself wasn't yet updated. - run: echo "date=$(date +'%y%m%d%H%M')" >> $GITHUB_OUTPUT - name: Compile run: | cd src/bonsai && make dist PLATFORM=${{ matrix.config.short_name }} PYVERSION=${{ matrix.pyver }} @@ -88,8 +88,8 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ${{ steps.find_zip.outputs.filepath }} asset_name: ${{ steps.find_zip.outputs.filename }} - release_name: "bonsai-${{steps.version.outputs.version}}-alpha${{steps.date.outputs.date}} (unstable)" - tag: "bonsai-${{steps.version.outputs.version}}-alpha${{steps.date.outputs.date}}" + release_name: "bonsai-${{steps.version.outputs.version}}-alpha${{ needs.activate.outputs.timestamp }} (unstable)" + tag: "bonsai-${{steps.version.outputs.version}}-alpha${{ needs.activate.outputs.timestamp }}" overwrite: true body: "See README in https://github.com/IfcOpenShell/bonsai_unstable_repo/ on how to setup autoupdates for daily Bonsai builds." diff --git a/.github/workflows/ci-ifcopenshell-docker.yml b/.github/workflows/ci-ifcopenshell-docker.yml index d5691ecfce..e6668490c5 100644 --- a/.github/workflows/ci-ifcopenshell-docker.yml +++ b/.github/workflows/ci-ifcopenshell-docker.yml @@ -35,7 +35,7 @@ jobs: - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 + uses: hendrikmuhs/ccache-action@v1.2.20 - name: Build ifcopenshell diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65031e83d9..896a179758 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,10 +79,7 @@ jobs: libhdf5-dev libcgal-dev libeigen3-dev - name: ccache - # TODO: temporarily pointing to 1.2.19 to get notified by dependabot when 1.2.20 is released - # to update hardcoded references to commits in some other workflows. - # Then we can switch back to 1.2 in all actions. - uses: hendrikmuhs/ccache-action@v1.2.19 + uses: hendrikmuhs/ccache-action@v1.2.20 with: key: ubuntu-22.04-${{ runner.arch }} diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9e88026ac7..bf48427774 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -258,10 +258,10 @@ if(WITH_ROCKSDB) set(ROCKSDB_LIBRARIES "IFCOPENSHELL_RocksDB") target_compile_definitions(IFCOPENSHELL_RocksDB INTERFACE IFOPSH_WITH_ROCKSDB) set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_ROCKSDB) - target_link_libraries( - IFCOPENSHELL_RocksDB - INTERFACE $,RocksDB::rocksdb-shared,RocksDB::rocksdb> - ) + # Shared binaries for `rocksdb` only support limited API (only `c.h`), but we use `db.h` API. + # So rocksdb supported only as a static library. + # See https://github.com/facebook/rocksdb/issues/981. + target_link_libraries(IFCOPENSHELL_RocksDB INTERFACE RocksDB::rocksdb) if(WITH_ZSTD) # @todo do we actually need the zstd include dir or rather just pass @@ -368,12 +368,20 @@ if(ENABLE_BUILD_OPTIMIZATIONS) # Linker # /OPT:REF enables also /OPT:ICF and disables INCREMENTAL - set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG /OPT:REF") - + set(LINKER_FLAGS_RELEASE "/LTCG /OPT:REF") # /OPT:NOICF is recommended when /DEBUG is used (http://msdn.microsoft.com/en-us/library/xe4t6fc1.aspx) - set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:NOICF") - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG /OPT:REF") - set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:NOICF") + set(LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /OPT:NOICF") + + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} ${LINKER_FLAGS_RELEASE}") + set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO + "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} ${LINKER_FLAGS_RELWITHDEBINFO}" + ) + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${LINKER_FLAGS_RELEASE}") + set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${LINKER_FLAGS_RELWITHDEBINFO}") + set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} ${LINKER_FLAGS_RELEASE}") + set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO + "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} ${LINKER_FLAGS_RELWITHDEBINFO}" + ) else() # GCC-like: Release should use O3 but RelWithDebInfo 02 so enforce 03. Anything other useful that could be added here? set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") diff --git a/cmake/FindOpenCASCADE.cmake b/cmake/FindOpenCASCADE.cmake index f78ee33b99..aac5f0521e 100644 --- a/cmake/FindOpenCASCADE.cmake +++ b/cmake/FindOpenCASCADE.cmake @@ -43,6 +43,17 @@ if(NOT OCC_INCLUDE_DIR AND NOT OCC_LIBRARY_DIR) set_target_properties(TKernel PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${OpenCASCADE_INCLUDE_DIR}") endif() + if( + OpenCASCADE_VERSION VERSION_LESS "7.9.0" + AND CMAKE_VERSION GREATER_EQUAL "3.24" + AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + ) + # Before 7.9.0 targets in OCCT cmake configs are not linked to each other + # leading to missing symbols on Unix. Link them as a single group as a workaround. + # Only needed for gcc, because other compilers (e.g. Apple Clang, MSVC) do rescan automatically. + set(OpenCASCADE_LIBRARIES "$") + endif() + if(OpenCASCADE_VERSION VERSION_LESS "7.9.0" AND WIN32) # Bug in OCCT cmake configs < 7.9.0 - missing linked library. list(APPEND OpenCASCADE_LIBRARIES WSOCK32.lib) diff --git a/nix/build-all.py b/nix/build-all.py index 2a4318dc35..46b7b5c30c 100644 --- a/nix/build-all.py +++ b/nix/build-all.py @@ -75,27 +75,30 @@ Used environment variables: # # # for python37 to install correctly additionally: # # * libffi(-dev[el]) # -# for Python build we also needs ssl # +# for Python build we also needs ssl and zlib # # (since we do `pip install numpy` at the end) # # * libssl-dev # # # # on debian 7.8 these can be obtained with: # # $ apt-get install git gcc g++ autoconf bison bzip2 cmake # # mesa-common-dev libffi-dev libfontconfig1-dev # -# libssl-dev xz # +# libssl-dev xz zlib1g-dev # # # # on ubuntu 14.04: # # $ apt-get install git gcc g++ autoconf bison make cmake # # mesa-common-dev libffi-dev libfontconfig1-dev # -# libssl-dev xz-utils # +# libssl-dev xz-utils zlib1g-dev # # # # on OS X El Capitan with homebrew: # # $ brew install git bison autoconf automake libffi cmake # +# $ # `bison` shipped with Mac is too old for swig build, # +# $ # so we use `brew`. # +# $ export PATH=$(brew --prefix bison)/bin:$PATH # # # # on RHEL-related distros: # -# $ yum install git gcc gcc-c++ autoconf bison make cmake # +# $ dnf install git gcc gcc-c++ autoconf bison make cmake # # mesa-libGL-devel libffi-devel fontconfig-devel bzip2 # -# automake patch byacc xz # +# automake patch byacc xz zlib-devel openssl-devel # """ @@ -147,9 +150,8 @@ OCCT_VERSION = "7.8.1" BOOST_VERSION = "1.86.0" EIGEN_VERSION = "3.4.0" PCRE_VERSION = "8.41" -PCRE2_VERSION = "10.32" LIBXML2_VERSION = "2.13.8" -SWIG_VERSION = "4.1.0" +SWIG_VERSION = "4.2.1" OPENCOLLADA_VERSION = "v1.6.68" HDF5_VERSION = "1.13.1" @@ -246,15 +248,8 @@ if WASM: # https://github.com/pyodide/pyodide-build/pull/249 WASM_CMAKE_IS_USING_INIT_VARS = get_pyodide_build_version() >= (99, 0, 0) - # pyodide provide empty `CXXFLAGS`, leading to issues using C++ files compiled with `-fexceptions` - # which is used by OCCT. - # https://github.com/pyodide/pyodide-build/issues/251 - side_module_cxx_flags = os.environ.get("SIDE_MODULE_CXXFLAGS", "") - if side_module_cxx_flags.strip(): - print("SIDE_MODULE_CXXFLAGS are already passed from pyodide build ('{side_module_cxx_flags}').") - print("Maybe it's time to stop overriding them in the script?") - - os.environ["SIDE_MODULE_CXXFLAGS"] = os.environ["SIDE_MODULE_CFLAGS"] + # 0.31 is required for SIDE_MODULE_CXXFLAGS to be provided. + assert get_pyodide_build_version() >= (0, 31) # Set defaults for missing empty environment variables @@ -294,6 +289,7 @@ DEPS_DIR = os.getenv("DEPS_DIR", DEFAULT_DEPS_DIR) if not os.path.exists(DEPS_DIR): os.makedirs(DEPS_DIR) +INSTALL_DIR = Path(DEPS_DIR) / "install" BUILD_CFG = os.getenv("BUILD_CFG", "RelWithDebInfo") @@ -319,24 +315,18 @@ cecho(f"* Build Directory = {BUILD_DIR}", MAGENTA) cecho(f"* Dependency Directory = {DEPS_DIR}", MAGENTA) cecho(f" - The directory where {PROJECT_NAME} dependencies are installed.") cecho(f"* Build Config Type = {BUILD_CFG}", MAGENTA) -cecho( - """ - The used build configuration type for the dependencies. - Defaults to RelWithDebInfo if not specified.""" -) +cecho(""" - The used build configuration type for the dependencies. + Defaults to RelWithDebInfo if not specified.""") if BUILD_CFG == "MinSizeRel": cecho(" WARNING: MinSizeRel build can suffer from a significant performance loss.", RED) cecho(f"* IFCOS_NUM_BUILD_PROCS = {IFCOS_NUM_BUILD_PROCS}", MAGENTA) -cecho( - """ - How many compiler processes may be run in parallel. -""" -) +cecho(""" - How many compiler processes may be run in parallel. +""") cecho(f" * IFCOS_SCHEMAS = '{os.environ.get('IFCOS_SCHEMAS')}'", MAGENTA) -cecho( - """ - IFC Schemas to compile. If not provided, fallback to default provided in cmake. -""" -) +cecho(""" - IFC Schemas to compile. If not provided, fallback to default provided in cmake. +""") dependency_tree: "dict[str, tuple[str, ...]]" = { "IfcParse": ("boost", "libxml2", "hdf5", "rocksdb"), @@ -345,13 +335,12 @@ dependency_tree: "dict[str, tuple[str, ...]]" = { "OpenCOLLADA": ("libxml2", "pcre"), "IfcGeomServer": ("IfcGeom",), "IfcOpenShell-Python": ("python", "swig", "IfcGeom"), - "swig": ("pcre2",), + "swig": (), "boost": (), "libxml2": (), "python": (), "occ": (), "pcre": (), - "pcre2": (), "json": (), "hdf5": (), "cgal": (), @@ -418,7 +407,6 @@ if WASM: "opencollada", "swig", "pcre", - "pcre2", "IfcGeom", "IfcConvert", "IfcGeomServer", @@ -433,13 +421,16 @@ print("Building:", *sorted(targets, key=lambda t: len(list(gather_dependencies(t # Check that required tools are in PATH yacc = "yacc" # Used during swig building process, installed with `bison` on Debian / `byacc` on Red Hat. +bison = "bison" + missing_commands: "list[str]" = [] -required_commands = [git, bunzip2, tar, cc, cplusplus, autoconf, automake, make, "patch", "cmake", yacc, xz] +required_commands = [git, bunzip2, tar, cc, cplusplus, autoconf, automake, make, "patch", "cmake", yacc, xz, bison] if "wasm" in flags: # Skip swig build for WASM. required_commands.append("swig") required_commands.append("pyodide") required_commands.remove(yacc) + required_commands.remove(bison) for cmd in required_commands: if shutil.which(cmd) is None: @@ -498,7 +489,7 @@ def run(cmds: "Sequence[str]", cwd: "Union[str, None]" = None, can_fail: bool = collector.append(line) pipe.close() - logger.debug(f"running command {' '.join(cmds)} in directory {cwd}") + logger.debug(f"running command `{' '.join(cmds)}` in directory '{cwd}'") stdout: list[str] = [] stderr: list[str] = [] @@ -544,14 +535,14 @@ BOOST_LOCATION = f"https://github.com/boostorg/boost/releases/download/boost-{BO # Helper functions -def run_autoconf(arg1: str, configure_args: "list[str]", cwd: str) -> None: +def run_autoconf(dependency_name: str, configure_args: "list[str]", cwd: str) -> None: configure_path = os.path.realpath(os.path.join(cwd, "..", "configure")) if not os.path.exists(configure_path): run( [bash, "./autogen.sh"], cwd=os.path.realpath(os.path.join(cwd, "..")) ) # only run autogen.sh in the directory it is located and use cwd to achieve that in order to not mess up things # Using `sh` over `bash` fixes issues with building swig - prefix = os.path.realpath(f"{DEPS_DIR}/install/{arg1}") + prefix = os.path.realpath(f"{DEPS_DIR}/install/{dependency_name}") wasm = [] if "wasm" in flags: @@ -930,20 +921,15 @@ if "pcre" in targets: restore_env("CC", OLD_CC) restore_env("CXX", OLD_CXX) -if "pcre2" in targets: - build_dependency( - name=f"pcre2-{PCRE2_VERSION}", - mode="autoconf", - build_tool_args=[DISABLE_FLAG], - download_url=f"https://downloads.sourceforge.net/project/pcre/pcre2/{PCRE2_VERSION}/", - download_name=f"pcre2-{PCRE2_VERSION}.tar.bz2", - ) - if "swig" in targets: + dependency_name = f"swig-{SWIG_VERSION}" build_dependency( - name=f"swig-{SWIG_VERSION}", - mode="autoconf", - build_tool_args=["--disable-ccache", f"--with-pcre2-prefix={DEPS_DIR}/install/pcre2-{PCRE2_VERSION}"], + name=dependency_name, + mode="cmake", + build_tool_args=[ + "-DWITH_PCRE=OFF", + f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/{dependency_name}", + ], download_url="https://github.com/swig/swig.git", download_name="swig", download_tool=download_tool_git, @@ -951,21 +937,18 @@ if "swig" in targets: ) if USE_OCCT and "occ" in targets: - patches = [] + occt_args: "list[str]" = [] + patches: "list[str]" = [] if OCCT_VERSION < "7.4": patches.append("./patches/occt/enable-exception-handling.patch") - if OCCT_VERSION == "7.7.1": + # Skip ExpToCasExe as we don't need it and it requires additional dependencies. + # Before 7.7.2 ExpToCasExe is part of DataExchange, DETools doesn't exist yet. + # Since we do need DataExchange (used for IgesSerializer), we use a patch to skip only ExpToCasExe. + if "7.7.2" > OCCT_VERSION >= "7.7": patches.append("./patches/occt/no_ExpToCasExe.patch") - - if OCCT_VERSION == "7.7.2": - patches.append("./patches/occt/no_ExpToCasExe_7_7_2.patch") - - if OCCT_VERSION == "7.8.1": - patches.append("./patches/occt/no_ExpToCasExe_7_8_1.patch") - - if OCCT_VERSION == "7.9.1": - patches.append("./patches/occt/no_ExpToCasExe_7_9_1.patch") + elif OCCT_VERSION >= "7.7.2": + occt_args.append("-DBUILD_MODULE_DETools=OFF") if "wasm" in flags: patches.append("./patches/occt/no_em_js.patch") @@ -986,6 +969,7 @@ if USE_OCCT and "occ" in targets: f"-DUSE_GLES2=OFF", f"-DCMAKE_POLICY_VERSION_MINIMUM=3.5", *MAC_CROSS_COMPILE_INTEL_ARGS, + *occt_args, ], download_url="https://github.com/Open-Cascade-SAS/OCCT", download_name="occt", @@ -1101,23 +1085,19 @@ if "python" in targets and not USE_CURRENT_PYTHON_VERSION and "wasm" not in flag PYTHON_CONFIGURE_ARGS.extend(["--with-universal-archs=intel-64", "--enable-universalsdk"]) for PYTHON_VERSION in PYTHON_VERSIONS: - try: - build_dependency( - f"python-{PYTHON_VERSION}", - "autoconf", - PYTHON_CONFIGURE_ARGS, - f"http://www.python.org/ftp/python/{PYTHON_VERSION}/", - f"Python-{PYTHON_VERSION}.tgz", - ) - except RuntimeError as e: - # Sometimes setting up modules such as pip/lzma can cause - # the python installer script to return a non zero exit - # code where actually the headers and dynamic libraries - # are installed correctly. This is all we need so we catch - # the exception and only reraise if a partially successful - # install is not detected. - if not os.path.exists(os.path.join(DEPS_DIR, "install", f"python-{PYTHON_VERSION}")): - raise e + # Don't fail silently on missing Python dependencies (e.g. openssl or zlib), + # because later ifcopenshell-python build will fail too but in a more confusing way. + build_dependency( + f"python-{PYTHON_VERSION}", + "autoconf", + PYTHON_CONFIGURE_ARGS, + f"http://www.python.org/ftp/python/{PYTHON_VERSION}/", + f"Python-{PYTHON_VERSION}.tgz", + ) + python_bin = INSTALL_DIR / f"python-{PYTHON_VERSION}" / "bin" / "python3" + # `_ssl` module is present -> we will be able to install `numpy` later + # to verify IfcOpenShell installation + run([str(python_bin), "-c", "import _ssl"]) if MAC_CROSS_COMPILE_INTEL: assert original_path @@ -1535,13 +1515,16 @@ if "IfcOpenShell-Python" in targets: ) # Copy setup.py where pyodide build system expects it. shutil.copy(REPO_PATH / "pyodide" / "setup.py", REPO_PATH) + # Empty pyproject so it's contents won't affect the resulting wheelthe the + # otherwise the wheel will use version and dependencies from toml, not setup.py. + (REPO_PATH / "pyproject.toml").write_text("") elif USE_CURRENT_PYTHON_VERSION: python_info = sysconfig.get_paths() compile_python_wrapper(platform.python_version(), python_info["include"], sys.executable) else: for python_version in PYTHON_VERSIONS: - python_path = Path(DEPS_DIR) / "install" / f"python-{python_version}" + python_path = INSTALL_DIR / f"python-{python_version}" module_dir = compile_python_wrapper(python_version, python_path=python_path) assert module_dir # Not sure why, but added after reading this in the logs diff --git a/pyodide/cache_dependencies.py b/nix/cache_dependencies.py similarity index 76% rename from pyodide/cache_dependencies.py rename to nix/cache_dependencies.py index 5800cba067..465d6002f1 100644 --- a/pyodide/cache_dependencies.py +++ b/nix/cache_dependencies.py @@ -5,9 +5,13 @@ This script is finding common install directory and either packs each folder into a tar.gz archive, if it wasn't packed before, or unpacks existing archives. +Expected to be executed from 'build' directory (e.g. that might contain 'Linux/x86_64/install'). + Usage: python cache_dependencies.py [pack|unpack] """ +import platform +import subprocess import sys import tarfile from pathlib import Path @@ -17,11 +21,20 @@ CACHE_PREFIX = "cache-" def get_install_dir() -> Path: - for data in Path.cwd().glob("*/*/install"): + if platform.system() == "Darwin": + pattern = "Darwin/*/*/install" + else: + pattern = "*/*/install" + for data in Path.cwd().glob(pattern): return data raise Exception("No install dir found") +def run(cmd: str) -> None: + print(f"Running command: `{cmd}`") + subprocess.check_call(cmd, shell=True) + + def pack_dependencies(install_dir: Path) -> None: # Process each install_dir for dependency_path in install_dir.iterdir(): @@ -32,8 +45,8 @@ def pack_dependencies(install_dir: Path) -> None: if tar_path.exists(): print(f"Skipping existing cache: '{tar_path}'") else: - with tarfile.open(tar_path, "w:gz") as tar: - tar.add(dependency_path, arcname=dependency_path.name) + # Python's `tarfile` is 10x slower than `tar` cli, so we use `tar`. + run(f'tar -czf "{tar_path}" -C "{install_dir}" "{dependency_name}"') print(f"Created cache: '{tar_path}'") diff --git a/nix/patches/occt/no_ExpToCasExe.patch b/nix/patches/occt/no_ExpToCasExe.patch index 6e10f2a9fb..2f99845925 100644 --- a/nix/patches/occt/no_ExpToCasExe.patch +++ b/nix/patches/occt/no_ExpToCasExe.patch @@ -1,13 +1,9 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index fd17283f77..6cecf9dad3 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -826,6 +826,8 @@ if (EMSCRIPTEN) - list (REMOVE_ITEM BUILD_TOOLKITS ExpToCasExe) - endif() - -+list (REMOVE_ITEM BUILD_TOOLKITS ExpToCasExe) -+ - # bison - if (BUILD_YACCLEX) - OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison") +--- a/adm/MODULES ++++ b/adm/MODULES +@@ -3,5 +3,5 @@ ModelingData TKG2d TKG3d TKGeomBase TKBRep + ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffset TKFeat TKMesh TKXMesh TKShHealing + Visualization TKService TKV3d TKOpenGl TKOpenGles TKMeshVS TKIVtk TKD3DHost + ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd TKTObj TKBinTObj TKXmlTObj TKVCAF +-DataExchange TKXDE TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh TKXDECascade TKExpress ExpToCasExe ++DataExchange TKXDE TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh TKXDECascade TKExpress + Draw TKDraw TKTopTest TKOpenGlTest TKOpenGlesTest TKD3DHostTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE diff --git a/nix/patches/occt/no_ExpToCasExe_7_7_2.patch b/nix/patches/occt/no_ExpToCasExe_7_7_2.patch deleted file mode 100644 index 8b9f924e83..0000000000 --- a/nix/patches/occt/no_ExpToCasExe_7_7_2.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 1bacca1a48..11f931ad39 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -820,6 +820,8 @@ else() - OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE") - endif() - -+list (REMOVE_ITEM BUILD_TOOLKITS ExpToCasExe) -+ - # bison - if (BUILD_YACCLEX) - OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison") diff --git a/nix/patches/occt/no_ExpToCasExe_7_8_1.patch b/nix/patches/occt/no_ExpToCasExe_7_8_1.patch deleted file mode 100644 index 63d6fd3206..0000000000 --- a/nix/patches/occt/no_ExpToCasExe_7_8_1.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 86905287dc..9d0bce984c 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -828,6 +828,8 @@ else() - OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE") - endif() - -+list (REMOVE_ITEM BUILD_TOOLKITS ExpToCasExe) -+ - # bison - if (BUILD_YACCLEX) - OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison") diff --git a/nix/patches/occt/no_ExpToCasExe_7_9_1.patch b/nix/patches/occt/no_ExpToCasExe_7_9_1.patch deleted file mode 100644 index abe2b20ef9..0000000000 --- a/nix/patches/occt/no_ExpToCasExe_7_9_1.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 34300d41ad..09b2e0d45f 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -721,6 +721,8 @@ else() - OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE") - endif() - -+list (REMOVE_ITEM BUILD_TOOLKITS ExpToCasExe) -+ - # bison - if (BUILD_YACCLEX) - list (APPEND OCCT_3RDPARTY_CMAKE_LIST "adm/cmake/bison") diff --git a/pyodide/build_pyodide.sh b/pyodide/build_pyodide.sh index 2994a44ae6..20ad946162 100755 --- a/pyodide/build_pyodide.sh +++ b/pyodide/build_pyodide.sh @@ -1,9 +1,12 @@ #!/usr/bin/bash set -ex +# Script is assuming that it will be possible to execute it multiple times +# therefore we're clearing venv each time and ignoring existing 'emsdk' folder. + # Install uv. curl -LsSf https://astral.sh/uv/install.sh | sh -uv venv --python 3.13 +uv venv --python 3.13 --clear source .venv/bin/activate # Install pyodide cross build environment. @@ -13,7 +16,9 @@ uv pip install pyodide-build uv run pyodide xbuildenv install # Emscripten doesn't come with xbuildenv. -git clone https://github.com/emscripten-core/emsdk +if [ ! -d emsdk ]; then + git clone https://github.com/emscripten-core/emsdk +fi pushd emsdk PYODIDE_EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) ./emsdk install ${PYODIDE_EMSCRIPTEN_VERSION} diff --git a/pyproject.toml b/pyproject.toml index 95b61e2c39..4c4aeb331a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,9 +3,9 @@ name = "IfcOpenShell" version = "0.0.0" dependencies = [ "black==26.1.0", - "ruff==0.15.1", + "ruff==0.15.2", "poethepoet", - "gersemi==0.25.4", + "gersemi==0.26.0", ] [tool.black] @@ -15,7 +15,8 @@ include = ''' |nix/.*.pyi?$ ''' extend-exclude = ''' - src/ifcopenshell-python/ifcopenshell/express/* + src/ifcopenshell-python/ifcopenshell/express/rules/* + |src/ifcopenshell-python/ifcopenshell/express/express_parser.py |src/ifcopenshell-python/ifcopenshell/mvd/* |src/ifcopenshell-python/ifcopenshell/simple_spf/* |src/ifc2ca/templates/* diff --git a/src/bcf/bcf/v3/bcfapi.py b/src/bcf/bcf/v3/bcfapi.py index 127d9e3732..3ac85b9685 100644 --- a/src/bcf/bcf/v3/bcfapi.py +++ b/src/bcf/bcf/v3/bcfapi.py @@ -34,8 +34,8 @@ client_id, client_secret = "", "" class OAuthReceiver(http.server.BaseHTTPRequestHandler): def do_GET(self) -> None: query = urllib.parse.parse_qs(urllib.parse.urlparse(self.path).query) - self.server.auth_code = query.get("code", [""])[0] # type:ignore - self.server.auth_state = query.get("state", [""])[0] # type:ignore + self.server.auth_code = query.get("code", [""])[0] # type: ignore + self.server.auth_state = query.get("state", [""])[0] # type: ignore self.send_response(200) self.send_header("Content-type", "text/plain") self.end_headers() diff --git a/src/bonsai/Makefile b/src/bonsai/Makefile index 38fbc61355..310d31a4b0 100644 --- a/src/bonsai/Makefile +++ b/src/bonsai/Makefile @@ -104,7 +104,7 @@ endif endif # def PLATFORM # Current build commit hash. -OLD:=e8eb5e4 +OLD:=1c5b825 .PHONY: bump bump: ifndef NEW diff --git a/src/bonsai/bonsai/__init__.py b/src/bonsai/bonsai/__init__.py index b4083b0eef..e30e2bf699 100644 --- a/src/bonsai/bonsai/__init__.py +++ b/src/bonsai/bonsai/__init__.py @@ -34,7 +34,6 @@ IN_PACKAGE = __package__ == "bonsai" import platform import re -import shutil import traceback import uuid import webbrowser diff --git a/src/bonsai/bonsai/bim/export_ifc.py b/src/bonsai/bonsai/bim/export_ifc.py index cfab523942..633d6292f9 100644 --- a/src/bonsai/bonsai/bim/export_ifc.py +++ b/src/bonsai/bonsai/bim/export_ifc.py @@ -24,21 +24,14 @@ import os import tempfile import zipfile from logging import Logger -from math import radians from typing import Union import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.util.element -import ifcopenshell.util.placement import ifcopenshell.util.unit -from mathutils import Vector -import bonsai.core.aggregate import bonsai.core.geometry -import bonsai.core.spatial -import bonsai.core.style import bonsai.tool as tool from bonsai.bim.ifc import IfcStore diff --git a/src/bonsai/bonsai/bim/helper.py b/src/bonsai/bonsai/bim/helper.py index 9267134988..ab4a0875ab 100644 --- a/src/bonsai/bonsai/bim/helper.py +++ b/src/bonsai/bonsai/bim/helper.py @@ -28,7 +28,6 @@ import bpy import ifcopenshell import ifcopenshell.ifcopenshell_wrapper as W import ifcopenshell.util.attribute -import ifcopenshell.util.element import ifcopenshell.util.unit from ifcopenshell.util.doc import ( get_attribute_doc, diff --git a/src/bonsai/bonsai/bim/import_ifc.py b/src/bonsai/bonsai/bim/import_ifc.py index 9f846d8ccc..7e8f40560e 100644 --- a/src/bonsai/bonsai/bim/import_ifc.py +++ b/src/bonsai/bonsai/bim/import_ifc.py @@ -32,7 +32,6 @@ import ifcopenshell.api.pset import ifcopenshell.geom import ifcopenshell.ifcopenshell_wrapper as W import ifcopenshell.util.element -import ifcopenshell.util.geolocation import ifcopenshell.util.placement import ifcopenshell.util.representation import ifcopenshell.util.shape diff --git a/src/bonsai/bonsai/bim/module/aggregate/decorator.py b/src/bonsai/bonsai/bim/module/aggregate/decorator.py index 080f965bf8..eb389a58bd 100644 --- a/src/bonsai/bonsai/bim/module/aggregate/decorator.py +++ b/src/bonsai/bonsai/bim/module/aggregate/decorator.py @@ -19,7 +19,6 @@ import blf import bpy import gpu -import ifcopenshell import ifcopenshell.util.element from bpy.types import SpaceView3D from bpy_extras import view3d_utils @@ -27,7 +26,6 @@ from gpu_extras.batch import batch_for_shader from mathutils import Vector import bonsai.tool as tool -from bonsai.bim.module.geometry.decorator import ItemDecorator def transparent_color(color, alpha=0.1): diff --git a/src/bonsai/bonsai/bim/module/aggregate/operator.py b/src/bonsai/bonsai/bim/module/aggregate/operator.py index e9f23afece..98bc612784 100644 --- a/src/bonsai/bonsai/bim/module/aggregate/operator.py +++ b/src/bonsai/bonsai/bim/module/aggregate/operator.py @@ -19,8 +19,6 @@ from typing import TYPE_CHECKING import bpy -import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.group import ifcopenshell.api.pset import ifcopenshell.api.root diff --git a/src/bonsai/bonsai/bim/module/aggregate/prop.py b/src/bonsai/bonsai/bim/module/aggregate/prop.py index 241663882f..0595c200c5 100644 --- a/src/bonsai/bonsai/bim/module/aggregate/prop.py +++ b/src/bonsai/bonsai/bim/module/aggregate/prop.py @@ -23,12 +23,7 @@ import ifcopenshell.util.element from bpy.props import ( BoolProperty, CollectionProperty, - EnumProperty, - FloatProperty, - FloatVectorProperty, - IntProperty, PointerProperty, - StringProperty, ) from bpy.types import PropertyGroup @@ -37,8 +32,6 @@ from bonsai.bim.module.aggregate.decorator import ( AggregateDecorator, AggregateModeDecorator, ) -from bonsai.bim.module.spatial.data import SpatialData -from bonsai.bim.prop import Attribute, StrProperty def can_aggregate(relating_obj: bpy.types.Object, related_obj: bpy.types.Object) -> bool: diff --git a/src/bonsai/bonsai/bim/module/aggregate/ui.py b/src/bonsai/bonsai/bim/module/aggregate/ui.py index d693843401..f59ead6308 100644 --- a/src/bonsai/bonsai/bim/module/aggregate/ui.py +++ b/src/bonsai/bonsai/bim/module/aggregate/ui.py @@ -21,7 +21,6 @@ from bpy.types import Panel import bonsai.tool as tool from bonsai.bim.ifc import IfcStore from bonsai.bim.module.aggregate.data import AggregateData -from bonsai.bim.module.group.data import GroupsData, ObjectGroupsData class BIM_PT_aggregate(Panel): diff --git a/src/bonsai/bonsai/bim/module/alignment/operator.py b/src/bonsai/bonsai/bim/module/alignment/operator.py index 0705dcb1b9..42ad1d25de 100644 --- a/src/bonsai/bonsai/bim/module/alignment/operator.py +++ b/src/bonsai/bonsai/bim/module/alignment/operator.py @@ -18,24 +18,14 @@ # pyright: reportUnnecessaryTypeIgnoreComment=error -import calendar -import json -import os import time -from datetime import datetime import bpy import ifcopenshell.api.alignment import ifcopenshell.api.spatial import ifcopenshell.geom -import ifcopenshell.util.selector -import ifcopenshell.util.sequence -import isodate from bpy_extras.io_utils import ImportHelper -from dateutil import parser, relativedelta -import bonsai.bim.module.sequence.helper as helper -import bonsai.core.sequence as core import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/attribute/prop.py b/src/bonsai/bonsai/bim/module/attribute/prop.py index 98ffb00c5c..acff2424b7 100644 --- a/src/bonsai/bonsai/bim/module/attribute/prop.py +++ b/src/bonsai/bonsai/bim/module/attribute/prop.py @@ -23,16 +23,12 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, - StringProperty, ) from bpy.types import PropertyGroup import bonsai.tool as tool -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute class BIMAttributeProperties(PropertyGroup): diff --git a/src/bonsai/bonsai/bim/module/bcf/bcfstore.py b/src/bonsai/bonsai/bim/module/bcf/bcfstore.py index a1fec8aa6e..b1abc97c6e 100644 --- a/src/bonsai/bonsai/bim/module/bcf/bcfstore.py +++ b/src/bonsai/bonsai/bim/module/bcf/bcfstore.py @@ -19,9 +19,7 @@ import os from typing import Union -import bcf import bcf.bcfxml -import bcf.v2.bcfxml import bpy import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/bcf/operator.py b/src/bonsai/bonsai/bim/module/bcf/operator.py index b0a6f1f699..6edf257f05 100644 --- a/src/bonsai/bonsai/bim/module/bcf/operator.py +++ b/src/bonsai/bonsai/bim/module/bcf/operator.py @@ -16,22 +16,18 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import os import tempfile import uuid import webbrowser -from math import atan, cos, degrees, radians, sin, tan +from math import atan, degrees, radians, tan from pathlib import Path -import bcf import bcf.agnostic.topic import bcf.agnostic.visinfo -import bcf.bcfxml import bcf.v2.bcfxml import bcf.v2.model import bcf.v2.topic import bcf.v2.visinfo -import bcf.v3 import bcf.v3.bcfxml import bcf.v3.document import bcf.v3.model @@ -43,11 +39,10 @@ import ifcopenshell.util.geolocation import ifcopenshell.util.unit import numpy as np from bpy_extras.io_utils import ExportHelper, ImportHelper -from mathutils import Euler, Matrix, Vector, geometry +from mathutils import Matrix, Vector from xsdata.models.datatype import XmlDateTime import bonsai.bim.module.bcf.bcfstore as bcfstore -import bonsai.bim.module.bcf.prop as bcf_prop import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/bcf/prop.py b/src/bonsai/bonsai/bim/module/bcf/prop.py index b720a2ff74..3ac751387e 100644 --- a/src/bonsai/bonsai/bim/module/bcf/prop.py +++ b/src/bonsai/bonsai/bim/module/bcf/prop.py @@ -24,8 +24,6 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, PointerProperty, StringProperty, diff --git a/src/bonsai/bonsai/bim/module/bcf/ui.py b/src/bonsai/bonsai/bim/module/bcf/ui.py index e3478f63cf..881bef488b 100644 --- a/src/bonsai/bonsai/bim/module/bcf/ui.py +++ b/src/bonsai/bonsai/bim/module/bcf/ui.py @@ -18,7 +18,6 @@ from __future__ import annotations -import os from typing import TYPE_CHECKING import bpy diff --git a/src/bonsai/bonsai/bim/module/boundary/decorator.py b/src/bonsai/bonsai/bim/module/boundary/decorator.py index 1f5859824e..a2d134a135 100644 --- a/src/bonsai/bonsai/bim/module/boundary/decorator.py +++ b/src/bonsai/bonsai/bim/module/boundary/decorator.py @@ -20,7 +20,6 @@ import bmesh import gpu from bpy.types import SpaceView3D from gpu_extras.batch import batch_for_shader -from mathutils import Vector import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/boundary/operator.py b/src/bonsai/bonsai/bim/module/boundary/operator.py index 4b26a0a4d9..5720d6aae5 100644 --- a/src/bonsai/bonsai/bim/module/boundary/operator.py +++ b/src/bonsai/bonsai/bim/module/boundary/operator.py @@ -29,18 +29,15 @@ import ifcopenshell.api.root import ifcopenshell.geom import ifcopenshell.util.element import ifcopenshell.util.placement -import ifcopenshell.util.representation import ifcopenshell.util.shape import ifcopenshell.util.unit import mathutils -import numpy as np import shapely import shapely.ops from ifcopenshell.util.shape_builder import ShapeBuilder from mathutils import Matrix, Vector import bonsai.bim.import_ifc as import_ifc -import bonsai.core import bonsai.core.geometry import bonsai.tool as tool from bonsai.bim.ifc import IfcStore diff --git a/src/bonsai/bonsai/bim/module/boundary/prop.py b/src/bonsai/bonsai/bim/module/boundary/prop.py index cd7e0b9de3..2e9ab8c975 100644 --- a/src/bonsai/bonsai/bim/module/boundary/prop.py +++ b/src/bonsai/bonsai/bim/module/boundary/prop.py @@ -21,13 +21,7 @@ from typing import TYPE_CHECKING, Union import bpy from bpy.props import ( BoolProperty, - CollectionProperty, - EnumProperty, - FloatProperty, - FloatVectorProperty, - IntProperty, PointerProperty, - StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/module/boundary/ui.py b/src/bonsai/bonsai/bim/module/boundary/ui.py index 54694d752c..0ca21b9ce5 100644 --- a/src/bonsai/bonsai/bim/module/boundary/ui.py +++ b/src/bonsai/bonsai/bim/module/boundary/ui.py @@ -16,8 +16,7 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import bpy -from bpy.types import Panel, UIList +from bpy.types import Panel import bonsai.tool as tool from bonsai.bim.module.boundary.data import SpaceBoundariesData diff --git a/src/bonsai/bonsai/bim/module/brick/data.py b/src/bonsai/bonsai/bim/module/brick/data.py index bae294d713..e414723594 100644 --- a/src/bonsai/bonsai/bim/module/brick/data.py +++ b/src/bonsai/bonsai/bim/module/brick/data.py @@ -63,8 +63,7 @@ class BrickschemaData: if namespace == "https://brickschema.org/schema/Brick": return [] results = [] - query = BrickStore.graph.query( - """ + query = BrickStore.graph.query(""" PREFIX brick: PREFIX rdfs: PREFIX rdf: @@ -81,10 +80,7 @@ class BrickschemaData: } } GROUP BY ?object - """.replace( - "{uri}", uri - ) - ) + """.replace("{uri}", uri)) for row in query: predicate_uri = row.get("predicate") predicate_name = predicate_uri.toPython().split("#")[-1] diff --git a/src/bonsai/bonsai/bim/module/brick/operator.py b/src/bonsai/bonsai/bim/module/brick/operator.py index cb0a5f675f..2f71e6b638 100644 --- a/src/bonsai/bonsai/bim/module/brick/operator.py +++ b/src/bonsai/bonsai/bim/module/brick/operator.py @@ -19,7 +19,6 @@ import os import bpy -import ifcopenshell.api from bpy_extras.io_utils import ExportHelper, ImportHelper import bonsai.bim.handler diff --git a/src/bonsai/bonsai/bim/module/brick/prop.py b/src/bonsai/bonsai/bim/module/brick/prop.py index 9fe6d78407..6201113a09 100644 --- a/src/bonsai/bonsai/bim/module/brick/prop.py +++ b/src/bonsai/bonsai/bim/module/brick/prop.py @@ -23,10 +23,7 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup @@ -34,7 +31,7 @@ from bpy.types import PropertyGroup import bonsai.core.brick as core import bonsai.tool.brick as tool from bonsai.bim.module.brick.data import BrickschemaData, BrickschemaReferencesData -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import StrProperty from bonsai.tool.brick import BrickStore diff --git a/src/bonsai/bonsai/bim/module/bsdd/data.py b/src/bonsai/bonsai/bim/module/bsdd/data.py index 6e916d3355..37d030d867 100644 --- a/src/bonsai/bonsai/bim/module/bsdd/data.py +++ b/src/bonsai/bonsai/bim/module/bsdd/data.py @@ -16,13 +16,8 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import bpy -import ifcopenshell -import ifcopenshell.util.classification -import ifcopenshell.util.date import bonsai.tool as tool -from bonsai.bim.ifc import IfcStore def refresh(): diff --git a/src/bonsai/bonsai/bim/module/bsdd/operator.py b/src/bonsai/bonsai/bim/module/bsdd/operator.py index d3f5533c1a..8b94e12fd9 100644 --- a/src/bonsai/bonsai/bim/module/bsdd/operator.py +++ b/src/bonsai/bonsai/bim/module/bsdd/operator.py @@ -19,7 +19,6 @@ import textwrap from typing import Any import bpy -import bsdd import ifcopenshell.api.pset import ifcopenshell.util.element diff --git a/src/bonsai/bonsai/bim/module/bsdd/prop.py b/src/bonsai/bonsai/bim/module/bsdd/prop.py index efd8db46db..5103358b6e 100644 --- a/src/bonsai/bonsai/bim/module/bsdd/prop.py +++ b/src/bonsai/bonsai/bim/module/bsdd/prop.py @@ -23,10 +23,7 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup @@ -34,7 +31,7 @@ from bpy.types import PropertyGroup import bonsai.tool as tool from bonsai.bim.module.bsdd.data import BSDDData from bonsai.bim.module.classification.data import ClassificationsData -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute def get_active_dictionary(self: "BIMBSDDProperties", context: object) -> tool.Blender.BLENDER_ENUM_ITEMS: @@ -163,7 +160,7 @@ class BIMBSDDProperties(PropertyGroup): default=False, ) classification_psets: CollectionProperty(name="Classification Psets", type=BSDDPset) - + if TYPE_CHECKING: active_dictionary: str active_dictionary: str @@ -182,7 +179,7 @@ class BIMBSDDProperties(PropertyGroup): should_filter_ifc_class: bool use_only_ifc_properties: bool classification_psets: bpy.types.bpy_prop_collection_idprop[BSDDPset] - + @property def active_class(self) -> Union[BSDDClassification, None]: return tool.Blender.get_active_uilist_element(self.classes, self.active_class_index) diff --git a/src/bonsai/bonsai/bim/module/bsdd/ui.py b/src/bonsai/bonsai/bim/module/bsdd/ui.py index f239eb41cf..c6966c01d8 100644 --- a/src/bonsai/bonsai/bim/module/bsdd/ui.py +++ b/src/bonsai/bonsai/bim/module/bsdd/ui.py @@ -24,7 +24,6 @@ import bpy from bpy.types import Panel, UIList import bonsai.tool as tool -import bsdd from bonsai.bim.module.bsdd.data import BSDDData if TYPE_CHECKING: @@ -84,6 +83,7 @@ class BIM_PT_bsdd(Panel): row = self.layout.row() row.operator("bim.load_bsdd_dictionaries") + class BIM_UL_bsdd_dictionaries(UIList): def draw_item( self, diff --git a/src/bonsai/bonsai/bim/module/cad/operator.py b/src/bonsai/bonsai/bim/module/cad/operator.py index 857d757ca1..3b6ef8fc69 100644 --- a/src/bonsai/bonsai/bim/module/cad/operator.py +++ b/src/bonsai/bonsai/bim/module/cad/operator.py @@ -17,13 +17,11 @@ # along with Bonsai. If not, see . import math -from math import cos, pi, radians, sin, sqrt -from typing import Union +from math import pi, sqrt import bmesh import bpy import bpy_extras -import ifcopenshell.util.unit import mathutils from mathutils import Matrix, Vector diff --git a/src/bonsai/bonsai/bim/module/cad/prop.py b/src/bonsai/bonsai/bim/module/cad/prop.py index db737b51dc..7dab36df91 100644 --- a/src/bonsai/bonsai/bim/module/cad/prop.py +++ b/src/bonsai/bonsai/bim/module/cad/prop.py @@ -22,8 +22,6 @@ from typing import TYPE_CHECKING import bpy from bpy.types import PropertyGroup -from bonsai.bim.module.model.data import AuthoringData - class BIMCadProperties(PropertyGroup): resolution: bpy.props.IntProperty(name="Arc Resolution", min=1, default=1) diff --git a/src/bonsai/bonsai/bim/module/cad/workspace.py b/src/bonsai/bonsai/bim/module/cad/workspace.py index b384463ac2..20faa4dcc7 100644 --- a/src/bonsai/bonsai/bim/module/cad/workspace.py +++ b/src/bonsai/bonsai/bim/module/cad/workspace.py @@ -20,12 +20,10 @@ import os from functools import partial import bpy -import ifcopenshell.util.unit from bpy.types import WorkSpaceTool -import bonsai.bim.module.type.prop as type_prop import bonsai.tool as tool -from bonsai.bim.module.model.data import AuthoringData, RailingData, RoofData +from bonsai.bim.module.model.data import RailingData, RoofData def load_custom_icons(): diff --git a/src/bonsai/bonsai/bim/module/clash/data.py b/src/bonsai/bonsai/bim/module/clash/data.py index 4ecbb229a4..f5b87ede95 100644 --- a/src/bonsai/bonsai/bim/module/clash/data.py +++ b/src/bonsai/bonsai/bim/module/clash/data.py @@ -18,9 +18,6 @@ import json -import bpy -import ifcopenshell.util.element - import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/clash/decorator.py b/src/bonsai/bonsai/bim/module/clash/decorator.py index d1d0daf095..ab95c92d9f 100644 --- a/src/bonsai/bonsai/bim/module/clash/decorator.py +++ b/src/bonsai/bonsai/bim/module/clash/decorator.py @@ -17,7 +17,6 @@ # along with Bonsai. If not, see . import blf -import bmesh import gpu from bpy.types import SpaceView3D from bpy_extras.view3d_utils import location_3d_to_region_2d diff --git a/src/bonsai/bonsai/bim/module/clash/operator.py b/src/bonsai/bonsai/bim/module/clash/operator.py index 688568270f..94866a4e97 100644 --- a/src/bonsai/bonsai/bim/module/clash/operator.py +++ b/src/bonsai/bonsai/bim/module/clash/operator.py @@ -18,16 +18,13 @@ import json import logging -import os import tempfile from math import radians from pathlib import Path from typing import TYPE_CHECKING -import bmesh import bpy import ifcopenshell -import numpy as np from bpy_extras.io_utils import ExportHelper, ImportHelper from mathutils import Matrix, Vector diff --git a/src/bonsai/bonsai/bim/module/clash/prop.py b/src/bonsai/bonsai/bim/module/clash/prop.py index 5f42a400e7..8bcd71632b 100644 --- a/src/bonsai/bonsai/bim/module/clash/prop.py +++ b/src/bonsai/bonsai/bim/module/clash/prop.py @@ -26,7 +26,6 @@ from bpy.props import ( FloatProperty, FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup @@ -34,7 +33,7 @@ from ifcopenshell.geom.main import CLASH_TYPE_ITEMS, ClashType from mathutils import Vector import bonsai.tool as tool -from bonsai.bim.prop import Attribute, BIMFilterGroup, StrProperty +from bonsai.bim.prop import BIMFilterGroup, StrProperty class ClashSource(PropertyGroup): diff --git a/src/bonsai/bonsai/bim/module/classification/operator.py b/src/bonsai/bonsai/bim/module/classification/operator.py index 7bf699cc31..77b77ba541 100644 --- a/src/bonsai/bonsai/bim/module/classification/operator.py +++ b/src/bonsai/bonsai/bim/module/classification/operator.py @@ -18,7 +18,6 @@ import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.classification import ifcopenshell.api.pset import ifcopenshell.util.classification diff --git a/src/bonsai/bonsai/bim/module/classification/prop.py b/src/bonsai/bonsai/bim/module/classification/prop.py index 454f861f07..44f174bd13 100644 --- a/src/bonsai/bonsai/bim/module/classification/prop.py +++ b/src/bonsai/bonsai/bim/module/classification/prop.py @@ -23,10 +23,7 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/module/classification/ui.py b/src/bonsai/bonsai/bim/module/classification/ui.py index 77310be49a..6840238927 100644 --- a/src/bonsai/bonsai/bim/module/classification/ui.py +++ b/src/bonsai/bonsai/bim/module/classification/ui.py @@ -25,7 +25,6 @@ import ifcopenshell.util.classification from bpy.types import Panel, UIList import bonsai.bim.helper -import bonsai.bim.module.classification.prop as classification_prop import bonsai.tool as tool from bonsai.bim.module.classification.data import ( ClassificationsData, diff --git a/src/bonsai/bonsai/bim/module/constraint/operator.py b/src/bonsai/bonsai/bim/module/constraint/operator.py index 976f4ff6a3..d438325f44 100644 --- a/src/bonsai/bonsai/bim/module/constraint/operator.py +++ b/src/bonsai/bonsai/bim/module/constraint/operator.py @@ -19,7 +19,6 @@ from typing import TYPE_CHECKING import bpy -import ifcopenshell.api import ifcopenshell.api.constraint import bonsai.bim.helper diff --git a/src/bonsai/bonsai/bim/module/constraint/prop.py b/src/bonsai/bonsai/bim/module/constraint/prop.py index c76d48e8a6..55ae9d1223 100644 --- a/src/bonsai/bonsai/bim/module/constraint/prop.py +++ b/src/bonsai/bonsai/bim/module/constraint/prop.py @@ -20,19 +20,13 @@ from typing import TYPE_CHECKING, Literal import bpy from bpy.props import ( - BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup -from ifcopenshell.util.doc import get_entity_doc -import bonsai.tool as tool from bonsai.bim.module.constraint.data import ConstraintsData from bonsai.bim.prop import Attribute diff --git a/src/bonsai/bonsai/bim/module/context/data.py b/src/bonsai/bonsai/bim/module/context/data.py index ade8061a4b..e2717a166a 100644 --- a/src/bonsai/bonsai/bim/module/context/data.py +++ b/src/bonsai/bonsai/bim/module/context/data.py @@ -18,7 +18,6 @@ from typing import Any -import bpy import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/context/prop.py b/src/bonsai/bonsai/bim/module/context/prop.py index ff73c53a5a..e8540746ff 100644 --- a/src/bonsai/bonsai/bim/module/context/prop.py +++ b/src/bonsai/bonsai/bim/module/context/prop.py @@ -20,19 +20,13 @@ from typing import TYPE_CHECKING import bpy from bpy.props import ( - BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, - StringProperty, ) from bpy.types import PropertyGroup -from bonsai.bim.module.context.data import ContextData -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute class BIMContextProperties(PropertyGroup): diff --git a/src/bonsai/bonsai/bim/module/cost/data.py b/src/bonsai/bonsai/bim/module/cost/data.py index aab9ea9231..32299b8e41 100644 --- a/src/bonsai/bonsai/bim/module/cost/data.py +++ b/src/bonsai/bonsai/bim/module/cost/data.py @@ -18,13 +18,11 @@ from typing import Any, Union -import bpy import ifcopenshell import ifcopenshell.util.cost import ifcopenshell.util.date import ifcopenshell.util.element import ifcopenshell.util.unit -from ifcopenshell.util.doc import get_entity_doc, get_predefined_type_doc import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/cost/operator.py b/src/bonsai/bonsai/bim/module/cost/operator.py index 48b672a2c2..b612100a1d 100644 --- a/src/bonsai/bonsai/bim/module/cost/operator.py +++ b/src/bonsai/bonsai/bim/module/cost/operator.py @@ -987,10 +987,10 @@ class ExportCostSchedulesToPDF(bpy.types.Operator, ExportHelper): @classmethod def poll(cls, context): try: - import typst + import typst # noqa: F401 return True - except: + except ModuleNotFoundError: cls.poll_message_set( "Typst not available.\nIt can be installed from Quality and\nControl -> Debug and using 'typst' with Pip Install.\n(Run Blender as Administrator)" ) diff --git a/src/bonsai/bonsai/bim/module/cost/prop.py b/src/bonsai/bonsai/bim/module/cost/prop.py index 121ca617e7..426d5c1e33 100644 --- a/src/bonsai/bonsai/bim/module/cost/prop.py +++ b/src/bonsai/bonsai/bim/module/cost/prop.py @@ -19,16 +19,13 @@ from typing import TYPE_CHECKING, Literal, Union import bpy -import ifcopenshell.api import ifcopenshell.api.cost from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/module/covering/workspace.py b/src/bonsai/bonsai/bim/module/covering/workspace.py index 68b2704166..728b4f6013 100644 --- a/src/bonsai/bonsai/bim/module/covering/workspace.py +++ b/src/bonsai/bonsai/bim/module/covering/workspace.py @@ -21,7 +21,6 @@ import os from functools import partial import bpy -import ifcopenshell from bpy.types import WorkSpaceTool import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/covetool/operator.py b/src/bonsai/bonsai/bim/module/covetool/operator.py index fa298ada9c..fb2b2f3086 100644 --- a/src/bonsai/bonsai/bim/module/covetool/operator.py +++ b/src/bonsai/bonsai/bim/module/covetool/operator.py @@ -20,7 +20,6 @@ import json from math import atan2, degrees import bpy -import ifcopenshell import ifcopenshell.util.element import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/csv/operator.py b/src/bonsai/bonsai/bim/module/csv/operator.py index d42e8d3852..3b1db40b6b 100644 --- a/src/bonsai/bonsai/bim/module/csv/operator.py +++ b/src/bonsai/bonsai/bim/module/csv/operator.py @@ -19,14 +19,10 @@ from __future__ import annotations import json -import logging -import os -import tempfile from collections import Counter from typing import TYPE_CHECKING import bpy -import ifccsv import ifcopenshell import ifcopenshell.util.selector from bpy_extras.io_utils import ExportHelper, ImportHelper diff --git a/src/bonsai/bonsai/bim/module/csv/prop.py b/src/bonsai/bonsai/bim/module/csv/prop.py index a698f89b76..8104a8d75b 100644 --- a/src/bonsai/bonsai/bim/module/csv/prop.py +++ b/src/bonsai/bonsai/bim/module/csv/prop.py @@ -23,15 +23,11 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, - IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup -from bonsai.bim.prop import BIMFilterGroup, StrProperty +from bonsai.bim.prop import BIMFilterGroup class CsvAttribute(PropertyGroup): diff --git a/src/bonsai/bonsai/bim/module/debug/operator.py b/src/bonsai/bonsai/bim/module/debug/operator.py index 6e30a3cc0f..9315386008 100644 --- a/src/bonsai/bonsai/bim/module/debug/operator.py +++ b/src/bonsai/bonsai/bim/module/debug/operator.py @@ -29,7 +29,6 @@ from typing import TYPE_CHECKING, Any, Literal, Union, assert_never, get_args import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.pset import ifcopenshell.geom import ifcopenshell.ifcopenshell_wrapper as W diff --git a/src/bonsai/bonsai/bim/module/debug/prop.py b/src/bonsai/bonsai/bim/module/debug/prop.py index e52ec5ff7d..9744159e20 100644 --- a/src/bonsai/bonsai/bim/module/debug/prop.py +++ b/src/bonsai/bonsai/bim/module/debug/prop.py @@ -20,13 +20,9 @@ from typing import TYPE_CHECKING, Literal, get_args import bpy from bpy.props import ( - BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/module/demo/prop.py b/src/bonsai/bonsai/bim/module/demo/prop.py index f206fe3156..6570c4cbc0 100644 --- a/src/bonsai/bonsai/bim/module/demo/prop.py +++ b/src/bonsai/bonsai/bim/module/demo/prop.py @@ -32,18 +32,10 @@ from typing import TYPE_CHECKING -import bpy - # Properties have many different data types. We won't use all of them in this # demo module, but this is a list for your reference. from bpy.props import ( BoolProperty, - CollectionProperty, - EnumProperty, - FloatProperty, - FloatVectorProperty, - IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/module/diff/prop.py b/src/bonsai/bonsai/bim/module/diff/prop.py index c8f9d48c84..cfe5b147fe 100644 --- a/src/bonsai/bonsai/bim/module/diff/prop.py +++ b/src/bonsai/bonsai/bim/module/diff/prop.py @@ -23,16 +23,12 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, - IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup from bonsai.bim.module.diff.data import DiffData -from bonsai.bim.prop import BIMFilterGroup, StrProperty +from bonsai.bim.prop import BIMFilterGroup def update_diff_json_file(self: "DiffProperties", context: bpy.types.Context) -> None: diff --git a/src/bonsai/bonsai/bim/module/document/data.py b/src/bonsai/bonsai/bim/module/document/data.py index 97b4a1f206..f194e2f4e0 100644 --- a/src/bonsai/bonsai/bim/module/document/data.py +++ b/src/bonsai/bonsai/bim/module/document/data.py @@ -19,8 +19,6 @@ import os import bpy -import ifcopenshell -import ifcopenshell.util.schema from natsort import natsorted import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/document/operator.py b/src/bonsai/bonsai/bim/module/document/operator.py index a4e5cfc4ac..006ed27957 100644 --- a/src/bonsai/bonsai/bim/module/document/operator.py +++ b/src/bonsai/bonsai/bim/module/document/operator.py @@ -20,10 +20,9 @@ import json import bpy -import bonsai.bim.handler import bonsai.core.document as core import bonsai.tool as tool -from bonsai.bim.module.document.data import DocumentData, ObjectDocumentData +from bonsai.bim.module.document.data import ObjectDocumentData class LoadProjectDocuments(bpy.types.Operator): diff --git a/src/bonsai/bonsai/bim/module/document/prop.py b/src/bonsai/bonsai/bim/module/document/prop.py index b1eb41cc2e..c51f7b636c 100644 --- a/src/bonsai/bonsai/bim/module/document/prop.py +++ b/src/bonsai/bonsai/bim/module/document/prop.py @@ -5,17 +5,14 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup import bonsai.tool as tool from bonsai.bim.module.document.data import DocumentData, refresh -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute def update_document_name(self: "Document", context: bpy.types.Context) -> None: diff --git a/src/bonsai/bonsai/bim/module/document/ui.py b/src/bonsai/bonsai/bim/module/document/ui.py index eda5d34a1d..d618d6d966 100644 --- a/src/bonsai/bonsai/bim/module/document/ui.py +++ b/src/bonsai/bonsai/bim/module/document/ui.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import bpy from bpy.types import Panel, UIList import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/drawing/annotation.py b/src/bonsai/bonsai/bim/module/drawing/annotation.py index 18d914872a..d1e2dc4b2b 100644 --- a/src/bonsai/bonsai/bim/module/drawing/annotation.py +++ b/src/bonsai/bonsai/bim/module/drawing/annotation.py @@ -18,15 +18,12 @@ from __future__ import annotations -import math -import os -from pathlib import Path from typing import Optional import bmesh import bpy import ifcopenshell.util.element -from mathutils import Matrix, Vector +from mathutils import Vector import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/drawing/data.py b/src/bonsai/bonsai/bim/module/drawing/data.py index 1668d386d3..8373ed29bc 100644 --- a/src/bonsai/bonsai/bim/module/drawing/data.py +++ b/src/bonsai/bonsai/bim/module/drawing/data.py @@ -23,8 +23,6 @@ from typing import Any, Union import bpy import ifcopenshell.util.element -import ifcopenshell.util.representation -import ifcopenshell.util.selector import ifcopenshell.util.unit from natsort import natsorted diff --git a/src/bonsai/bonsai/bim/module/drawing/decoration.py b/src/bonsai/bonsai/bim/module/drawing/decoration.py index 705fabfcf9..f950f7a1bb 100644 --- a/src/bonsai/bonsai/bim/module/drawing/decoration.py +++ b/src/bonsai/bonsai/bim/module/drawing/decoration.py @@ -23,7 +23,7 @@ from functools import cache from math import acos, atan, cos, degrees, pi, radians, sin from pathlib import Path from timeit import default_timer as timer -from typing import Optional, Union +from typing import Optional import blf import bmesh @@ -34,7 +34,6 @@ import ifcopenshell.util.element import ifcopenshell.util.representation import ifcopenshell.util.unit import numpy as np -import shapely from bpy.types import SpaceView3D from bpy_extras.view3d_utils import location_3d_to_region_2d from gpu_extras.batch import batch_for_shader diff --git a/src/bonsai/bonsai/bim/module/drawing/helper.py b/src/bonsai/bonsai/bim/module/drawing/helper.py index ee8ecf805d..7dce81359d 100644 --- a/src/bonsai/bonsai/bim/module/drawing/helper.py +++ b/src/bonsai/bonsai/bim/module/drawing/helper.py @@ -17,10 +17,8 @@ # along with Bonsai. If not, see . import math -from typing import Union import bpy -import ifcopenshell import ifcopenshell.util.element import ifcopenshell.util.unit import mathutils.geometry diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index 2cddf46f9e..66a1482acc 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -20,7 +20,6 @@ import hashlib import json import multiprocessing import os -import re import shutil import subprocess import time @@ -42,7 +41,6 @@ import bmesh import bpy import logging import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.document import ifcopenshell.api.pset import ifcopenshell.api.style @@ -55,17 +53,14 @@ import ifcopenshell.util.shape_builder import ifcopenshell.util.unit import numpy as np import shapely -import shapely.ops from bpy_extras.image_utils import load_image from bpy_extras.io_utils import ImportHelper from lxml import etree -from mathutils import Color, Matrix, Vector +from mathutils import Color, Vector import bonsai.bim.import_ifc import bonsai.bim.export_ifc import bonsai.bim.handler -import bonsai.bim.helper -import bonsai.bim.module.drawing.annotation as annotation import bonsai.bim.module.drawing.sheeter as sheeter import bonsai.bim.module.drawing.svgwriter as svgwriter import bonsai.core.drawing as core @@ -3876,7 +3871,6 @@ class AddReferenceImage(bpy.types.Operator, tool.Ifc.Operator, ImportHelper): layout.prop(self, "x_length") layout.prop(self, "y_length") - def _execute(self, context): project_props = tool.Project.get_project_props() project_props.load_indexed_maps = self.show_texture_solid_mode @@ -3905,7 +3899,7 @@ class AddReferenceImage(bpy.types.Operator, tool.Ifc.Operator, ImportHelper): unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file) hx = self.x_length * 0.5 / unit_scale hy = self.y_length * 0.5 / unit_scale - verts = [(-hx, -hy, 0.0), ( hx, -hy, 0.0), ( hx, hy, 0.0), (-hx, hy, 0.0)] + verts = [(-hx, -hy, 0.0), (hx, -hy, 0.0), (hx, hy, 0.0), (-hx, hy, 0.0)] item = builder.mesh(verts, [[0, 1, 2, 3]]) ifc_context = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW") diff --git a/src/bonsai/bonsai/bim/module/drawing/prop.py b/src/bonsai/bonsai/bim/module/drawing/prop.py index b323b8d41e..cc597a4802 100644 --- a/src/bonsai/bonsai/bim/module/drawing/prop.py +++ b/src/bonsai/bonsai/bim/module/drawing/prop.py @@ -18,14 +18,11 @@ import enum import json -import os from collections.abc import Callable -from pathlib import Path -from typing import TYPE_CHECKING, Any, Literal, Union, get_args +from typing import TYPE_CHECKING, Any, Literal, Union import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.pset import ifcopenshell.util.element from bpy.props import ( @@ -34,7 +31,6 @@ from bpy.props import ( CollectionProperty, EnumProperty, FloatProperty, - FloatVectorProperty, IntProperty, PointerProperty, StringProperty, @@ -42,19 +38,17 @@ from bpy.props import ( from bpy.types import PropertyGroup from mathutils import Matrix -import bonsai.bim.module.drawing.annotation as annotation import bonsai.bim.module.drawing.decoration as decoration import bonsai.core.drawing as core import bonsai.tool as tool from bonsai.bim.module.drawing.data import ( AnnotationData, - DecoratorData, DrawingsData, ElementValuesData, SheetsData, ) from bonsai.bim.module.drawing.data import refresh as refresh_drawing_data -from bonsai.bim.prop import Attribute, BIMFilterGroup, StrProperty +from bonsai.bim.prop import Attribute, BIMFilterGroup diagram_scales_enum = [] diff --git a/src/bonsai/bonsai/bim/module/drawing/scheduler.py b/src/bonsai/bonsai/bim/module/drawing/scheduler.py index 3b120e8d99..a1610020c4 100644 --- a/src/bonsai/bonsai/bim/module/drawing/scheduler.py +++ b/src/bonsai/bonsai/bim/module/drawing/scheduler.py @@ -22,7 +22,6 @@ import string from pathlib import Path from textwrap import wrap -import bpy import openpyxl import openpyxl.cell # Unnecessary, bug in typeshed. import openpyxl.utils # Unnecessary, bug in typeshed. @@ -33,7 +32,6 @@ from odf.table import Table, TableCell, TableColumn, TableRow from odf.text import P import bonsai.tool as tool -from bonsai.bim.ifc import IfcStore from bonsai.bim.module.drawing.svgwriter import SvgWriter DEBUG = False diff --git a/src/bonsai/bonsai/bim/module/drawing/shaders.py b/src/bonsai/bonsai/bim/module/drawing/shaders.py index 2efd6ea285..774002fea3 100644 --- a/src/bonsai/bonsai/bim/module/drawing/shaders.py +++ b/src/bonsai/bonsai/bim/module/drawing/shaders.py @@ -335,12 +335,9 @@ class BaseLinesShader(BaseShader): TYPE = "LINES" - DEF_GLSL = ( - BaseShader.DEF_GLSL - + """ + DEF_GLSL = BaseShader.DEF_GLSL + """ #define GAP_SIZE {gap_size} """ - ) GEOM_GLSL = """ layout(lines) in; @@ -401,13 +398,10 @@ class DotsGizmoShader(GizmoShader): TYPE = "POINTS" - DEF_GLSL = ( - BaseShader.DEF_GLSL - + """ + DEF_GLSL = BaseShader.DEF_GLSL + """ #define CIRCLE_SEGMENTS 12 #define CIRCLE_RADIUS 8 """ - ) GEOM_GLSL = """ layout(points) in; diff --git a/src/bonsai/bonsai/bim/module/drawing/sheeter.py b/src/bonsai/bonsai/bim/module/drawing/sheeter.py index 7d8ebb67f4..df57b6efb5 100644 --- a/src/bonsai/bonsai/bim/module/drawing/sheeter.py +++ b/src/bonsai/bonsai/bim/module/drawing/sheeter.py @@ -26,7 +26,6 @@ import xml.etree.ElementTree as ET from pathlib import Path from xml.dom import minidom -import bpy import ifcopenshell.util.geolocation import pystache from mathutils import Vector diff --git a/src/bonsai/bonsai/bim/module/drawing/svgwriter.py b/src/bonsai/bonsai/bim/module/drawing/svgwriter.py index ef64fdefc6..83566c4d0b 100644 --- a/src/bonsai/bonsai/bim/module/drawing/svgwriter.py +++ b/src/bonsai/bonsai/bim/module/drawing/svgwriter.py @@ -18,7 +18,6 @@ import math import os -import re import shutil import xml.etree.ElementTree as ET from collections.abc import Callable, Sequence @@ -30,10 +29,8 @@ import bmesh import bpy import ifcopenshell import ifcopenshell.util.element -import ifcopenshell.util.representation import ifcopenshell.util.selector import ifcopenshell.util.unit -import mathutils import svgwrite import svgwrite.container import svgwrite.text diff --git a/src/bonsai/bonsai/bim/module/drawing/ui.py b/src/bonsai/bonsai/bim/module/drawing/ui.py index dc98715686..1b6a11cd75 100644 --- a/src/bonsai/bonsai/bim/module/drawing/ui.py +++ b/src/bonsai/bonsai/bim/module/drawing/ui.py @@ -30,7 +30,6 @@ from bonsai.bim.module.drawing.data import ( DocumentsData, DrawingsData, ElementFiltersData, - ElementValuesData, ProductAssignmentsData, SheetsData, ) diff --git a/src/bonsai/bonsai/bim/module/fm/data.py b/src/bonsai/bonsai/bim/module/fm/data.py index 80a686e364..6d486fd9ce 100644 --- a/src/bonsai/bonsai/bim/module/fm/data.py +++ b/src/bonsai/bonsai/bim/module/fm/data.py @@ -16,8 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import importlib -import os import ifcfm diff --git a/src/bonsai/bonsai/bim/module/fm/operator.py b/src/bonsai/bonsai/bim/module/fm/operator.py index 629251282a..43e9bb50e7 100644 --- a/src/bonsai/bonsai/bim/module/fm/operator.py +++ b/src/bonsai/bonsai/bim/module/fm/operator.py @@ -16,10 +16,7 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import json -import logging import os -import tempfile import bpy import ifcfm diff --git a/src/bonsai/bonsai/bim/module/fm/prop.py b/src/bonsai/bonsai/bim/module/fm/prop.py index 2eb1ae4739..cd6b038bc7 100644 --- a/src/bonsai/bonsai/bim/module/fm/prop.py +++ b/src/bonsai/bonsai/bim/module/fm/prop.py @@ -23,11 +23,7 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, - IntProperty, PointerProperty, - StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/module/geometry/__init__.py b/src/bonsai/bonsai/bim/module/geometry/__init__.py index bc64947436..111b67b5b0 100644 --- a/src/bonsai/bonsai/bim/module/geometry/__init__.py +++ b/src/bonsai/bonsai/bim/module/geometry/__init__.py @@ -16,8 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import math - import bpy import ifcopenshell.util.element from bpy.app.handlers import persistent diff --git a/src/bonsai/bonsai/bim/module/geometry/decorator.py b/src/bonsai/bonsai/bim/module/geometry/decorator.py index c5a82c1d59..589b18ec84 100644 --- a/src/bonsai/bonsai/bim/module/geometry/decorator.py +++ b/src/bonsai/bonsai/bim/module/geometry/decorator.py @@ -19,7 +19,6 @@ from collections.abc import Sequence import blf -import bmesh import bpy import gpu import ifcopenshell diff --git a/src/bonsai/bonsai/bim/module/geometry/helper.py b/src/bonsai/bonsai/bim/module/geometry/helper.py index 511669d60d..3b14003435 100644 --- a/src/bonsai/bonsai/bim/module/geometry/helper.py +++ b/src/bonsai/bonsai/bim/module/geometry/helper.py @@ -16,22 +16,17 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -from math import pi, pow +from math import pi from typing import Any, Optional, TypeVar, Union import bmesh import bpy import ifcopenshell -import ifcopenshell.util.shape import ifcopenshell.util.unit import mathutils -import numpy as np -import shapely from ifcopenshell.util.shape_builder import ShapeBuilder from mathutils import Matrix, Vector, geometry -import bonsai.tool as tool - T = TypeVar("T") diff --git a/src/bonsai/bonsai/bim/module/geometry/operator.py b/src/bonsai/bonsai/bim/module/geometry/operator.py index 7937acca30..f8389cb3af 100644 --- a/src/bonsai/bonsai/bim/module/geometry/operator.py +++ b/src/bonsai/bonsai/bim/module/geometry/operator.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import re from collections.abc import Sequence from time import time from typing import ( @@ -32,11 +31,9 @@ from typing import ( import bmesh import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.boundary import ifcopenshell.api.drawing import ifcopenshell.api.geometry -import ifcopenshell.api.grid import ifcopenshell.api.group import ifcopenshell.api.layer import ifcopenshell.api.material @@ -61,10 +58,8 @@ import bonsai.core.geometry as core import bonsai.core.nest import bonsai.core.root import bonsai.core.spatial -import bonsai.core.style import bonsai.tool as tool from bonsai.bim.ifc import IfcStore -from bonsai.bim.module.model.data import AuthoringData from bonsai.bim.module.model.decorator import ProfileDecorator if TYPE_CHECKING: @@ -902,7 +897,7 @@ class OverrideDelete(bpy.types.Operator): if not is_valid_data_block: continue - + element = tool.Ifc.get_entity(obj) if element: if tool.Geometry.is_locked(element): diff --git a/src/bonsai/bonsai/bim/module/geometry/prop.py b/src/bonsai/bonsai/bim/module/geometry/prop.py index 5336eef1c0..549c3bd227 100644 --- a/src/bonsai/bonsai/bim/module/geometry/prop.py +++ b/src/bonsai/bonsai/bim/module/geometry/prop.py @@ -24,8 +24,6 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, PointerProperty, StringProperty, @@ -34,7 +32,6 @@ from bpy.types import PropertyGroup import bonsai.tool as tool from bonsai.bim.module.geometry.data import RepresentationsData, ViewportData -from bonsai.bim.prop import Attribute, ObjProperty, StrProperty def get_contexts(self: "BIMObjectGeometryProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]: diff --git a/src/bonsai/bonsai/bim/module/georeference/data.py b/src/bonsai/bonsai/bim/module/georeference/data.py index cf86314f9a..bc9e5b9ac4 100644 --- a/src/bonsai/bonsai/bim/module/georeference/data.py +++ b/src/bonsai/bonsai/bim/module/georeference/data.py @@ -17,7 +17,6 @@ # along with Bonsai. If not, see . -import bpy import ifcopenshell.util.element import ifcopenshell.util.geolocation import ifcopenshell.util.schema diff --git a/src/bonsai/bonsai/bim/module/georeference/decorator.py b/src/bonsai/bonsai/bim/module/georeference/decorator.py index 6cece45cc8..05bce0e20b 100644 --- a/src/bonsai/bonsai/bim/module/georeference/decorator.py +++ b/src/bonsai/bonsai/bim/module/georeference/decorator.py @@ -19,10 +19,7 @@ from math import radians import blf -import bmesh -import bpy import gpu -import ifcopenshell import ifcopenshell.util.geolocation from bpy.types import SpaceView3D from bpy_extras.view3d_utils import location_3d_to_region_2d diff --git a/src/bonsai/bonsai/bim/module/georeference/operator.py b/src/bonsai/bonsai/bim/module/georeference/operator.py index c2af3d9225..93a4e0ef24 100644 --- a/src/bonsai/bonsai/bim/module/georeference/operator.py +++ b/src/bonsai/bonsai/bim/module/georeference/operator.py @@ -21,7 +21,6 @@ from bpy_extras.io_utils import ImportHelper import bonsai.core.georeference as core import bonsai.tool as tool -from bonsai.bim.module.georeference.decorator import GeoreferenceDecorator class AddGeoreferencing(bpy.types.Operator, tool.Ifc.Operator): diff --git a/src/bonsai/bonsai/bim/module/georeference/prop.py b/src/bonsai/bonsai/bim/module/georeference/prop.py index 1f4ca321ac..41035398e9 100644 --- a/src/bonsai/bonsai/bim/module/georeference/prop.py +++ b/src/bonsai/bonsai/bim/module/georeference/prop.py @@ -23,11 +23,7 @@ import ifcopenshell.util.geolocation from bpy.props import ( BoolProperty, CollectionProperty, - EnumProperty, FloatProperty, - FloatVectorProperty, - IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/module/group/data.py b/src/bonsai/bonsai/bim/module/group/data.py index c7be2ff393..fd5eba102d 100644 --- a/src/bonsai/bonsai/bim/module/group/data.py +++ b/src/bonsai/bonsai/bim/module/group/data.py @@ -17,9 +17,6 @@ # along with Bonsai. If not, see . import bpy -import ifcopenshell -import ifcopenshell.util.cost -import ifcopenshell.util.element import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/group/operator.py b/src/bonsai/bonsai/bim/module/group/operator.py index 66872ed90a..adea9ee48c 100644 --- a/src/bonsai/bonsai/bim/module/group/operator.py +++ b/src/bonsai/bonsai/bim/module/group/operator.py @@ -16,10 +16,9 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -from typing import TYPE_CHECKING, Literal, get_args +from typing import TYPE_CHECKING, get_args import bpy -import ifcopenshell.api import ifcopenshell.api.group import ifcopenshell.util.element diff --git a/src/bonsai/bonsai/bim/module/group/prop.py b/src/bonsai/bonsai/bim/module/group/prop.py index 48bff62e35..56cf7aae07 100644 --- a/src/bonsai/bonsai/bim/module/group/prop.py +++ b/src/bonsai/bonsai/bim/module/group/prop.py @@ -22,18 +22,14 @@ import bpy from bpy.props import ( BoolProperty, CollectionProperty, - EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup import bonsai.tool as tool from bonsai.bim.module.pset.data import refresh as refresh_pset -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute def update_active_group_index(self, context): diff --git a/src/bonsai/bonsai/bim/module/ifcgit/data.py b/src/bonsai/bonsai/bim/module/ifcgit/data.py index 9cb9f2655d..92da517a1c 100644 --- a/src/bonsai/bonsai/bim/module/ifcgit/data.py +++ b/src/bonsai/bonsai/bim/module/ifcgit/data.py @@ -1,8 +1,6 @@ import os import shutil -import bpy - # import tool import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/layer/data.py b/src/bonsai/bonsai/bim/module/layer/data.py index 4550d3257e..1ec9db8b39 100644 --- a/src/bonsai/bonsai/bim/module/layer/data.py +++ b/src/bonsai/bonsai/bim/module/layer/data.py @@ -19,7 +19,6 @@ from typing import Any import bpy -import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/layer/operator.py b/src/bonsai/bonsai/bim/module/layer/operator.py index 8475bebd54..4ff2a4fe0e 100644 --- a/src/bonsai/bonsai/bim/module/layer/operator.py +++ b/src/bonsai/bonsai/bim/module/layer/operator.py @@ -19,7 +19,6 @@ from typing import TYPE_CHECKING import bpy -import ifcopenshell.api import ifcopenshell.api.layer import ifcopenshell.util.element diff --git a/src/bonsai/bonsai/bim/module/layer/prop.py b/src/bonsai/bonsai/bim/module/layer/prop.py index 26a6c3680d..f91681af76 100644 --- a/src/bonsai/bonsai/bim/module/layer/prop.py +++ b/src/bonsai/bonsai/bim/module/layer/prop.py @@ -23,16 +23,13 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup import bonsai.tool as tool -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute def update_layer_property(self: "Layer", context: bpy.types.Context, *, property: str) -> None: diff --git a/src/bonsai/bonsai/bim/module/library/operator.py b/src/bonsai/bonsai/bim/module/library/operator.py index 6c7abe8be5..058b474732 100644 --- a/src/bonsai/bonsai/bim/module/library/operator.py +++ b/src/bonsai/bonsai/bim/module/library/operator.py @@ -17,7 +17,6 @@ # along with Bonsai. If not, see . import bpy -import ifcopenshell.api import bonsai.core.library as core import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/library/prop.py b/src/bonsai/bonsai/bim/module/library/prop.py index 69647c195f..d7a9b51e1f 100644 --- a/src/bonsai/bonsai/bim/module/library/prop.py +++ b/src/bonsai/bonsai/bim/module/library/prop.py @@ -20,20 +20,16 @@ from typing import TYPE_CHECKING, Literal import bpy from bpy.props import ( - BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup import bonsai.tool as tool from bonsai.bim.module.library.data import LibrariesData -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute def update_active_reference_index(self, context): diff --git a/src/bonsai/bonsai/bim/module/library/ui.py b/src/bonsai/bonsai/bim/module/library/ui.py index f76e6a3251..32780f2797 100644 --- a/src/bonsai/bonsai/bim/module/library/ui.py +++ b/src/bonsai/bonsai/bim/module/library/ui.py @@ -28,7 +28,7 @@ import bonsai.tool as tool from bonsai.bim.module.library.data import LibrariesData, LibraryReferencesData if TYPE_CHECKING: - from bonsai.bim.module.library.prop import BIMLibraryProperties, LibraryReference + from bonsai.bim.module.library.prop import LibraryReference class BIM_PT_libraries(Panel): diff --git a/src/bonsai/bonsai/bim/module/light/__init__.py b/src/bonsai/bonsai/bim/module/light/__init__.py index 1bfe11be7a..fa167bc518 100644 --- a/src/bonsai/bonsai/bim/module/light/__init__.py +++ b/src/bonsai/bonsai/bim/module/light/__init__.py @@ -16,10 +16,8 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import importlib import importlib.util import stat -import traceback from pathlib import Path import bpy diff --git a/src/bonsai/bonsai/bim/module/light/data.py b/src/bonsai/bonsai/bim/module/light/data.py index d708b6170f..d14835bb27 100644 --- a/src/bonsai/bonsai/bim/module/light/data.py +++ b/src/bonsai/bonsai/bim/module/light/data.py @@ -16,9 +16,7 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import bpy import ifcopenshell.util.geolocation -from mathutils import Vector import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/light/decorator.py b/src/bonsai/bonsai/bim/module/light/decorator.py index 9cfb9ae186..f72a941ab8 100644 --- a/src/bonsai/bonsai/bim/module/light/decorator.py +++ b/src/bonsai/bonsai/bim/module/light/decorator.py @@ -16,10 +16,8 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -from math import degrees, radians import blf -import bmesh import bpy import gpu from bpy.types import SpaceView3D diff --git a/src/bonsai/bonsai/bim/module/material/data.py b/src/bonsai/bonsai/bim/module/material/data.py index 36c93add4f..543a44824b 100644 --- a/src/bonsai/bonsai/bim/module/material/data.py +++ b/src/bonsai/bonsai/bim/module/material/data.py @@ -16,14 +16,12 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import os from typing import Any, Union import bpy import ifcopenshell import ifcopenshell.util.doc import ifcopenshell.util.element -import ifcopenshell.util.schema from natsort import natsorted import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/material/operator.py b/src/bonsai/bonsai/bim/module/material/operator.py index 81ef17e6e4..e0761bf416 100644 --- a/src/bonsai/bonsai/bim/module/material/operator.py +++ b/src/bonsai/bonsai/bim/module/material/operator.py @@ -20,7 +20,6 @@ import json from typing import TYPE_CHECKING, Any, Literal, Union import bpy -import ifcopenshell.api import ifcopenshell.api.material import ifcopenshell.api.profile import ifcopenshell.api.style diff --git a/src/bonsai/bonsai/bim/module/material/prop.py b/src/bonsai/bonsai/bim/module/material/prop.py index 27567ab27e..9c8454f05e 100644 --- a/src/bonsai/bonsai/bim/module/material/prop.py +++ b/src/bonsai/bonsai/bim/module/material/prop.py @@ -19,25 +19,21 @@ from typing import TYPE_CHECKING import bpy -import ifcopenshell from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup -from ifcopenshell.util.doc import get_entity_doc import bonsai.tool as tool from bonsai.bim.module.classification.data import MaterialClassificationsData from bonsai.bim.module.material.data import MaterialsData, ObjectMaterialData from bonsai.bim.module.profile.data import ProfileData -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute def get_profile_classes(self, context): diff --git a/src/bonsai/bonsai/bim/module/material/ui.py b/src/bonsai/bonsai/bim/module/material/ui.py index 2ac1908327..f743306767 100644 --- a/src/bonsai/bonsai/bim/module/material/ui.py +++ b/src/bonsai/bonsai/bim/module/material/ui.py @@ -22,7 +22,6 @@ from typing import TYPE_CHECKING, Any import bpy import ifcopenshell.util.element -import ifcopenshell.util.unit from bpy.types import Panel, UIList import bonsai.bim.helper diff --git a/src/bonsai/bonsai/bim/module/misc/operator.py b/src/bonsai/bonsai/bim/module/misc/operator.py index 33703331f8..02cc56834b 100644 --- a/src/bonsai/bonsai/bim/module/misc/operator.py +++ b/src/bonsai/bonsai/bim/module/misc/operator.py @@ -19,12 +19,11 @@ from typing import TYPE_CHECKING, Literal, assert_never, get_args import bpy -import ifcopenshell import ifcopenshell.util.geolocation import ifcopenshell.util.placement import ifcopenshell.util.unit import numpy as np -from mathutils import Euler, Matrix, Vector +from mathutils import Matrix import bonsai.core.geometry as core_geometry import bonsai.core.misc as core diff --git a/src/bonsai/bonsai/bim/module/misc/prop.py b/src/bonsai/bonsai/bim/module/misc/prop.py index 889e1f5099..f596f22fc6 100644 --- a/src/bonsai/bonsai/bim/module/misc/prop.py +++ b/src/bonsai/bonsai/bim/module/misc/prop.py @@ -16,21 +16,12 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import bpy from bpy.props import ( - BoolProperty, - CollectionProperty, - EnumProperty, - FloatProperty, FloatVectorProperty, IntProperty, - PointerProperty, - StringProperty, ) from bpy.types import PropertyGroup -from bonsai.bim.prop import Attribute, StrProperty - class BIMMiscProperties(PropertyGroup): total_storeys: IntProperty( diff --git a/src/bonsai/bonsai/bim/module/model/array.py b/src/bonsai/bonsai/bim/module/model/array.py index 5f045435ac..dd54bf0ab3 100644 --- a/src/bonsai/bonsai/bim/module/model/array.py +++ b/src/bonsai/bonsai/bim/module/model/array.py @@ -19,12 +19,10 @@ import json import bpy -import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.pset import ifcopenshell.util.element import ifcopenshell.util.unit -from mathutils import Matrix, Vector +from mathutils import Matrix import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/model/covering.py b/src/bonsai/bonsai/bim/module/model/covering.py index 468554b9be..dd3889a7cb 100644 --- a/src/bonsai/bonsai/bim/module/model/covering.py +++ b/src/bonsai/bonsai/bim/module/model/covering.py @@ -18,8 +18,6 @@ import bpy -import ifcopenshell -import ifcopenshell.util.element import bonsai.core.covering as core import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/model/data.py b/src/bonsai/bonsai/bim/module/model/data.py index 0b97e05e77..10553f1bed 100644 --- a/src/bonsai/bonsai/bim/module/model/data.py +++ b/src/bonsai/bonsai/bim/module/model/data.py @@ -25,7 +25,7 @@ import bpy import ifcopenshell import ifcopenshell.util.element import ifcopenshell.util.schema -from ifcopenshell.util.doc import get_entity_doc, get_predefined_type_doc +from ifcopenshell.util.doc import get_entity_doc from natsort import natsorted import bonsai.tool as tool @@ -424,12 +424,12 @@ class SverchokData: return tool.Model.get_modeling_bbim_pset_data(bpy.context.active_object, "BBIM_Sverchok") @classmethod - def has_sverchok(cls): + def has_sverchok(cls) -> bool: try: - import sverchok + import sverchok # noqa: F401 return True - except: + except ModuleNotFoundError: return False diff --git a/src/bonsai/bonsai/bim/module/model/decorator.py b/src/bonsai/bonsai/bim/module/model/decorator.py index f5a1e534da..d4dc1a218d 100644 --- a/src/bonsai/bonsai/bim/module/model/decorator.py +++ b/src/bonsai/bonsai/bim/module/model/decorator.py @@ -19,9 +19,8 @@ from __future__ import annotations import math -from itertools import chain from math import cos, radians, sin, tan -from typing import Any, Literal, Union +from typing import Any, Literal import blf import bmesh @@ -1077,7 +1076,7 @@ class ProductDecorator: data["verts"] = [] # Verts - polyline_vertices = [] + polyline_vertices: list[Vector] = [] polyline_props = tool.Model.get_polyline_props() polyline_data = polyline_props.insertion_polyline polyline_points = polyline_data[0].polyline_points if polyline_data else [] @@ -1197,7 +1196,7 @@ class ProductDecorator: data = {} data["verts"] = [] # Verts - polyline_vertices = [] + polyline_vertices: list[Vector] = [] polyline_props = tool.Model.get_polyline_props() polyline_data = polyline_props.insertion_polyline polyline_points = polyline_data[0].polyline_points if polyline_data else [] diff --git a/src/bonsai/bonsai/bim/module/model/door.py b/src/bonsai/bonsai/bim/module/model/door.py index dbdf5e8dcf..5a14cde101 100644 --- a/src/bonsai/bonsai/bim/module/model/door.py +++ b/src/bonsai/bonsai/bim/module/model/door.py @@ -17,21 +17,18 @@ # along with Bonsai. If not, see . -import collections import collections.abc import json -from typing import TYPE_CHECKING, get_args +from typing import TYPE_CHECKING import bmesh import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.geometry import ifcopenshell.api.material import ifcopenshell.api.pset import ifcopenshell.util.element import ifcopenshell.util.representation -import ifcopenshell.util.schema import ifcopenshell.util.unit from mathutils import Matrix, Vector diff --git a/src/bonsai/bonsai/bim/module/model/grid.py b/src/bonsai/bonsai/bim/module/model/grid.py index df4f140ebc..8ceaa605dc 100644 --- a/src/bonsai/bonsai/bim/module/model/grid.py +++ b/src/bonsai/bonsai/bim/module/model/grid.py @@ -19,7 +19,6 @@ from typing import TYPE_CHECKING import bpy -import ifcopenshell.api import ifcopenshell.api.grid from bpy.props import FloatProperty, IntProperty from bpy.types import Operator diff --git a/src/bonsai/bonsai/bim/module/model/handler.py b/src/bonsai/bonsai/bim/module/model/handler.py index 47075cdcfa..bfa064cda7 100644 --- a/src/bonsai/bonsai/bim/module/model/handler.py +++ b/src/bonsai/bonsai/bim/module/model/handler.py @@ -16,12 +16,10 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import bpy -import ifcopenshell import ifcopenshell.api from bpy.app.handlers import persistent -from bonsai.bim.module.model import opening, product, profile, slab, task, wall +from bonsai.bim.module.model import opening, product, profile, task @persistent diff --git a/src/bonsai/bonsai/bim/module/model/mep.py b/src/bonsai/bonsai/bim/module/model/mep.py index cdb2538d28..245e10a21b 100644 --- a/src/bonsai/bonsai/bim/module/model/mep.py +++ b/src/bonsai/bonsai/bim/module/model/mep.py @@ -16,18 +16,13 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import collections import collections.abc import json -import math import re from copy import copy -from math import asin, cos, degrees, pi, radians, sin, tan +from math import cos, degrees, pi, radians, sin, tan -import bmesh import bpy -import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.geometry import ifcopenshell.api.material import ifcopenshell.api.pset @@ -41,9 +36,7 @@ import numpy as np from ifcopenshell.util.shape_builder import ShapeBuilder from mathutils import Matrix, Vector -import bonsai.core.geometry import bonsai.core.root -import bonsai.core.type import bonsai.tool as tool from bonsai.bim.module.model.profile import DumbProfileJoiner from bonsai.tool.cad import VTX_PRECISION diff --git a/src/bonsai/bonsai/bim/module/model/opening.py b/src/bonsai/bonsai/bim/module/model/opening.py index b0806ec33d..c20325c2e7 100644 --- a/src/bonsai/bonsai/bim/module/model/opening.py +++ b/src/bonsai/bonsai/bim/module/model/opening.py @@ -16,37 +16,29 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import json -import logging -from collections import defaultdict from collections.abc import Sequence -from math import pi, radians -from typing import Any, Optional, Union, cast +from math import radians +from typing import Any, Optional, Union import bmesh import bpy import gpu import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.feature import ifcopenshell.api.geometry import ifcopenshell.api.root import ifcopenshell.geom import ifcopenshell.util.element -import ifcopenshell.util.placement import ifcopenshell.util.representation import ifcopenshell.util.shape import ifcopenshell.util.shape_builder import ifcopenshell.util.unit import numpy as np import shapely -from bpy.props import FloatProperty from bpy.types import Operator, SpaceView3D -from bpy_extras.object_utils import AddObjectHelper, object_data_add from gpu_extras.batch import batch_for_shader -from mathutils import Euler, Matrix, Vector +from mathutils import Matrix, Vector -import bonsai.bim.import_ifc as import_ifc import bonsai.core.geometry import bonsai.tool as tool from bonsai.bim.module.drawing.decoration import DecoratorData diff --git a/src/bonsai/bonsai/bim/module/model/polyline.py b/src/bonsai/bonsai/bim/module/model/polyline.py index 92ec36581b..e33fe2cf5d 100644 --- a/src/bonsai/bonsai/bim/module/model/polyline.py +++ b/src/bonsai/bonsai/bim/module/model/polyline.py @@ -18,28 +18,13 @@ from __future__ import annotations -import copy -import math -from typing import Any, Literal, Optional, Union +from typing import Literal, Union -import bmesh import bpy import ifcopenshell -import ifcopenshell.api -import ifcopenshell.geom -import ifcopenshell.util.element -import ifcopenshell.util.placement -import ifcopenshell.util.representation -import ifcopenshell.util.type import ifcopenshell.util.unit -import mathutils.geometry -from lark import Lark, Transformer from mathutils import Vector -import bonsai.core.geometry -import bonsai.core.model as core -import bonsai.core.root -import bonsai.core.type import bonsai.tool as tool from bonsai.bim.module.model.decorator import PolylineDecorator diff --git a/src/bonsai/bonsai/bim/module/model/product.py b/src/bonsai/bonsai/bim/module/model/product.py index 012cba4889..d7c96bce1d 100644 --- a/src/bonsai/bonsai/bim/module/model/product.py +++ b/src/bonsai/bonsai/bim/module/model/product.py @@ -19,12 +19,11 @@ # pyright: reportUnnecessaryTypeIgnoreComment=error import json -from typing import TYPE_CHECKING, Any, Literal, Optional, Union, assert_never, get_args +from typing import TYPE_CHECKING, Any, Literal, get_args import bmesh import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.geometry import ifcopenshell.api.system import ifcopenshell.util.element @@ -34,8 +33,6 @@ import ifcopenshell.util.shape_builder import ifcopenshell.util.system import ifcopenshell.util.type import ifcopenshell.util.unit -import mathutils -import numpy as np from bpy_extras.object_utils import AddObjectHelper from mathutils import Matrix, Vector diff --git a/src/bonsai/bonsai/bim/module/model/profile.py b/src/bonsai/bonsai/bim/module/model/profile.py index 4e16f9b296..f759d40a94 100644 --- a/src/bonsai/bonsai/bim/module/model/profile.py +++ b/src/bonsai/bonsai/bim/module/model/profile.py @@ -20,10 +20,8 @@ import copy from math import atan2, degrees, pi, radians from typing import Any, Literal, Optional, Union -import bmesh import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.geometry import ifcopenshell.api.pset import ifcopenshell.api.type @@ -38,7 +36,6 @@ from mathutils import Matrix, Vector import bonsai.core.geometry import bonsai.core.material import bonsai.core.root -import bonsai.core.type import bonsai.tool as tool from bonsai.bim.ifc import IfcStore from bonsai.bim.module.model.decorator import ( diff --git a/src/bonsai/bonsai/bim/module/model/prop.py b/src/bonsai/bonsai/bim/module/model/prop.py index ec79a49196..cb246ac7c5 100644 --- a/src/bonsai/bonsai/bim/module/model/prop.py +++ b/src/bonsai/bonsai/bim/module/model/prop.py @@ -22,7 +22,6 @@ from math import pi, radians from typing import TYPE_CHECKING, Any, Literal, Optional, Union, get_args import bpy -import ifcopenshell import ifcopenshell.util.element from bpy.types import NodeTree, PropertyGroup from mathutils import Vector diff --git a/src/bonsai/bonsai/bim/module/model/railing.py b/src/bonsai/bonsai/bim/module/model/railing.py index 624b1b64a7..7ca66d8dbc 100644 --- a/src/bonsai/bonsai/bim/module/model/railing.py +++ b/src/bonsai/bonsai/bim/module/model/railing.py @@ -23,7 +23,6 @@ from typing import Any import bmesh import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.geometry import ifcopenshell.api.pset import ifcopenshell.util.representation diff --git a/src/bonsai/bonsai/bim/module/model/roof.py b/src/bonsai/bonsai/bim/module/model/roof.py index 4038faa993..e1f7903299 100644 --- a/src/bonsai/bonsai/bim/module/model/roof.py +++ b/src/bonsai/bonsai/bim/module/model/roof.py @@ -23,14 +23,12 @@ from typing import Any, Literal, Union import bmesh import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.pset import ifcopenshell.util.representation import ifcopenshell.util.unit -import mathutils.geometry import shapely from bpypolyskel import bpypolyskel -from mathutils import Matrix, Quaternion, Vector +from mathutils import Quaternion, Vector import bonsai.core.root import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/model/slab.py b/src/bonsai/bonsai/bim/module/model/slab.py index 602c36df11..58a353ab28 100644 --- a/src/bonsai/bonsai/bim/module/model/slab.py +++ b/src/bonsai/bonsai/bim/module/model/slab.py @@ -17,13 +17,10 @@ # along with Bonsai. If not, see . import json -from math import acos, cos, degrees, pi, sin -from typing import Optional +from math import cos, pi -import bmesh import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.geometry import ifcopenshell.api.material import ifcopenshell.api.pset @@ -37,7 +34,6 @@ from mathutils import Matrix, Vector import bonsai.core.geometry import bonsai.core.root -import bonsai.core.type import bonsai.tool as tool from bonsai.bim.ifc import IfcStore from bonsai.bim.module.model.decorator import ( diff --git a/src/bonsai/bonsai/bim/module/model/stair.py b/src/bonsai/bonsai/bim/module/model/stair.py index 5b52308542..87152c645b 100644 --- a/src/bonsai/bonsai/bim/module/model/stair.py +++ b/src/bonsai/bonsai/bim/module/model/stair.py @@ -23,7 +23,6 @@ import bpy import ifcopenshell import ifcopenshell.api.pset import ifcopenshell.util.element -import ifcopenshell.util.representation import ifcopenshell.util.unit from mathutils import Matrix, Vector @@ -38,7 +37,7 @@ from bonsai.tool.numeric_input import ( ) V_ = tool.Blender.V_ -from typing import TYPE_CHECKING, get_args +from typing import TYPE_CHECKING from bmesh.types import BMVert from bpy.props import IntProperty diff --git a/src/bonsai/bonsai/bim/module/model/sverchok_modifier.py b/src/bonsai/bonsai/bim/module/model/sverchok_modifier.py index 0a318b1fb1..08f29890c4 100644 --- a/src/bonsai/bonsai/bim/module/model/sverchok_modifier.py +++ b/src/bonsai/bonsai/bim/module/model/sverchok_modifier.py @@ -22,7 +22,6 @@ import zipfile import bmesh import bpy -import ifcopenshell import ifcopenshell.api.pset import ifcopenshell.util.element from bpy_extras.io_utils import ExportHelper, ImportHelper diff --git a/src/bonsai/bonsai/bim/module/model/task.py b/src/bonsai/bonsai/bim/module/model/task.py index 93a361b73c..a6fe2607a2 100644 --- a/src/bonsai/bonsai/bim/module/model/task.py +++ b/src/bonsai/bonsai/bim/module/model/task.py @@ -17,7 +17,6 @@ # along with Bonsai. If not, see . import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.pset import ifcopenshell.util.date diff --git a/src/bonsai/bonsai/bim/module/model/ui.py b/src/bonsai/bonsai/bim/module/model/ui.py index d8a297433b..512eaf3fdf 100644 --- a/src/bonsai/bonsai/bim/module/model/ui.py +++ b/src/bonsai/bonsai/bim/module/model/ui.py @@ -22,11 +22,10 @@ from collections.abc import Iterable from typing import TYPE_CHECKING, Any import bpy -from bpy.types import Menu, Panel +from bpy.types import Panel import bonsai.bim import bonsai.tool as tool -from bonsai.bim import module from bonsai.bim.helper import prop_with_search from bonsai.bim.module.model.data import ( ArrayData, diff --git a/src/bonsai/bonsai/bim/module/model/wall.py b/src/bonsai/bonsai/bim/module/model/wall.py index 7f4579df31..441566e3e6 100644 --- a/src/bonsai/bonsai/bim/module/model/wall.py +++ b/src/bonsai/bonsai/bim/module/model/wall.py @@ -20,12 +20,11 @@ import copy import math -from math import acos, atan2, cos, degrees, pi, sin -from typing import TYPE_CHECKING, Any, Literal, Optional, Union, assert_never, get_args +from math import atan2, cos, degrees, pi, sin +from typing import TYPE_CHECKING, Any, Literal, Union, get_args import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.feature import ifcopenshell.api.geometry import ifcopenshell.api.material @@ -45,11 +44,9 @@ from mathutils import Matrix, Vector import bonsai.core.geometry import bonsai.core.model as core import bonsai.core.root -import bonsai.core.type import bonsai.tool as tool from bonsai.bim.ifc import IfcStore from bonsai.bim.module.model.decorator import PolylineDecorator, ProductDecorator -from bonsai.bim.module.model.opening import FilledOpeningGenerator from bonsai.bim.module.model.polyline import PolylineOperator diff --git a/src/bonsai/bonsai/bim/module/model/window.py b/src/bonsai/bonsai/bim/module/model/window.py index ad473a110e..30e8d767b5 100644 --- a/src/bonsai/bonsai/bim/module/model/window.py +++ b/src/bonsai/bonsai/bim/module/model/window.py @@ -17,21 +17,18 @@ # along with Bonsai. If not, see . -import collections import collections.abc import json -from typing import TYPE_CHECKING, get_args +from typing import TYPE_CHECKING import bmesh import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.geometry import ifcopenshell.api.material import ifcopenshell.api.pset import ifcopenshell.util.element import ifcopenshell.util.representation -import ifcopenshell.util.shape_builder import ifcopenshell.util.unit from bmesh.types import BMVert from ifcopenshell.api.geometry.add_window_representation import DEFAULT_PANEL_SCHEMAS diff --git a/src/bonsai/bonsai/bim/module/model/workspace.py b/src/bonsai/bonsai/bim/module/model/workspace.py index 7b7a91906d..5f7cf7699d 100644 --- a/src/bonsai/bonsai/bim/module/model/workspace.py +++ b/src/bonsai/bonsai/bim/module/model/workspace.py @@ -17,15 +17,13 @@ # along with Bonsai. If not, see . import os -import sys from functools import partial -from typing import Any, Optional, Union +from typing import Optional, Union import bpy import bpy.utils.previews from bpy.types import Menu, WorkSpaceTool -import bonsai.bim import bonsai.core.model as core import bonsai.tool as tool from bonsai.bim.helper import draw_attribute, prop_with_search diff --git a/src/bonsai/bonsai/bim/module/nest/decorator.py b/src/bonsai/bonsai/bim/module/nest/decorator.py index e9630ebc26..66608b0171 100644 --- a/src/bonsai/bonsai/bim/module/nest/decorator.py +++ b/src/bonsai/bonsai/bim/module/nest/decorator.py @@ -19,7 +19,6 @@ import blf import bpy import gpu -import ifcopenshell import ifcopenshell.util.element from bpy.types import SpaceView3D from bpy_extras import view3d_utils @@ -27,7 +26,6 @@ from gpu_extras.batch import batch_for_shader from mathutils import Vector import bonsai.tool as tool -from bonsai.bim.module.geometry.decorator import ItemDecorator def transparent_color(color, alpha=0.1): diff --git a/src/bonsai/bonsai/bim/module/nest/operator.py b/src/bonsai/bonsai/bim/module/nest/operator.py index 9d7eb2df67..6961fea0c8 100644 --- a/src/bonsai/bonsai/bim/module/nest/operator.py +++ b/src/bonsai/bonsai/bim/module/nest/operator.py @@ -17,7 +17,6 @@ # along with Bonsai. If not, see . import bpy -import ifcopenshell import ifcopenshell.util.element import bonsai.core.nest as core diff --git a/src/bonsai/bonsai/bim/module/nest/prop.py b/src/bonsai/bonsai/bim/module/nest/prop.py index c36388398c..4c7533455a 100644 --- a/src/bonsai/bonsai/bim/module/nest/prop.py +++ b/src/bonsai/bonsai/bim/module/nest/prop.py @@ -22,19 +22,12 @@ import bpy from bpy.props import ( BoolProperty, CollectionProperty, - EnumProperty, - FloatProperty, - FloatVectorProperty, - IntProperty, PointerProperty, - StringProperty, ) from bpy.types import PropertyGroup import bonsai.tool as tool from bonsai.bim.module.nest.decorator import NestDecorator, NestModeDecorator -from bonsai.bim.module.spatial.data import SpatialData -from bonsai.bim.prop import Attribute, StrProperty def update_relating_object(self: "BIMObjectNestProperties", context: bpy.types.Context) -> None: diff --git a/src/bonsai/bonsai/bim/module/owner/prop.py b/src/bonsai/bonsai/bim/module/owner/prop.py index dfe2b95ecd..171712e799 100644 --- a/src/bonsai/bonsai/bim/module/owner/prop.py +++ b/src/bonsai/bonsai/bim/module/owner/prop.py @@ -20,14 +20,9 @@ from typing import TYPE_CHECKING, Literal import bpy from bpy.props import ( - BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, - StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/module/patch/operator.py b/src/bonsai/bonsai/bim/module/patch/operator.py index 57413214d6..99459b99e9 100644 --- a/src/bonsai/bonsai/bim/module/patch/operator.py +++ b/src/bonsai/bonsai/bim/module/patch/operator.py @@ -17,7 +17,6 @@ # along with Bonsai. If not, see . import json -import os from pathlib import Path from typing import TYPE_CHECKING, cast diff --git a/src/bonsai/bonsai/bim/module/patch/prop.py b/src/bonsai/bonsai/bim/module/patch/prop.py index 9382b4e786..e14bb3b1ef 100644 --- a/src/bonsai/bonsai/bim/module/patch/prop.py +++ b/src/bonsai/bonsai/bim/module/patch/prop.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import importlib import importlib.util from pathlib import Path from typing import TYPE_CHECKING, Literal, Union @@ -27,15 +26,11 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, - IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute ifcpatchrecipes_enum: list[tuple[str, str, str]] = [] diff --git a/src/bonsai/bonsai/bim/module/profile/data.py b/src/bonsai/bonsai/bim/module/profile/data.py index 34ea4d1b7b..09f8eaf383 100644 --- a/src/bonsai/bonsai/bim/module/profile/data.py +++ b/src/bonsai/bonsai/bim/module/profile/data.py @@ -19,7 +19,6 @@ from typing import Any import bpy -import bpy.utils import bpy.utils.previews import ifcopenshell.util.doc diff --git a/src/bonsai/bonsai/bim/module/profile/operator.py b/src/bonsai/bonsai/bim/module/profile/operator.py index 871d8f3b86..42a37989a0 100644 --- a/src/bonsai/bonsai/bim/module/profile/operator.py +++ b/src/bonsai/bonsai/bim/module/profile/operator.py @@ -23,7 +23,6 @@ import ifcopenshell.util.element import bonsai.bim.helper import bonsai.bim.module.model.profile as model_profile -import bonsai.core.profile as core import bonsai.tool as tool from bonsai.bim.module.geometry.helper import Helper from bonsai.bim.module.model.decorator import ProfileDecorator diff --git a/src/bonsai/bonsai/bim/module/profile/prop.py b/src/bonsai/bonsai/bim/module/profile/prop.py index 61e2546193..3a4a71650e 100644 --- a/src/bonsai/bonsai/bim/module/profile/prop.py +++ b/src/bonsai/bonsai/bim/module/profile/prop.py @@ -19,15 +19,10 @@ from typing import TYPE_CHECKING, Union import bpy -import ifcopenshell -import ifcopenshell.util.attribute -import ifcopenshell.util.schema from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, PointerProperty, StringProperty, @@ -36,7 +31,7 @@ from bpy.types import PropertyGroup import bonsai.tool as tool from bonsai.bim.module.profile.data import ProfileData -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute def get_profile_classes(self: "BIMProfileProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]: diff --git a/src/bonsai/bonsai/bim/module/project/data.py b/src/bonsai/bonsai/bim/module/project/data.py index e2e960b382..56a77d1880 100644 --- a/src/bonsai/bonsai/bim/module/project/data.py +++ b/src/bonsai/bonsai/bim/module/project/data.py @@ -16,12 +16,10 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import os from collections import defaultdict from pathlib import Path from typing import Any, Union -import bpy import ifcopenshell.util.file import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/project/decorator.py b/src/bonsai/bonsai/bim/module/project/decorator.py index 14035ca91c..8c2ec0e08b 100644 --- a/src/bonsai/bonsai/bim/module/project/decorator.py +++ b/src/bonsai/bonsai/bim/module/project/decorator.py @@ -18,13 +18,11 @@ from typing import Union -import blf import bmesh import bpy import gpu from bpy.app.handlers import persistent from bpy.types import SpaceView3D -from bpy_extras import view3d_utils from gpu_extras.batch import batch_for_shader from mathutils import Vector diff --git a/src/bonsai/bonsai/bim/module/project/gizmo.py b/src/bonsai/bonsai/bim/module/project/gizmo.py index d91668eaa8..fa8edb8c7e 100644 --- a/src/bonsai/bonsai/bim/module/project/gizmo.py +++ b/src/bonsai/bonsai/bim/module/project/gizmo.py @@ -17,7 +17,6 @@ # along with Bonsai. If not, see . -import bpy from bpy.types import GizmoGroup from mathutils import Matrix diff --git a/src/bonsai/bonsai/bim/module/project/operator.py b/src/bonsai/bonsai/bim/module/project/operator.py index 43588584bd..7bffc724e5 100644 --- a/src/bonsai/bonsai/bim/module/project/operator.py +++ b/src/bonsai/bonsai/bim/module/project/operator.py @@ -18,7 +18,6 @@ import datetime import json -import math import logging import os import subprocess @@ -32,7 +31,6 @@ from typing import TYPE_CHECKING, Literal, Union, get_args import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.attribute import ifcopenshell.api.nest import ifcopenshell.api.project @@ -50,12 +48,10 @@ import ifcopenshell.util.unit import numpy as np from bpy.app.handlers import persistent from bpy_extras.io_utils import ExportHelper, ImportHelper -from ifcopenshell.geom import ShapeElementType from mathutils import Matrix, Vector import bonsai.bim.handler import bonsai.bim.helper -import bonsai.bim.schema import bonsai.core.project as core import bonsai.tool as tool from bonsai.bim import export_ifc, import_ifc @@ -63,12 +59,11 @@ from bonsai.bim.ifc import IfcStore from bonsai.bim.ui import IFCFileSelector from bonsai.bim import import_ifc from bonsai.bim import export_ifc -from math import radians, degrees +from math import radians from pathlib import Path from collections import defaultdict from mathutils import Vector, Matrix from bpy.app.handlers import persistent -from ifcopenshell.geom import ShapeElementType from bonsai.bim.module.model.decorator import FaceAreaDecorator, PolylineDecorator from bonsai.bim.module.model.polyline import PolylineOperator from bonsai.bim.module.project.data import LinksData, ProjectLibraryData diff --git a/src/bonsai/bonsai/bim/module/project/prop.py b/src/bonsai/bonsai/bim/module/project/prop.py index a34b5726f7..57b153428b 100644 --- a/src/bonsai/bonsai/bim/module/project/prop.py +++ b/src/bonsai/bonsai/bim/module/project/prop.py @@ -16,9 +16,7 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import math from collections.abc import Generator -from pathlib import Path from typing import TYPE_CHECKING, Literal, Union, assert_never, get_args import bpy @@ -39,7 +37,7 @@ import bonsai.bim.helper import bonsai.tool as tool from bonsai.bim.ifc import IfcStore from bonsai.bim.module.project.data import ProjectData, ProjectLibraryData -from bonsai.bim.prop import Attribute, ObjProperty, StrProperty +from bonsai.bim.prop import Attribute, ObjProperty def get_export_schema(self: "BIMProjectProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]: diff --git a/src/bonsai/bonsai/bim/module/project/ui.py b/src/bonsai/bonsai/bim/module/project/ui.py index 1836500c54..7029eb7227 100644 --- a/src/bonsai/bonsai/bim/module/project/ui.py +++ b/src/bonsai/bonsai/bim/module/project/ui.py @@ -22,8 +22,6 @@ import os from typing import TYPE_CHECKING import bpy -import math -import ifcopenshell from bpy.types import Menu, Panel, UIList import bonsai.bim diff --git a/src/bonsai/bonsai/bim/module/project/workspace.py b/src/bonsai/bonsai/bim/module/project/workspace.py index a72981c625..dca65f72e6 100644 --- a/src/bonsai/bonsai/bim/module/project/workspace.py +++ b/src/bonsai/bonsai/bim/module/project/workspace.py @@ -19,7 +19,6 @@ import os import bpy -from bpy.types import WorkSpaceTool import bonsai.tool as tool from bonsai.bim.module.project.data import LinksData diff --git a/src/bonsai/bonsai/bim/module/pset/operator.py b/src/bonsai/bonsai/bim/module/pset/operator.py index 3257760531..d7755cf80a 100644 --- a/src/bonsai/bonsai/bim/module/pset/operator.py +++ b/src/bonsai/bonsai/bim/module/pset/operator.py @@ -32,7 +32,7 @@ import bonsai.tool as tool from bonsai.bim.ifc import IfcStore if TYPE_CHECKING: - from bonsai.bim.module.pset.prop import AddEditPropertyEntry, RenamePropertyEntry + from bonsai.bim.module.pset.prop import AddEditPropertyEntry class TogglePsetExpansion(bpy.types.Operator, tool.Ifc.Operator): diff --git a/src/bonsai/bonsai/bim/module/pset/prop.py b/src/bonsai/bonsai/bim/module/pset/prop.py index 4b16e15010..1777fa0f94 100644 --- a/src/bonsai/bonsai/bim/module/pset/prop.py +++ b/src/bonsai/bonsai/bim/module/pset/prop.py @@ -22,13 +22,11 @@ import bpy import ifcopenshell import ifcopenshell.util.attribute import ifcopenshell.util.doc -import ifcopenshell.util.element from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, FloatProperty, - FloatVectorProperty, IntProperty, PointerProperty, StringProperty, @@ -44,7 +42,7 @@ from bonsai.bim.module.pset.data import ( ObjectPsetsData, PsetsGeneralData, ) -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute psetnames = {} qtonames = {} diff --git a/src/bonsai/bonsai/bim/module/pset_template/data.py b/src/bonsai/bonsai/bim/module/pset_template/data.py index 1725b974f1..0d922fe2ae 100644 --- a/src/bonsai/bonsai/bim/module/pset_template/data.py +++ b/src/bonsai/bonsai/bim/module/pset_template/data.py @@ -16,11 +16,8 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import os -import pathlib from typing import Any -import bpy import ifcopenshell import ifcopenshell.util.attribute import ifcopenshell.util.doc diff --git a/src/bonsai/bonsai/bim/module/pset_template/operator.py b/src/bonsai/bonsai/bim/module/pset_template/operator.py index e956917df3..0ae20ce0ea 100644 --- a/src/bonsai/bonsai/bim/module/pset_template/operator.py +++ b/src/bonsai/bonsai/bim/module/pset_template/operator.py @@ -20,7 +20,6 @@ import os import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.pset_template import bonsai.bim.handler diff --git a/src/bonsai/bonsai/bim/module/pset_template/prop.py b/src/bonsai/bonsai/bim/module/pset_template/prop.py index 9ec31b364f..3b2d6c5d9e 100644 --- a/src/bonsai/bonsai/bim/module/pset_template/prop.py +++ b/src/bonsai/bonsai/bim/module/pset_template/prop.py @@ -16,18 +16,15 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import os from typing import TYPE_CHECKING import bpy -import ifcopenshell import ifcopenshell.util.attribute from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, FloatProperty, - FloatVectorProperty, IntProperty, PointerProperty, StringProperty, @@ -38,7 +35,6 @@ from ifcopenshell.util.doc import get_attribute_doc import bonsai.tool as tool from bonsai.bim.ifc import IfcStore from bonsai.bim.module.pset_template.data import PsetTemplatesData -from bonsai.bim.prop import Attribute, StrProperty def updatePsetTemplateFiles(self, context): diff --git a/src/bonsai/bonsai/bim/module/pset_template/ui.py b/src/bonsai/bonsai/bim/module/pset_template/ui.py index 6576e8f56c..92cd78e4ba 100644 --- a/src/bonsai/bonsai/bim/module/pset_template/ui.py +++ b/src/bonsai/bonsai/bim/module/pset_template/ui.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import bpy from bpy.types import Panel import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/qto/operator.py b/src/bonsai/bonsai/bim/module/qto/operator.py index 572c65e258..6aa10c9beb 100644 --- a/src/bonsai/bonsai/bim/module/qto/operator.py +++ b/src/bonsai/bonsai/bim/module/qto/operator.py @@ -18,7 +18,6 @@ import bpy import ifcopenshell -import ifcopenshell.api from ifcopenshell.util.profiler import Profiler import bonsai.core.qto as core diff --git a/src/bonsai/bonsai/bim/module/qto/prop.py b/src/bonsai/bonsai/bim/module/qto/prop.py index 9952285d30..7ffbfcdfa7 100644 --- a/src/bonsai/bonsai/bim/module/qto/prop.py +++ b/src/bonsai/bonsai/bim/module/qto/prop.py @@ -22,18 +22,12 @@ import bpy import ifc5d.qto from bpy.props import ( BoolProperty, - CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, - IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup import bonsai.tool as tool -from bonsai.bim.prop import Attribute, StrProperty CALCULATOR_FUNCTION_ENUM_ITEMS: list[Union[tuple[str, str, str], None]] = [] diff --git a/src/bonsai/bonsai/bim/module/resource/prop.py b/src/bonsai/bonsai/bim/module/resource/prop.py index 4c6828e56c..9f2c5ba85c 100644 --- a/src/bonsai/bonsai/bim/module/resource/prop.py +++ b/src/bonsai/bonsai/bim/module/resource/prop.py @@ -19,7 +19,6 @@ from typing import TYPE_CHECKING, Literal, get_args import bpy -import ifcopenshell.api import ifcopenshell.api.resource import ifcopenshell.util.resource from bpy.props import ( @@ -27,9 +26,7 @@ from bpy.props import ( CollectionProperty, EnumProperty, FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/module/root/data.py b/src/bonsai/bonsai/bim/module/root/data.py index 7adf7b5fb9..c1988c8b82 100644 --- a/src/bonsai/bonsai/bim/module/root/data.py +++ b/src/bonsai/bonsai/bim/module/root/data.py @@ -19,7 +19,6 @@ from collections import defaultdict from typing import Union -import bpy import ifcopenshell.util.attribute import ifcopenshell.util.element import ifcopenshell.util.schema diff --git a/src/bonsai/bonsai/bim/module/root/operator.py b/src/bonsai/bonsai/bim/module/root/operator.py index ac766172bd..159f157d44 100644 --- a/src/bonsai/bonsai/bim/module/root/operator.py +++ b/src/bonsai/bonsai/bim/module/root/operator.py @@ -22,7 +22,6 @@ import bmesh import bpy import idprop import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.geometry import ifcopenshell.api.material import ifcopenshell.api.pset @@ -34,7 +33,6 @@ import ifcopenshell.util.type import ifcopenshell.util.unit from mathutils import Vector -import bonsai.bim.handler import bonsai.bim.module.root.prop as root_prop import bonsai.core.geometry import bonsai.core.root as core diff --git a/src/bonsai/bonsai/bim/module/root/prop.py b/src/bonsai/bonsai/bim/module/root/prop.py index 854eb6d0f0..35b7b9f403 100644 --- a/src/bonsai/bonsai/bim/module/root/prop.py +++ b/src/bonsai/bonsai/bim/module/root/prop.py @@ -19,17 +19,10 @@ from typing import TYPE_CHECKING, Union import bpy -import ifcopenshell import ifcopenshell.util.element -import ifcopenshell.util.schema import ifcopenshell.util.type from bpy.props import ( - BoolProperty, - CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, - IntProperty, PointerProperty, StringProperty, ) diff --git a/src/bonsai/bonsai/bim/module/root/ui.py b/src/bonsai/bonsai/bim/module/root/ui.py index 72eadb4e39..f9eae350e4 100644 --- a/src/bonsai/bonsai/bim/module/root/ui.py +++ b/src/bonsai/bonsai/bim/module/root/ui.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import bpy from bpy.types import Panel import bonsai.bim.module.root.prop as root_prop diff --git a/src/bonsai/bonsai/bim/module/search/operator.py b/src/bonsai/bonsai/bim/module/search/operator.py index 83f401a122..b7ba62acdb 100644 --- a/src/bonsai/bonsai/bim/module/search/operator.py +++ b/src/bonsai/bonsai/bim/module/search/operator.py @@ -19,11 +19,10 @@ import bisect import json import traceback -from typing import TYPE_CHECKING, Literal, assert_never, get_args +from typing import TYPE_CHECKING, Any, Literal, assert_never, get_args import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.group import ifcopenshell.util.element import ifcopenshell.util.selector @@ -31,13 +30,10 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) -from bpy.types import Operator, PropertyGroup +from bpy.types import Operator from natsort import natsorted import bonsai.core.search as core @@ -695,9 +691,9 @@ class EditFilterQuery(Operator, tool.Ifc.Operator): filter_groups = tool.Search.get_filter_groups(module) if tool.Blender.get_addon_preferences().chain_filter_with_set_operations: - filter_structure = [] + filter_structure: list[list[dict[str, Any]]] = [] for filter_group in filter_groups: - group_data = [] + group_data: list[dict[str, Any]] = [] for ifc_filter in filter_group.filters: filter_data = { "type": ifc_filter.type, @@ -852,9 +848,9 @@ class SaveSearch(Operator, tool.Ifc.Operator): query = tool.Search.export_filter_query(filter_groups) results = tool.Search.execute_filter_groups(filter_groups) - filter_structure = [] + filter_structure: list[list[dict[str, Any]]] = [] for filter_group in filter_groups: - group_data = [] + group_data: list[dict[str, Any]] = [] for ifc_filter in filter_group.filters: filter_data = { "type": ifc_filter.type, diff --git a/src/bonsai/bonsai/bim/module/search/prop.py b/src/bonsai/bonsai/bim/module/search/prop.py index e3403b5abe..0f45112420 100644 --- a/src/bonsai/bonsai/bim/module/search/prop.py +++ b/src/bonsai/bonsai/bim/module/search/prop.py @@ -19,7 +19,6 @@ from typing import TYPE_CHECKING, Literal, get_args import bpy -import ifcopenshell.util.schema from bpy.props import ( BoolProperty, CollectionProperty, @@ -27,7 +26,6 @@ from bpy.props import ( FloatProperty, FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup @@ -40,8 +38,6 @@ from bonsai.bim.module.search.data import ( ) from bonsai.bim.prop import BIMFilterGroup, ObjProperty -from . import operator, prop, ui - def get_element_key(self: "BIMSearchProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]: if not SelectSimilarData.is_loaded: diff --git a/src/bonsai/bonsai/bim/module/sequence/data.py b/src/bonsai/bonsai/bim/module/sequence/data.py index 7ea6050ca3..20027281eb 100644 --- a/src/bonsai/bonsai/bim/module/sequence/data.py +++ b/src/bonsai/bonsai/bim/module/sequence/data.py @@ -20,7 +20,6 @@ import json from typing import Any import bpy -import ifcopenshell import ifcopenshell.util.attribute import ifcopenshell.util.date from ifcopenshell.util.doc import get_predefined_type_doc diff --git a/src/bonsai/bonsai/bim/module/sequence/helper.py b/src/bonsai/bonsai/bim/module/sequence/helper.py index 50d2367144..9e16e38402 100644 --- a/src/bonsai/bonsai/bim/module/sequence/helper.py +++ b/src/bonsai/bonsai/bim/module/sequence/helper.py @@ -23,7 +23,6 @@ from typing import Any, Union import bpy import ifcopenshell.util.date -import isodate from dateutil import parser from bonsai.bim.prop import ISODuration diff --git a/src/bonsai/bonsai/bim/module/sequence/prop.py b/src/bonsai/bonsai/bim/module/sequence/prop.py index 6a5937ac45..abb1aa9f0c 100644 --- a/src/bonsai/bonsai/bim/module/sequence/prop.py +++ b/src/bonsai/bonsai/bim/module/sequence/prop.py @@ -16,14 +16,11 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -from typing import TYPE_CHECKING, Literal, Union, get_args +from typing import TYPE_CHECKING, Literal, get_args import bpy -import ifcopenshell.api import ifcopenshell.api.sequence -import ifcopenshell.util.attribute import ifcopenshell.util.date -import isodate from bpy.props import ( BoolProperty, CollectionProperty, @@ -31,7 +28,6 @@ from bpy.props import ( FloatProperty, FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/module/sequence/ui.py b/src/bonsai/bonsai/bim/module/sequence/ui.py index 0ecd772276..f758e89ef5 100644 --- a/src/bonsai/bonsai/bim/module/sequence/ui.py +++ b/src/bonsai/bonsai/bim/module/sequence/ui.py @@ -19,7 +19,6 @@ from typing import TYPE_CHECKING, Any, Optional import bpy -import ifcopenshell import isodate from bpy.types import Panel, UIList diff --git a/src/bonsai/bonsai/bim/module/spatial/decorator.py b/src/bonsai/bonsai/bim/module/spatial/decorator.py index 8d66d4e8a6..047a9ff555 100644 --- a/src/bonsai/bonsai/bim/module/spatial/decorator.py +++ b/src/bonsai/bonsai/bim/module/spatial/decorator.py @@ -17,7 +17,6 @@ # along with Bonsai. If not, see . import blf -import bmesh import gpu from bpy.types import SpaceView3D from bpy_extras.view3d_utils import location_3d_to_region_2d diff --git a/src/bonsai/bonsai/bim/module/spatial/prop.py b/src/bonsai/bonsai/bim/module/spatial/prop.py index 3d3d2e74f4..b0d393b265 100644 --- a/src/bonsai/bonsai/bim/module/spatial/prop.py +++ b/src/bonsai/bonsai/bim/module/spatial/prop.py @@ -19,15 +19,11 @@ from typing import TYPE_CHECKING, Literal, Union import bpy -import ifcopenshell import ifcopenshell.api.attribute -import ifcopenshell.util.unit from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, PointerProperty, StringProperty, diff --git a/src/bonsai/bonsai/bim/module/structural/operator.py b/src/bonsai/bonsai/bim/module/structural/operator.py index edb3ab18ae..500dce4371 100644 --- a/src/bonsai/bonsai/bim/module/structural/operator.py +++ b/src/bonsai/bonsai/bim/module/structural/operator.py @@ -16,13 +16,10 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import json from math import degrees -from typing import TYPE_CHECKING, Any, Literal +from typing import TYPE_CHECKING, Literal import bpy -import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.aggregate import ifcopenshell.api.group import ifcopenshell.api.structural diff --git a/src/bonsai/bonsai/bim/module/structural/prop.py b/src/bonsai/bonsai/bim/module/structural/prop.py index 24d6ead470..e1e658ce7a 100644 --- a/src/bonsai/bonsai/bim/module/structural/prop.py +++ b/src/bonsai/bonsai/bim/module/structural/prop.py @@ -25,21 +25,19 @@ from bpy.props import ( CollectionProperty, EnumProperty, FloatProperty, - FloatVectorProperty, IntProperty, PointerProperty, StringProperty, ) from bpy.types import PropertyGroup -import bonsai.tool as tool from bonsai.bim.module.structural.data import ( BoundaryConditionsData, LoadGroupDecorationData, StructuralLoadCasesData, StructuralLoadsData, ) -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute def get_load_groups_to_show(self: "BIMStructuralProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]: diff --git a/src/bonsai/bonsai/bim/module/structural/shader.py b/src/bonsai/bonsai/bim/module/structural/shader.py index d6f92028d6..b9b5a5c7bc 100644 --- a/src/bonsai/bonsai/bim/module/structural/shader.py +++ b/src/bonsai/bonsai/bim/module/structural/shader.py @@ -58,15 +58,13 @@ class DecorationShader: "PLANAR LOAD", } if pattern not in valid_patterns: - raise ValueError( - """pattern must be one of: + raise ValueError("""pattern must be one of: PERPENDICULAR DISTRIBUTED FORCE PARALLEL DISTRIBUTED FORCE, DISTRIBUTED MOMENT, SINGLE FORCE, SINGLE MOMENT, - PLANAR LOAD""" - ) + PLANAR LOAD""") if "DISTRIBUTED" in pattern.upper(): shader = self.get_linear_shader(pattern) return shader diff --git a/src/bonsai/bonsai/bim/module/style/prop.py b/src/bonsai/bonsai/bim/module/style/prop.py index b1660dfd4c..5d14bbd248 100644 --- a/src/bonsai/bonsai/bim/module/style/prop.py +++ b/src/bonsai/bonsai/bim/module/style/prop.py @@ -24,7 +24,6 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, FloatVectorProperty, IntProperty, PointerProperty, diff --git a/src/bonsai/bonsai/bim/module/system/data.py b/src/bonsai/bonsai/bim/module/system/data.py index c5d8897cc8..65faca50d5 100644 --- a/src/bonsai/bonsai/bim/module/system/data.py +++ b/src/bonsai/bonsai/bim/module/system/data.py @@ -19,7 +19,6 @@ from typing import Any, Union import bpy -import ifcopenshell import ifcopenshell.util.schema import ifcopenshell.util.system import ifcopenshell.util.unit diff --git a/src/bonsai/bonsai/bim/module/system/decorator.py b/src/bonsai/bonsai/bim/module/system/decorator.py index f2448ba6e6..13ac7519f1 100644 --- a/src/bonsai/bonsai/bim/module/system/decorator.py +++ b/src/bonsai/bonsai/bim/module/system/decorator.py @@ -16,19 +16,15 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -from math import cos, radians, sin import bmesh import bpy import gpu -import ifcopenshell from bpy.app.handlers import persistent from bpy.types import SpaceView3D from gpu_extras.batch import batch_for_shader -from mathutils import Matrix, Vector import bonsai.tool as tool -from bonsai.bim.module.system.data import SystemDecorationData ERROR_ELEMENTS_COLOR = (1, 0.2, 0.322, 1) # RED UNSPECIAL_ELEMENT_COLOR = (0.2, 0.2, 0.2, 1) # GREY diff --git a/src/bonsai/bonsai/bim/module/system/operator.py b/src/bonsai/bonsai/bim/module/system/operator.py index 089bd9f24b..e1f6f5e9e4 100644 --- a/src/bonsai/bonsai/bim/module/system/operator.py +++ b/src/bonsai/bonsai/bim/module/system/operator.py @@ -19,7 +19,7 @@ from typing import TYPE_CHECKING import bpy -import ifcopenshell.api +import ifcopenshell.api.attribute import ifcopenshell.api.system import ifcopenshell.util.system @@ -445,6 +445,7 @@ class CycleFlowDirection(bpy.types.Operator, tool.Ifc.Operator): return "Cycle through flow directions: SOURCE → SINK → SOURCEANDSINK → NOTDEFINED → SOURCE..." def _execute(self, context): + ifc_file = tool.Ifc.get() port = tool.Ifc.get().by_id(self.port_id) if not port or not port.is_a("IfcDistributionPort"): return {"CANCELLED"} @@ -459,7 +460,7 @@ class CycleFlowDirection(bpy.types.Operator, tool.Ifc.Operator): } next_direction = flow_cycle_map.get(current_direction, "SOURCE") - tool.Ifc.run("attribute.edit_attributes", product=port, attributes={"FlowDirection": next_direction}) + ifcopenshell.api.attribute.edit_attributes(ifc_file, product=port, attributes={"FlowDirection": next_direction}) connected_port = tool.System.get_connected_port(port) if connected_port: @@ -470,8 +471,8 @@ class CycleFlowDirection(bpy.types.Operator, tool.Ifc.Operator): "NOTDEFINED": "NOTDEFINED", } connected_direction = connected_direction_map.get(next_direction, "NOTDEFINED") - tool.Ifc.run( - "attribute.edit_attributes", product=connected_port, attributes={"FlowDirection": connected_direction} + ifcopenshell.api.attribute.edit_attributes( + ifc_file, product=connected_port, attributes={"FlowDirection": connected_direction} ) PortData.is_loaded = False diff --git a/src/bonsai/bonsai/bim/module/system/prop.py b/src/bonsai/bonsai/bim/module/system/prop.py index a40f50a90e..a03b2a0cfb 100644 --- a/src/bonsai/bonsai/bim/module/system/prop.py +++ b/src/bonsai/bonsai/bim/module/system/prop.py @@ -23,10 +23,7 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup @@ -35,7 +32,7 @@ import bonsai.bim.handler import bonsai.bim.module.system.decorator as decorator import bonsai.tool as tool from bonsai.bim.module.system.data import SystemData -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute def get_system_class(self: "BIMSystemProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]: diff --git a/src/bonsai/bonsai/bim/module/tester/data.py b/src/bonsai/bonsai/bim/module/tester/data.py index 1d1a1c4901..8535d879c6 100644 --- a/src/bonsai/bonsai/bim/module/tester/data.py +++ b/src/bonsai/bonsai/bim/module/tester/data.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import bpy import ifctester.reporter import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/tester/operator.py b/src/bonsai/bonsai/bim/module/tester/operator.py index 6cb7999184..c8485d3339 100644 --- a/src/bonsai/bonsai/bim/module/tester/operator.py +++ b/src/bonsai/bonsai/bim/module/tester/operator.py @@ -31,7 +31,6 @@ from typing import Union import bpy import ifcopenshell -import ifctester import ifctester.ids import ifctester.reporter import socketio diff --git a/src/bonsai/bonsai/bim/module/tester/prop.py b/src/bonsai/bonsai/bim/module/tester/prop.py index 4beb07c533..1bfa32c1eb 100644 --- a/src/bonsai/bonsai/bim/module/tester/prop.py +++ b/src/bonsai/bonsai/bim/module/tester/prop.py @@ -22,9 +22,6 @@ import bpy from bpy.props import ( BoolProperty, CollectionProperty, - EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, PointerProperty, StringProperty, @@ -32,7 +29,7 @@ from bpy.props import ( from bpy.types import PropertyGroup from bonsai.bim.module.tester.data import TesterData -from bonsai.bim.prop import MultipleFileSelect, StrProperty +from bonsai.bim.prop import MultipleFileSelect def update_active_specification_index(self: "IfcTesterProperties", context: bpy.types.Context) -> None: diff --git a/src/bonsai/bonsai/bim/module/type/operator.py b/src/bonsai/bonsai/bim/module/type/operator.py index 8d24989f12..4a6ce053fc 100644 --- a/src/bonsai/bonsai/bim/module/type/operator.py +++ b/src/bonsai/bonsai/bim/module/type/operator.py @@ -18,16 +18,11 @@ from typing import TYPE_CHECKING -import bmesh import bpy -import ifcopenshell.api import ifcopenshell.api.attribute import ifcopenshell.api.type import ifcopenshell.util.element import ifcopenshell.util.representation -import ifcopenshell.util.schema -import ifcopenshell.util.type -import ifcopenshell.util.unit import bonsai.bim.helper import bonsai.core.geometry diff --git a/src/bonsai/bonsai/bim/module/type/prop.py b/src/bonsai/bonsai/bim/module/type/prop.py index 13141a7947..d624fd59a0 100644 --- a/src/bonsai/bonsai/bim/module/type/prop.py +++ b/src/bonsai/bonsai/bim/module/type/prop.py @@ -20,16 +20,11 @@ from typing import TYPE_CHECKING, Union import bpy import ifcopenshell.util.element -import ifcopenshell.util.type from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, - IntProperty, PointerProperty, - StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/module/unit/data.py b/src/bonsai/bonsai/bim/module/unit/data.py index fc51ef3710..6d83bb4e16 100644 --- a/src/bonsai/bonsai/bim/module/unit/data.py +++ b/src/bonsai/bonsai/bim/module/unit/data.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import ifcopenshell import ifcopenshell.util.attribute import ifcopenshell.util.schema import ifcopenshell.util.unit diff --git a/src/bonsai/bonsai/bim/module/unit/operator.py b/src/bonsai/bonsai/bim/module/unit/operator.py index da2c7edc1d..f0cee9a6be 100644 --- a/src/bonsai/bonsai/bim/module/unit/operator.py +++ b/src/bonsai/bonsai/bim/module/unit/operator.py @@ -19,8 +19,6 @@ from typing import TYPE_CHECKING import bpy -import ifcopenshell.api -import ifcopenshell.util.unit import bonsai.core.unit as core import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/unit/prop.py b/src/bonsai/bonsai/bim/module/unit/prop.py index 02fe7ac803..60639ac3a1 100644 --- a/src/bonsai/bonsai/bim/module/unit/prop.py +++ b/src/bonsai/bonsai/bim/module/unit/prop.py @@ -23,16 +23,13 @@ from bpy.props import ( BoolProperty, CollectionProperty, EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, StringProperty, ) from bpy.types import PropertyGroup from bonsai.bim.module.unit.data import UnitsData -from bonsai.bim.prop import Attribute, StrProperty +from bonsai.bim.prop import Attribute def get_unit_classes(self: "BIMUnitProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]: diff --git a/src/bonsai/bonsai/bim/module/void/data.py b/src/bonsai/bonsai/bim/module/void/data.py index 6d1fcc12a2..0253140651 100644 --- a/src/bonsai/bonsai/bim/module/void/data.py +++ b/src/bonsai/bonsai/bim/module/void/data.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -from collections.abc import Generator from typing import Any, Union import bpy diff --git a/src/bonsai/bonsai/bim/module/web/data.py b/src/bonsai/bonsai/bim/module/web/data.py index e74b7fa0b6..652d5f7169 100644 --- a/src/bonsai/bonsai/bim/module/web/data.py +++ b/src/bonsai/bonsai/bim/module/web/data.py @@ -18,8 +18,6 @@ import os -import bpy - import bonsai.tool as tool diff --git a/src/bonsai/bonsai/bim/module/web/operator.py b/src/bonsai/bonsai/bim/module/web/operator.py index 8efd15494e..a2910b9805 100644 --- a/src/bonsai/bonsai/bim/module/web/operator.py +++ b/src/bonsai/bonsai/bim/module/web/operator.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import os import bpy diff --git a/src/bonsai/bonsai/bim/module/web/prop.py b/src/bonsai/bonsai/bim/module/web/prop.py index 1538454270..42bd272578 100644 --- a/src/bonsai/bonsai/bim/module/web/prop.py +++ b/src/bonsai/bonsai/bim/module/web/prop.py @@ -18,16 +18,9 @@ from typing import TYPE_CHECKING -import bpy from bpy.props import ( BoolProperty, - CollectionProperty, - EnumProperty, - FloatProperty, - FloatVectorProperty, IntProperty, - PointerProperty, - StringProperty, ) from bpy.types import PropertyGroup diff --git a/src/bonsai/bonsai/bim/prop.py b/src/bonsai/bonsai/bim/prop.py index 4e93c1c690..61b916965e 100644 --- a/src/bonsai/bonsai/bim/prop.py +++ b/src/bonsai/bonsai/bim/prop.py @@ -21,8 +21,6 @@ import os from typing import TYPE_CHECKING, Any, Literal, Union, assert_never, get_args import bpy -import ifcopenshell -import ifcopenshell.util.pset import ifcopenshell.util.unit from bpy.props import ( BoolProperty, @@ -35,17 +33,9 @@ from bpy.props import ( StringProperty, ) from bpy.types import PropertyGroup -from ifcopenshell.util.doc import ( - get_attribute_doc, - get_entity_doc, - get_predefined_type_doc, - get_property_doc, - get_property_set_doc, -) import bonsai.bim import bonsai.bim.handler -import bonsai.bim.schema import bonsai.tool as tool cwd = os.path.dirname(os.path.realpath(__file__)) diff --git a/src/bonsai/bonsai/bim/ui.py b/src/bonsai/bonsai/bim/ui.py index 26c06c5b8d..7bc27a20e0 100644 --- a/src/bonsai/bonsai/bim/ui.py +++ b/src/bonsai/bonsai/bim/ui.py @@ -24,10 +24,9 @@ from typing import TYPE_CHECKING, Literal, Optional import bpy import platformdirs -from bpy.props import BoolProperty, IntProperty, StringProperty +from bpy.props import BoolProperty, StringProperty from bpy.types import Panel from ifcopenshell.util.doc import ( - get_attribute_doc, get_entity_doc, get_property_set_doc, get_type_doc, @@ -38,7 +37,6 @@ from natsort import natsorted import bonsai.bim import bonsai.bim.helper import bonsai.tool as tool -from bonsai import get_debug_info from bonsai.bim.module.bsdd.prop import BIMBSDDProperties, BSDDProperty from bonsai.bim.module.model.prop import ( BIMDoorProperties, @@ -57,8 +55,6 @@ from bonsai.bim.module.model.ui import ( from bonsai.bim.module.pset.prop import IfcProperty from bonsai.bim.prop import Attribute -from . import ifc - if TYPE_CHECKING: from bonsai.bim.module.project.prop import BIMProjectProperties from bonsai.bim.prop import ObjProperty @@ -661,7 +657,8 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences): name="Load Test Dictionaries", description="Load dictionaries that are for testing only", default=False ) bsdd_baseurl: StringProperty( - name="bSDD API Base URL", description="Base URL for data dictionary API requests, e.g. https://api.bsdd.buildingsmart.org/api/", + name="bSDD API Base URL", + description="Base URL for data dictionary API requests, e.g. https://api.bsdd.buildingsmart.org/api/", default="https://api.bsdd.buildingsmart.org/api/", ) should_disable_undo_on_save: BoolProperty( diff --git a/src/bonsai/bonsai/core/attribute.py b/src/bonsai/bonsai/core/attribute.py index 2bc2340cd8..803cc353bf 100644 --- a/src/bonsai/bonsai/core/attribute.py +++ b/src/bonsai/bonsai/core/attribute.py @@ -21,8 +21,6 @@ from __future__ import annotations from typing import TYPE_CHECKING, Union if TYPE_CHECKING: - import bpy - import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/brick.py b/src/bonsai/bonsai/core/brick.py index a21c6d0656..95b673f88b 100644 --- a/src/bonsai/bonsai/core/brick.py +++ b/src/bonsai/bonsai/core/brick.py @@ -18,10 +18,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import TYPE_CHECKING, Union if TYPE_CHECKING: - import bpy import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/bsdd.py b/src/bonsai/bonsai/core/bsdd.py index 1cbf610ea7..55268c131f 100644 --- a/src/bonsai/bonsai/core/bsdd.py +++ b/src/bonsai/bonsai/core/bsdd.py @@ -18,12 +18,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: - import bpy - import bsdd - import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/context.py b/src/bonsai/bonsai/core/context.py index 49815881aa..7ea77fc2e8 100644 --- a/src/bonsai/bonsai/core/context.py +++ b/src/bonsai/bonsai/core/context.py @@ -21,7 +21,6 @@ from __future__ import annotations from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: - import bpy import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/cost.py b/src/bonsai/bonsai/core/cost.py index 6cd2d916c3..66067cf36e 100644 --- a/src/bonsai/bonsai/core/cost.py +++ b/src/bonsai/bonsai/core/cost.py @@ -21,7 +21,6 @@ from __future__ import annotations from typing import TYPE_CHECKING, Literal, Optional, Union if TYPE_CHECKING: - import bpy import ifcopenshell import ifcopenshell.util.cost diff --git a/src/bonsai/bonsai/core/covering.py b/src/bonsai/bonsai/core/covering.py index c308c861fc..a8c7a73f25 100644 --- a/src/bonsai/bonsai/core/covering.py +++ b/src/bonsai/bonsai/core/covering.py @@ -18,11 +18,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: - import bpy - import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/debug.py b/src/bonsai/bonsai/core/debug.py index b79bd4f0e7..3702a9cca3 100644 --- a/src/bonsai/bonsai/core/debug.py +++ b/src/bonsai/bonsai/core/debug.py @@ -19,11 +19,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: - import bpy - import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/document.py b/src/bonsai/bonsai/core/document.py index e38fc5d1e1..b7fe4ef2e5 100644 --- a/src/bonsai/bonsai/core/document.py +++ b/src/bonsai/bonsai/core/document.py @@ -18,7 +18,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: import ifcopenshell diff --git a/src/bonsai/bonsai/core/drawing.py b/src/bonsai/bonsai/core/drawing.py index 42b0f77fbb..953f57e7f4 100644 --- a/src/bonsai/bonsai/core/drawing.py +++ b/src/bonsai/bonsai/core/drawing.py @@ -19,7 +19,7 @@ from __future__ import annotations from pathlib import Path -from typing import TYPE_CHECKING, Literal, Optional, Union +from typing import TYPE_CHECKING, Optional, Union if TYPE_CHECKING: import bpy diff --git a/src/bonsai/bonsai/core/georeference.py b/src/bonsai/bonsai/core/georeference.py index 442c928b4e..f594f41416 100644 --- a/src/bonsai/bonsai/core/georeference.py +++ b/src/bonsai/bonsai/core/georeference.py @@ -18,11 +18,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: - import bpy - import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/ifcgit.py b/src/bonsai/bonsai/core/ifcgit.py index 703013e266..fb23652ebc 100644 --- a/src/bonsai/bonsai/core/ifcgit.py +++ b/src/bonsai/bonsai/core/ifcgit.py @@ -19,12 +19,11 @@ from __future__ import annotations import platform -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: import bpy import git - import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/library.py b/src/bonsai/bonsai/core/library.py index e6c58bf0f7..e006db797e 100644 --- a/src/bonsai/bonsai/core/library.py +++ b/src/bonsai/bonsai/core/library.py @@ -18,7 +18,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: import bpy diff --git a/src/bonsai/bonsai/core/misc.py b/src/bonsai/bonsai/core/misc.py index 297b81eac8..a5f0deb2f3 100644 --- a/src/bonsai/bonsai/core/misc.py +++ b/src/bonsai/bonsai/core/misc.py @@ -18,11 +18,10 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: import bpy - import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/model.py b/src/bonsai/bonsai/core/model.py index 6edce4d100..7b17d5de5d 100644 --- a/src/bonsai/bonsai/core/model.py +++ b/src/bonsai/bonsai/core/model.py @@ -22,7 +22,6 @@ from typing import TYPE_CHECKING, Literal, Optional if TYPE_CHECKING: import bpy - import ifcopenshell from mathutils import Vector import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/nest.py b/src/bonsai/bonsai/core/nest.py index 4ab491666b..ffa594e731 100644 --- a/src/bonsai/bonsai/core/nest.py +++ b/src/bonsai/bonsai/core/nest.py @@ -18,7 +18,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import TYPE_CHECKING, Union if TYPE_CHECKING: import bpy diff --git a/src/bonsai/bonsai/core/owner.py b/src/bonsai/bonsai/core/owner.py index 90383e7885..aeecb93a64 100644 --- a/src/bonsai/bonsai/core/owner.py +++ b/src/bonsai/bonsai/core/owner.py @@ -18,10 +18,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import TYPE_CHECKING, Union if TYPE_CHECKING: - import bpy import ifcopenshell from ifcopenshell.api.owner.add_actor import ACTOR_TYPE from ifcopenshell.api.owner.add_address import ADDRESS_TYPE diff --git a/src/bonsai/bonsai/core/patch.py b/src/bonsai/bonsai/core/patch.py index 4acee34494..1ea0a71d4a 100644 --- a/src/bonsai/bonsai/core/patch.py +++ b/src/bonsai/bonsai/core/patch.py @@ -19,11 +19,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: - import bpy - import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/profile.py b/src/bonsai/bonsai/core/profile.py index e102360062..77f64c4606 100644 --- a/src/bonsai/bonsai/core/profile.py +++ b/src/bonsai/bonsai/core/profile.py @@ -18,11 +18,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: - import bpy - import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/project.py b/src/bonsai/bonsai/core/project.py index 18dbd3fab2..0e4b044b5e 100644 --- a/src/bonsai/bonsai/core/project.py +++ b/src/bonsai/bonsai/core/project.py @@ -21,8 +21,6 @@ from __future__ import annotations from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: - import bpy - import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/pset.py b/src/bonsai/bonsai/core/pset.py index 6af9f1e1ee..62517b7ab2 100644 --- a/src/bonsai/bonsai/core/pset.py +++ b/src/bonsai/bonsai/core/pset.py @@ -19,7 +19,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional, Union +from typing import TYPE_CHECKING, Any, Union if TYPE_CHECKING: import bpy diff --git a/src/bonsai/bonsai/core/resource.py b/src/bonsai/bonsai/core/resource.py index cab03b7ebc..63f2e02b90 100644 --- a/src/bonsai/bonsai/core/resource.py +++ b/src/bonsai/bonsai/core/resource.py @@ -24,7 +24,6 @@ from collections.abc import Iterable from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: - import bpy import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/search.py b/src/bonsai/bonsai/core/search.py index cc16fb56f6..fb4771d92b 100644 --- a/src/bonsai/bonsai/core/search.py +++ b/src/bonsai/bonsai/core/search.py @@ -21,7 +21,6 @@ from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: - import bpy import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/sequence.py b/src/bonsai/bonsai/core/sequence.py index d62b4325ad..4e1ead7d08 100644 --- a/src/bonsai/bonsai/core/sequence.py +++ b/src/bonsai/bonsai/core/sequence.py @@ -21,7 +21,6 @@ from __future__ import annotations from typing import TYPE_CHECKING, Optional, Union if TYPE_CHECKING: - import bpy import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/spatial.py b/src/bonsai/bonsai/core/spatial.py index c464f84766..5086a8a872 100644 --- a/src/bonsai/bonsai/core/spatial.py +++ b/src/bonsai/bonsai/core/spatial.py @@ -18,7 +18,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union, assert_never +from typing import TYPE_CHECKING, Optional, Union if TYPE_CHECKING: import bpy diff --git a/src/bonsai/bonsai/core/structural.py b/src/bonsai/bonsai/core/structural.py index c3f787905a..fb5a28fe24 100644 --- a/src/bonsai/bonsai/core/structural.py +++ b/src/bonsai/bonsai/core/structural.py @@ -18,10 +18,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import TYPE_CHECKING, Union if TYPE_CHECKING: - import bpy import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/style.py b/src/bonsai/bonsai/core/style.py index 20fd98509c..04ee971f97 100644 --- a/src/bonsai/bonsai/core/style.py +++ b/src/bonsai/bonsai/core/style.py @@ -18,7 +18,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Optional +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: import bpy diff --git a/src/bonsai/bonsai/core/system.py b/src/bonsai/bonsai/core/system.py index 418c472645..f0a3ad0380 100644 --- a/src/bonsai/bonsai/core/system.py +++ b/src/bonsai/bonsai/core/system.py @@ -18,10 +18,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import TYPE_CHECKING, Union if TYPE_CHECKING: - import bpy import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/type.py b/src/bonsai/bonsai/core/type.py index a203b9ff76..cf8f3effbe 100644 --- a/src/bonsai/bonsai/core/type.py +++ b/src/bonsai/bonsai/core/type.py @@ -18,12 +18,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional - -import bonsai.core.geometry +from typing import TYPE_CHECKING if TYPE_CHECKING: - import bpy import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/unit.py b/src/bonsai/bonsai/core/unit.py index 863821e6f5..c0ecc46fcb 100644 --- a/src/bonsai/bonsai/core/unit.py +++ b/src/bonsai/bonsai/core/unit.py @@ -19,10 +19,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING if TYPE_CHECKING: - import bpy import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/core/web.py b/src/bonsai/bonsai/core/web.py index b0d9222460..81b9e8a90c 100644 --- a/src/bonsai/bonsai/core/web.py +++ b/src/bonsai/bonsai/core/web.py @@ -18,11 +18,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Optional, Union +from typing import TYPE_CHECKING if TYPE_CHECKING: - import bpy - import ifcopenshell import bonsai.tool as tool diff --git a/src/bonsai/bonsai/tool/__init__.py b/src/bonsai/bonsai/tool/__init__.py index 68fbf0e381..06e498e8be 100644 --- a/src/bonsai/bonsai/tool/__init__.py +++ b/src/bonsai/bonsai/tool/__init__.py @@ -15,6 +15,9 @@ # # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . +# +# Ignore unused imports. +# ruff: noqa: F401 from bonsai.tool.aggregate import Aggregate from bonsai.tool.attribute import Attribute diff --git a/src/bonsai/bonsai/tool/attribute.py b/src/bonsai/bonsai/tool/attribute.py index 426283ac9e..ce5cdba030 100644 --- a/src/bonsai/bonsai/tool/attribute.py +++ b/src/bonsai/bonsai/tool/attribute.py @@ -21,11 +21,8 @@ from __future__ import annotations from typing import ( TYPE_CHECKING, Any, - Literal, - Optional, TypeVar, Union, - assert_never, ) import bpy @@ -37,7 +34,6 @@ import bonsai.tool as tool if TYPE_CHECKING: from bonsai.bim.module.attribute.prop import ( - BIMAttributeProperties, BIMExplorerProperties, ) diff --git a/src/bonsai/bonsai/tool/bcf.py b/src/bonsai/bonsai/tool/bcf.py index c98cfeb4e0..7be0f97a5b 100644 --- a/src/bonsai/bonsai/tool/bcf.py +++ b/src/bonsai/bonsai/tool/bcf.py @@ -33,7 +33,6 @@ import bcf.v3.topic import bpy import bonsai.core.tool -import bonsai.tool as tool if TYPE_CHECKING: from bonsai.bim.module.bcf.prop import BCFProperties diff --git a/src/bonsai/bonsai/tool/blender.py b/src/bonsai/bonsai/tool/blender.py index 9471cad28c..9c01ce8c20 100644 --- a/src/bonsai/bonsai/tool/blender.py +++ b/src/bonsai/bonsai/tool/blender.py @@ -74,7 +74,7 @@ if TYPE_CHECKING: BIMSolarProperties, RadianceExporterProperties, ) - from bonsai.bim.prop import BIMObjectProperties, BIMProperties, BIMSnapProperties + from bonsai.bim.prop import BIMObjectProperties, BIMProperties T = TypeVar("T") @@ -1581,8 +1581,12 @@ class Blender(bonsai.core.tool.Blender): default_scale = default_dpi * default_pixel_size system = bpy.context.preferences.system system_scale = system.dpi * system.pixel_size - return (system_scale / default_scale) * base_size *platform_scale * tool.Blender.get_addon_preferences().decorator_font_scale - + return ( + (system_scale / default_scale) + * base_size + * platform_scale + * tool.Blender.get_addon_preferences().decorator_font_scale + ) @classmethod def apply_transform_as_local(cls, obj: bpy.types.Object) -> bool: diff --git a/src/bonsai/bonsai/tool/brick.py b/src/bonsai/bonsai/tool/brick.py index 42b80cc288..7ef2c30444 100644 --- a/src/bonsai/bonsai/tool/brick.py +++ b/src/bonsai/bonsai/tool/brick.py @@ -37,13 +37,11 @@ import bonsai.core.tool import bonsai.tool as tool try: - import urllib.parse import brickschema import brickschema.persistent from brickschema.namespaces import REF, A from rdflib import BNode, Literal, Namespace, URIRef - from rdflib.namespace import RDF except: # See #1860 print("Warning: brickschema not available.") @@ -166,17 +164,13 @@ class Brick(bonsai.core.tool.Brick): @classmethod def export_brick_attributes(cls, brick_uri: str) -> dict[str, Any]: - query = BrickStore.graph.query( - """ + query = BrickStore.graph.query(""" PREFIX rdfs: SELECT ?label { <{brick_uri}> rdfs:label ?label . } LIMIT 1 - """.replace( - "{brick_uri}", brick_uri - ) - ) + """.replace("{brick_uri}", brick_uri)) name = None for row in query: name = str(row.get("label")) @@ -220,18 +214,14 @@ class Brick(bonsai.core.tool.Brick): @classmethod def get_brickifc_project(cls) -> Union[str, None]: project = tool.Ifc.get().by_type("IfcProject")[0] - query = BrickStore.graph.query( - """ + query = BrickStore.graph.query(""" PREFIX ref: SELECT ?proj WHERE { ?proj a ref:ifcProject . ?proj ref:ifcProjectID "{project_globalid}" . } LIMIT 1 - """.replace( - "{project_globalid}", project.GlobalId - ) - ) + """.replace("{project_globalid}", project.GlobalId)) results = list(query) if results: return results[0][0].toPython() @@ -277,17 +267,13 @@ class Brick(bonsai.core.tool.Brick): @classmethod def get_item_class(cls, item: str) -> Union[str, None]: - query = BrickStore.graph.query( - """ + query = BrickStore.graph.query(""" PREFIX brick: SELECT ?class WHERE { <{item}> a ?class . } LIMIT 1 - """.replace( - "{item}", item - ) - ) + """.replace("{item}", item)) for row in query: return row.get("class").toPython().split("#")[-1] @@ -310,8 +296,7 @@ class Brick(bonsai.core.tool.Brick): @classmethod def import_brick_classes(cls, brick_class: str, split_screen: bool = False) -> None: - query = BrickStore.graph.query( - """ + query = BrickStore.graph.query(""" PREFIX brick: PREFIX rdfs: PREFIX rdf: @@ -324,10 +309,7 @@ class Brick(bonsai.core.tool.Brick): } GROUP BY ?group ORDER BY asc(?group) - """.replace( - "{brick_class}", brick_class - ) - ) + """.replace("{brick_class}", brick_class)) props = tool.Brick.get_brick_props() if split_screen: bricks = props.split_screen_bricks @@ -344,8 +326,7 @@ class Brick(bonsai.core.tool.Brick): @classmethod def import_brick_items(cls, brick_class: str, split_screen: bool = False) -> None: - query = BrickStore.graph.query( - """ + query = BrickStore.graph.query(""" PREFIX brick: PREFIX rdfs: PREFIX rdf: @@ -356,10 +337,7 @@ class Brick(bonsai.core.tool.Brick): } } ORDER BY asc(?item) - """.replace( - "{brick_class}", brick_class - ) - ) + """.replace("{brick_class}", brick_class)) props = tool.Brick.get_brick_props() if split_screen: bricks = props.split_screen_bricks @@ -509,8 +487,7 @@ class BrickStore: @classmethod def load_sub_roots(cls) -> None: - query = BrickStore.graph.query( - """ + query = BrickStore.graph.query(""" PREFIX brick: PREFIX rdfs: SELECT ?subRoot ?subClasses WHERE { @@ -527,8 +504,7 @@ class BrickStore: } FILTER(?subClasses > 3) } - """ - ) + """) for row in query: sub_root = row.get("subRoot").toPython().split("#")[-1] BrickStore.root_classes.append(sub_root) @@ -560,8 +536,7 @@ class BrickStore: @classmethod def load_entity_classes(cls) -> None: for root_class in BrickStore.root_classes: - query = BrickStore.graph.query( - """ + query = BrickStore.graph.query(""" PREFIX brick: PREFIX rdfs: PREFIX owl: @@ -571,25 +546,20 @@ class BrickStore: ?class owl:deprecated true . } } - """.replace( - "{root_class}", root_class - ) - ) + """.replace("{root_class}", root_class)) BrickStore.entity_classes[root_class] = [] for uri in sorted([x[0].toPython() for x in query]): BrickStore.entity_classes[root_class].append(uri) @classmethod def load_relationships(cls) -> None: - query = BrickStore.graph.query( - """ + query = BrickStore.graph.query(""" PREFIX brick: PREFIX rdfs: SELECT DISTINCT ?relation WHERE { ?relation rdfs:subPropertyOf brick:Relationship . } - """ - ) + """) for uri in sorted([x[0].toPython() for x in query]): BrickStore.relationships.append(uri) diff --git a/src/bonsai/bonsai/tool/cad.py b/src/bonsai/bonsai/tool/cad.py index 4e3d8e1499..13678df15a 100644 --- a/src/bonsai/bonsai/tool/cad.py +++ b/src/bonsai/bonsai/tool/cad.py @@ -30,7 +30,6 @@ from __future__ import annotations -import itertools import math import sys from typing import TYPE_CHECKING, Union diff --git a/src/bonsai/bonsai/tool/clash.py b/src/bonsai/bonsai/tool/clash.py index 7c9961646c..fb64e82b49 100644 --- a/src/bonsai/bonsai/tool/clash.py +++ b/src/bonsai/bonsai/tool/clash.py @@ -19,12 +19,9 @@ from __future__ import annotations import json -import os -from contextlib import contextmanager -from typing import TYPE_CHECKING, Literal, Union, get_args +from typing import TYPE_CHECKING, Literal, Union import bpy -import ifcopenshell from ifcclash import ifcclash from ifcclash.ifcclash import ClashSource from mathutils import Vector diff --git a/src/bonsai/bonsai/tool/classification.py b/src/bonsai/bonsai/tool/classification.py index 7b2ebb073e..9264e5bee2 100644 --- a/src/bonsai/bonsai/tool/classification.py +++ b/src/bonsai/bonsai/tool/classification.py @@ -22,10 +22,8 @@ from typing import TYPE_CHECKING, Union, assert_never import bpy import ifcopenshell.api -import ifcopenshell.util.classification import bonsai.core.tool -import bonsai.tool as tool if TYPE_CHECKING: from bonsai.bim.module.classification.prop import ( diff --git a/src/bonsai/bonsai/tool/collector.py b/src/bonsai/bonsai/tool/collector.py index 74a55d7dc1..b0aa358629 100644 --- a/src/bonsai/bonsai/tool/collector.py +++ b/src/bonsai/bonsai/tool/collector.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -from typing import Union import bpy import ifcopenshell.util.element diff --git a/src/bonsai/bonsai/tool/covering.py b/src/bonsai/bonsai/tool/covering.py index 018a39eb46..28e2a80716 100644 --- a/src/bonsai/bonsai/tool/covering.py +++ b/src/bonsai/bonsai/tool/covering.py @@ -21,7 +21,6 @@ from __future__ import annotations from typing import TYPE_CHECKING import bpy -import ifcopenshell import ifcopenshell.util.element import bonsai.core.tool diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index 864568c835..b8ec26fd37 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -18,8 +18,6 @@ from __future__ import annotations -import collections -import collections.abc import json import logging import math @@ -2712,16 +2710,14 @@ class Drawing(bonsai.core.tool.Drawing): return float(value) except: pass # Perhaps it's imperial? - l = lark.Lark( - """start: feet? "-"? inches? + l = lark.Lark("""start: feet? "-"? inches? feet: NUMBER? "-"? fraction? "'" inches: NUMBER? "-"? fraction? "\\"" fraction: NUMBER "/" NUMBER %import common.NUMBER %import common.WS %ignore WS // Disregard spaces in text - """ - ) + """) try: start = l.parse(value) diff --git a/src/bonsai/bonsai/tool/feature.py b/src/bonsai/bonsai/tool/feature.py index d58a8df55c..3a06cbf625 100644 --- a/src/bonsai/bonsai/tool/feature.py +++ b/src/bonsai/bonsai/tool/feature.py @@ -22,11 +22,9 @@ from collections.abc import Iterable from typing import TYPE_CHECKING import bpy -import ifcopenshell import ifcopenshell.api.feature import ifcopenshell.util.representation -import bonsai.bim.helper import bonsai.core.geometry import bonsai.core.tool import bonsai.tool as tool diff --git a/src/bonsai/bonsai/tool/geometry.py b/src/bonsai/bonsai/tool/geometry.py index 13ec6695d2..e24152d642 100644 --- a/src/bonsai/bonsai/tool/geometry.py +++ b/src/bonsai/bonsai/tool/geometry.py @@ -39,7 +39,6 @@ from typing import ( import bmesh import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.boundary import ifcopenshell.api.geometry import ifcopenshell.api.grid @@ -81,7 +80,7 @@ if TYPE_CHECKING: BIMGeometryProperties, BIMObjectGeometryProperties, ) - from bonsai.bim.prop import Attribute, BIMMeshProperties + from bonsai.bim.prop import BIMMeshProperties class Geometry(bonsai.core.tool.Geometry): diff --git a/src/bonsai/bonsai/tool/georeference.py b/src/bonsai/bonsai/tool/georeference.py index 3fa3e51f62..0c47002a36 100644 --- a/src/bonsai/bonsai/tool/georeference.py +++ b/src/bonsai/bonsai/tool/georeference.py @@ -22,7 +22,6 @@ import json from typing import TYPE_CHECKING, Any, Literal, Union import bpy -import ifcopenshell import ifcopenshell.api.georeference import ifcopenshell.util.geolocation import ifcopenshell.util.placement @@ -317,7 +316,9 @@ class Georeference(bonsai.core.tool.Georeference): @classmethod def global2local(cls, matrix, is_specified_in_map_units: bool) -> tuple[float, float, float]: - matrix = ifcopenshell.util.geolocation.auto_global2local(tool.Ifc.get(), matrix, is_specified_in_map_units=is_specified_in_map_units) + matrix = ifcopenshell.util.geolocation.auto_global2local( + tool.Ifc.get(), matrix, is_specified_in_map_units=is_specified_in_map_units + ) props = cls.get_georeference_props() if props.has_blender_offset: matrix = ifcopenshell.util.geolocation.global2local( diff --git a/src/bonsai/bonsai/tool/group.py b/src/bonsai/bonsai/tool/group.py index f0f3664f6f..3e221b57aa 100644 --- a/src/bonsai/bonsai/tool/group.py +++ b/src/bonsai/bonsai/tool/group.py @@ -25,7 +25,6 @@ import bpy import ifcopenshell from natsort import natsorted -import bonsai.bim.helper import bonsai.core.tool import bonsai.tool as tool diff --git a/src/bonsai/bonsai/tool/layer.py b/src/bonsai/bonsai/tool/layer.py index 396cc13605..a49bf8bf05 100644 --- a/src/bonsai/bonsai/tool/layer.py +++ b/src/bonsai/bonsai/tool/layer.py @@ -23,7 +23,6 @@ from typing import TYPE_CHECKING import bpy import bonsai.core.tool -import bonsai.tool as tool if TYPE_CHECKING: from bonsai.bim.module.layer.prop import BIMLayerProperties diff --git a/src/bonsai/bonsai/tool/material.py b/src/bonsai/bonsai/tool/material.py index 6f862100e2..e09462a8c2 100644 --- a/src/bonsai/bonsai/tool/material.py +++ b/src/bonsai/bonsai/tool/material.py @@ -38,7 +38,6 @@ if TYPE_CHECKING: BIMMaterialProperties, BIMObjectMaterialProperties, ) - from bonsai.bim.module.material.prop import Material as MaterialItem class Material(bonsai.core.tool.Material): diff --git a/src/bonsai/bonsai/tool/model.py b/src/bonsai/bonsai/tool/model.py index 0f3f4e45ad..23c0071b1b 100644 --- a/src/bonsai/bonsai/tool/model.py +++ b/src/bonsai/bonsai/tool/model.py @@ -18,7 +18,6 @@ from __future__ import annotations -import collections import collections.abc import json from collections.abc import Iterable, Sequence @@ -38,7 +37,6 @@ from typing import ( import bmesh import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.geometry import ifcopenshell.api.grid import ifcopenshell.api.pset @@ -2626,7 +2624,7 @@ class Model(bonsai.core.tool.Model): reference_obj: bpy.types.Object, objs: Iterable[bpy.types.Object], align_type: Literal["CENTER", "POSITIVE", "NEGATIVE"], - ): + ) -> None: if align_type == "CENTER": point = reference_obj.matrix_world @ (Vector(reference_obj.bound_box[0]) + (reference_obj.dimensions / 2)) elif align_type == "POSITIVE": @@ -2771,7 +2769,7 @@ class Model(bonsai.core.tool.Model): SvIfcStore.use_bonsai_file = False @classmethod - def create_bmesh_from_vertices(cls, vertices, is_closed=False): + def create_bmesh_from_vertices(cls, vertices: list[Vector], is_closed: bool = False) -> bmesh.types.BMesh: bm = bmesh.new() new_verts = [bm.verts.new(v) for v in vertices] diff --git a/src/bonsai/bonsai/tool/owner.py b/src/bonsai/bonsai/tool/owner.py index 9ed0bda219..9f8cf4ab7c 100644 --- a/src/bonsai/bonsai/tool/owner.py +++ b/src/bonsai/bonsai/tool/owner.py @@ -18,7 +18,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal, Union, assert_never +from typing import TYPE_CHECKING, Any, Literal, Union import bpy import ifcopenshell diff --git a/src/bonsai/bonsai/tool/polyline.py b/src/bonsai/bonsai/tool/polyline.py index 5fbc909910..5a91fc79b8 100644 --- a/src/bonsai/bonsai/tool/polyline.py +++ b/src/bonsai/bonsai/tool/polyline.py @@ -18,12 +18,10 @@ import math from dataclasses import dataclass, field -from math import cos, degrees, radians, sin, tan +from math import radians from typing import Literal, Optional, Union -import bmesh import bpy -import ifcopenshell import ifcopenshell.util.unit from lark import Lark, Transformer from mathutils import Matrix, Vector diff --git a/src/bonsai/bonsai/tool/profile.py b/src/bonsai/bonsai/tool/profile.py index 99d2164a32..4c7c2fc448 100644 --- a/src/bonsai/bonsai/tool/profile.py +++ b/src/bonsai/bonsai/tool/profile.py @@ -25,9 +25,6 @@ import ifcopenshell import ifcopenshell.api.profile import ifcopenshell.geom import ifcopenshell.ifcopenshell_wrapper as W -import ifcopenshell.util.element -import ifcopenshell.util.placement -import ifcopenshell.util.representation import ifcopenshell.util.shape import ifcopenshell.util.unit import numpy as np diff --git a/src/bonsai/bonsai/tool/project.py b/src/bonsai/bonsai/tool/project.py index da613c3fa9..6e1c9b2186 100644 --- a/src/bonsai/bonsai/tool/project.py +++ b/src/bonsai/bonsai/tool/project.py @@ -20,7 +20,6 @@ from __future__ import annotations import os import json -import math import shutil import numpy as np from collections import defaultdict @@ -33,7 +32,6 @@ import ifcopenshell import ifcopenshell.api.document import ifcopenshell.util.element import ifcopenshell.util.representation -import ifcopenshell.util.unit from ifcopenshell.api.project.append_asset import APPENDABLE_ASSET_TYPES import bonsai.bim.schema @@ -542,11 +540,11 @@ class Project(bonsai.core.tool.Project): if not ifc_file: raise Exception("No IFC file loaded") - doc = tool.Ifc.run("document.add_information", parent=None) + doc = ifcopenshell.api.document.add_information(ifc_file, parent=None) if ifc_file.schema == "IFC2X3": - tool.Ifc.run( - "document.edit_information", + ifcopenshell.api.document.edit_information( + ifc_file, information=doc, attributes={ "DocumentId": "BLEND_METADATA", @@ -557,8 +555,8 @@ class Project(bonsai.core.tool.Project): }, ) else: - tool.Ifc.run( - "document.edit_information", + ifcopenshell.api.document.edit_information( + ifc_file, information=doc, attributes={ "Identification": "BLEND_METADATA", @@ -578,13 +576,15 @@ class Project(bonsai.core.tool.Project): return ifc_file = tool.Ifc.get() - if not ifc_file: - return - - tool.Ifc.run("document.edit_information", information=doc, attributes={"Location": metadata_filename}) + ifcopenshell.api.document.edit_information( + ifc_file, information=doc, attributes={"Location": metadata_filename} + ) @classmethod def remove_metadata_document_information(cls) -> None: doc = cls.get_metadata_document_information() - if doc: - tool.Ifc.run("document.remove_information", information=doc) + if not doc: + return + + ifc_file = tool.Ifc.get() + ifcopenshell.api.document.remove_information(ifc_file, information=doc) diff --git a/src/bonsai/bonsai/tool/pset.py b/src/bonsai/bonsai/tool/pset.py index 8eabcd155d..2e2fc4383c 100644 --- a/src/bonsai/bonsai/tool/pset.py +++ b/src/bonsai/bonsai/tool/pset.py @@ -22,7 +22,6 @@ from typing import TYPE_CHECKING, Any, Literal, Union, assert_never import bpy import ifcopenshell -import ifcopenshell.api.pset import ifcopenshell.util.attribute import ifcopenshell.util.element diff --git a/src/bonsai/bonsai/tool/pset_template.py b/src/bonsai/bonsai/tool/pset_template.py index e4c1c3dbe1..fea5362d4e 100644 --- a/src/bonsai/bonsai/tool/pset_template.py +++ b/src/bonsai/bonsai/tool/pset_template.py @@ -24,8 +24,6 @@ from typing import TYPE_CHECKING, Literal, final import bpy import ifcopenshell import ifcopenshell.api.pset_template -import ifcopenshell.util.attribute -import ifcopenshell.util.element import bonsai.bim import bonsai.core.tool diff --git a/src/bonsai/bonsai/tool/qto.py b/src/bonsai/bonsai/tool/qto.py index 4fd271b283..ec14df6f4c 100644 --- a/src/bonsai/bonsai/tool/qto.py +++ b/src/bonsai/bonsai/tool/qto.py @@ -22,7 +22,6 @@ from typing import TYPE_CHECKING, Any, Literal, Optional, Union import bpy import ifcopenshell -import ifcopenshell.util.element import ifcopenshell.util.unit from mathutils import Vector diff --git a/src/bonsai/bonsai/tool/raycast.py b/src/bonsai/bonsai/tool/raycast.py index ee06066dd7..d98aaf26ab 100644 --- a/src/bonsai/bonsai/tool/raycast.py +++ b/src/bonsai/bonsai/tool/raycast.py @@ -16,14 +16,12 @@ # You should have received a copy of the GNU General Public License # along with Bonsai. If not, see . -import copy from typing import Union import bmesh import bpy import mathutils import numpy as np -from bpy_extras import view3d_utils from mathutils import Vector import bonsai.core.tool diff --git a/src/bonsai/bonsai/tool/root.py b/src/bonsai/bonsai/tool/root.py index be7e350adc..02ddbe9745 100644 --- a/src/bonsai/bonsai/tool/root.py +++ b/src/bonsai/bonsai/tool/root.py @@ -22,7 +22,6 @@ from typing import TYPE_CHECKING, Any, Literal, Optional, Union import bpy import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.feature import ifcopenshell.api.geometry import ifcopenshell.api.root diff --git a/src/bonsai/bonsai/tool/search.py b/src/bonsai/bonsai/tool/search.py index ffd3a1aef3..356addee3a 100644 --- a/src/bonsai/bonsai/tool/search.py +++ b/src/bonsai/bonsai/tool/search.py @@ -20,7 +20,7 @@ from __future__ import annotations import json from itertools import cycle -from typing import TYPE_CHECKING, Literal, Union +from typing import TYPE_CHECKING, Any, Literal, Union import bpy import ifcopenshell.guid @@ -51,7 +51,9 @@ class Search(bonsai.core.tool.Search): @classmethod def import_filter_structure( - cls, filter_structure: list, filter_groups: bpy.types.bpy_prop_collection_idprop[BIMFilterGroup] + cls, + filter_structure: list[list[dict[str, Any]]], + filter_groups: bpy.types.bpy_prop_collection_idprop[BIMFilterGroup], ) -> None: filter_groups.clear() @@ -188,7 +190,9 @@ class Search(bonsai.core.tool.Search): return "" @classmethod - def execute_filter_groups(cls, filter_groups: bpy.types.bpy_prop_collection_idprop[BIMFilterGroup]) -> set: + def execute_filter_groups( + cls, filter_groups: bpy.types.bpy_prop_collection_idprop[BIMFilterGroup] + ) -> set[ifcopenshell.entity_instance]: """ Execute filter groups with simplified chaining support. Within a single group chain, all filters chain sequentially with ADD/SUBTRACT/FILTER modes. @@ -196,10 +200,10 @@ class Search(bonsai.core.tool.Search): """ preferences = tool.Blender.get_addon_preferences() - all_group_results = [] + all_group_results: list[set[ifcopenshell.entity_instance]] = [] - for group_idx, filter_group in enumerate(filter_groups): - group_results = set() + for filter_group in filter_groups: + group_results: set[ifcopenshell.entity_instance] = set() for filter_index, ifc_filter in enumerate(filter_group.filters): if not ifc_filter.value: @@ -245,7 +249,7 @@ class Search(bonsai.core.tool.Search): if group_results: all_group_results.append(group_results) - final_results = set() + final_results: set[ifcopenshell.entity_instance] = set() for group_results in all_group_results: final_results.update(group_results) @@ -262,9 +266,9 @@ class Search(bonsai.core.tool.Search): """ filter_structure = data.get("filter_structure", []) - all_group_results = [] + all_group_results: list[set[ifcopenshell.entity_instance]] = [] for group_data in filter_structure: - group_results = set() + group_results: set[ifcopenshell.entity_instance] = set() for filter_data in group_data: filter_mode = filter_data.get("filter_mode", "ADD") @@ -332,7 +336,7 @@ class Search(bonsai.core.tool.Search): if group_results: all_group_results.append(group_results) - final_results = set() + final_results: set[ifcopenshell.entity_instance] = set() for group_results in all_group_results: final_results.update(group_results) diff --git a/src/bonsai/bonsai/tool/sequence.py b/src/bonsai/bonsai/tool/sequence.py index 8c5339d438..2afed8741a 100644 --- a/src/bonsai/bonsai/tool/sequence.py +++ b/src/bonsai/bonsai/tool/sequence.py @@ -18,11 +18,8 @@ from __future__ import annotations -import base64 import json -import os import re -import webbrowser from collections.abc import Iterable from datetime import datetime from datetime import time as datetime_time @@ -32,14 +29,12 @@ import bpy import ifcopenshell import ifcopenshell.api.group import ifcopenshell.api.sequence -import ifcopenshell.ifcopenshell_wrapper as W import ifcopenshell.util.date import ifcopenshell.util.element import ifcopenshell.util.selector import ifcopenshell.util.sequence import isodate import mathutils -import pystache from dateutil import parser from mathutils import Color diff --git a/src/bonsai/bonsai/tool/snap.py b/src/bonsai/bonsai/tool/snap.py index 0dc11e86b0..02f484d388 100644 --- a/src/bonsai/bonsai/tool/snap.py +++ b/src/bonsai/bonsai/tool/snap.py @@ -23,10 +23,7 @@ from typing import TYPE_CHECKING, Any, Union import bmesh import bpy -import ifcopenshell import ifcopenshell.util.unit -import mathutils -from lark import Lark, Transformer from mathutils import Matrix, Vector import bonsai.core.tool diff --git a/src/bonsai/bonsai/tool/spatial.py b/src/bonsai/bonsai/tool/spatial.py index d38d895c22..b185b9ab59 100644 --- a/src/bonsai/bonsai/tool/spatial.py +++ b/src/bonsai/bonsai/tool/spatial.py @@ -49,7 +49,6 @@ import bonsai.core.root import bonsai.core.spatial import bonsai.core.tool import bonsai.core.type -import bonsai.core.unit import bonsai.tool as tool if TYPE_CHECKING: diff --git a/src/bonsai/bonsai/tool/style.py b/src/bonsai/bonsai/tool/style.py index 78cb19680e..8db3ed30fe 100644 --- a/src/bonsai/bonsai/tool/style.py +++ b/src/bonsai/bonsai/tool/style.py @@ -26,7 +26,6 @@ import ifcopenshell import ifcopenshell.api.style import ifcopenshell.util.element import ifcopenshell.util.representation -import numpy as np from mathutils import Color import bonsai.bim.helper diff --git a/src/bonsai/bonsai/tool/surveyor.py b/src/bonsai/bonsai/tool/surveyor.py index f59d9cd7da..42fe540c63 100644 --- a/src/bonsai/bonsai/tool/surveyor.py +++ b/src/bonsai/bonsai/tool/surveyor.py @@ -17,12 +17,10 @@ # along with Bonsai. If not, see . import bpy -import ifcopenshell.api import ifcopenshell.util.geolocation import ifcopenshell.util.unit import numpy as np import numpy.typing as npt -from mathutils import Matrix import bonsai.core.tool import bonsai.tool as tool diff --git a/src/bonsai/bonsai/tool/system.py b/src/bonsai/bonsai/tool/system.py index 8b949a36c9..926bceca91 100644 --- a/src/bonsai/bonsai/tool/system.py +++ b/src/bonsai/bonsai/tool/system.py @@ -28,7 +28,6 @@ import ifcopenshell.api.system import ifcopenshell.util.element import ifcopenshell.util.system from mathutils import Matrix, Vector -from natsort import natsorted import bonsai.bim.helper import bonsai.core.geometry diff --git a/src/bonsai/bonsai/tool/unit.py b/src/bonsai/bonsai/tool/unit.py index 1221f28be9..5825c6f382 100644 --- a/src/bonsai/bonsai/tool/unit.py +++ b/src/bonsai/bonsai/tool/unit.py @@ -20,7 +20,7 @@ from __future__ import annotations import json import math -from typing import TYPE_CHECKING, Any, Literal, Union, assert_never +from typing import TYPE_CHECKING, Any, Literal, Union import bpy import ifcopenshell diff --git a/src/bonsai/bonsai/tool/web.py b/src/bonsai/bonsai/tool/web.py index 35811b3819..9ebf211ce8 100644 --- a/src/bonsai/bonsai/tool/web.py +++ b/src/bonsai/bonsai/tool/web.py @@ -30,7 +30,6 @@ import threading import time import webbrowser from pathlib import Path -from time import sleep from typing import TYPE_CHECKING, Any, Optional, Union import bpy @@ -118,7 +117,6 @@ class Web(bonsai.core.tool.Web): :param port: The port number on which to start the WebSocket server. """ - import addon_utils global ws_process diff --git a/src/bonsai/pyproject.toml b/src/bonsai/pyproject.toml index 3ec2cb8748..398687a715 100644 --- a/src/bonsai/pyproject.toml +++ b/src/bonsai/pyproject.toml @@ -38,3 +38,6 @@ exclude = ["test*"] [tool.ruff] extend = "../../pyproject.toml" +lint.select = [ + "F401", # unused imports +] diff --git a/src/bonsai/scripts/bonsai_translations.py b/src/bonsai/scripts/bonsai_translations.py index 7a0fe86ea9..1597eaabcb 100644 --- a/src/bonsai/scripts/bonsai_translations.py +++ b/src/bonsai/scripts/bonsai_translations.py @@ -5,7 +5,6 @@ try: if not hasattr(bpy, "context"): raise ModuleNotFoundError import addon_utils - import bl_i18n_utils BPY_IS_LOADED = True except ModuleNotFoundError: diff --git a/src/bonsai/scripts/classifications/brick_classifiction.py b/src/bonsai/scripts/classifications/brick_classifiction.py index 9a9d42353e..17246940c7 100644 --- a/src/bonsai/scripts/classifications/brick_classifiction.py +++ b/src/bonsai/scripts/classifications/brick_classifiction.py @@ -22,8 +22,7 @@ class Generator: } ) - query = self.schema.query( - """ + query = self.schema.query(""" PREFIX brick: PREFIX rdfs: PREFIX skos: @@ -49,8 +48,7 @@ class Generator: } } GROUP BY ?entity - """ - ) + """) # create references dictionary references = {} @@ -76,17 +74,13 @@ class Generator: ) # get all parents of the entity - query = self.schema.query( - """ + query = self.schema.query(""" PREFIX brick: PREFIX rdfs: SELECT ?parent WHERE { brick:{entity} rdfs:subClassOf ?parent . } - """.replace( - "{entity}", location.split("#")[-1] - ) - ) + """.replace("{entity}", location.split("#")[-1])) # filter parents for the brick entity for row in query: parent = row.get("parent").toPython() diff --git a/src/bonsai/scripts/classifications/vbis.py b/src/bonsai/scripts/classifications/vbis.py index 7c4f43b967..71d0af5fe9 100644 --- a/src/bonsai/scripts/classifications/vbis.py +++ b/src/bonsai/scripts/classifications/vbis.py @@ -1,9 +1,6 @@ import csv -import json -import os # import pystache -import subprocess from pathlib import Path import ifcopenshell diff --git a/src/bonsai/scripts/gbxml.py b/src/bonsai/scripts/gbxml.py index 7280c69c2a..7bd8063a15 100644 --- a/src/bonsai/scripts/gbxml.py +++ b/src/bonsai/scripts/gbxml.py @@ -17,14 +17,11 @@ # along with Bonsai. If not, see . import math -import sys import uuid import bpy -import bspy # pyright: ignore[reportMissingImports] # sys.path.append('C:\Program Files\Python37\Lib\site-packages') -import lxml import lxml.etree from bspy import Gbxml # pyright: ignore[reportMissingImports] diff --git a/src/bonsai/scripts/generate_au_library.py b/src/bonsai/scripts/generate_au_library.py index 43f05b45da..91fe224255 100644 --- a/src/bonsai/scripts/generate_au_library.py +++ b/src/bonsai/scripts/generate_au_library.py @@ -20,7 +20,6 @@ # pylint: skip-file import bpy -import ifcopenshell import ifcopenshell.api import ifcopenshell.api.context import ifcopenshell.api.geometry diff --git a/src/bonsai/scripts/generate_entourage_library.py b/src/bonsai/scripts/generate_entourage_library.py index 7435186396..fe7a75856e 100644 --- a/src/bonsai/scripts/generate_entourage_library.py +++ b/src/bonsai/scripts/generate_entourage_library.py @@ -17,10 +17,8 @@ # along with Bonsai. If not, see . import os -from pathlib import Path import bpy -import ifcopenshell import ifcopenshell.api import ifcopenshell.api.context import ifcopenshell.api.geometry diff --git a/src/bonsai/scripts/generate_furniture_library.py b/src/bonsai/scripts/generate_furniture_library.py index 1c1572c854..7b9d411772 100644 --- a/src/bonsai/scripts/generate_furniture_library.py +++ b/src/bonsai/scripts/generate_furniture_library.py @@ -17,7 +17,7 @@ # along with Bonsai. If not, see . from itertools import chain -from math import cos, pi, tan +from math import pi, tan from pathlib import Path from typing import Optional, Union @@ -25,10 +25,8 @@ import ifcopenshell import ifcopenshell.api import ifcopenshell.api.context import ifcopenshell.api.geometry -import ifcopenshell.api.material import ifcopenshell.api.project import ifcopenshell.api.root -import ifcopenshell.api.style import ifcopenshell.api.unit import ifcopenshell.util.element import numpy as np diff --git a/src/bonsai/scripts/generate_landscape_library.py b/src/bonsai/scripts/generate_landscape_library.py index 34d2366fd5..4e6ad3eba1 100644 --- a/src/bonsai/scripts/generate_landscape_library.py +++ b/src/bonsai/scripts/generate_landscape_library.py @@ -20,13 +20,10 @@ import csv import os import random from collections import namedtuple -from itertools import chain -from math import cos, pi, sin, tan -from pathlib import Path +from math import cos, pi, sin from random import uniform import bpy -import ifcopenshell import ifcopenshell.api import ifcopenshell.api.context import ifcopenshell.api.geometry @@ -36,7 +33,7 @@ import ifcopenshell.api.style import ifcopenshell.api.unit import ifcopenshell.util.unit from ifcopenshell.util.shape_builder import ShapeBuilder -from mathutils import Matrix, Vector +from mathutils import Vector import bonsai.tool as tool diff --git a/src/bonsai/scripts/generate_site_library.py b/src/bonsai/scripts/generate_site_library.py index 0b0511e9da..d8439287ad 100644 --- a/src/bonsai/scripts/generate_site_library.py +++ b/src/bonsai/scripts/generate_site_library.py @@ -17,7 +17,6 @@ # along with Bonsai. If not, see . import bpy -import ifcopenshell import ifcopenshell.api import ifcopenshell.api.context import ifcopenshell.api.geometry diff --git a/src/bonsai/scripts/generate_steel_profiles_library.py b/src/bonsai/scripts/generate_steel_profiles_library.py index c54818df4b..255a448127 100644 --- a/src/bonsai/scripts/generate_steel_profiles_library.py +++ b/src/bonsai/scripts/generate_steel_profiles_library.py @@ -19,11 +19,10 @@ # fmt: off # pylint: skip-file -from math import cos, pi +from math import pi from pathlib import Path import boltspy as bolts # pyright: ignore[reportMissingImports] -import ifcopenshell import ifcopenshell.api import ifcopenshell.api.material import ifcopenshell.api.project diff --git a/src/bonsai/scripts/geonodes_modifier_prototype.py b/src/bonsai/scripts/geonodes_modifier_prototype.py index 16370c1ca2..185200942e 100644 --- a/src/bonsai/scripts/geonodes_modifier_prototype.py +++ b/src/bonsai/scripts/geonodes_modifier_prototype.py @@ -21,7 +21,6 @@ import json import bmesh import bpy -import ifcopenshell import ifcopenshell.api.pset import ifcopenshell.util.element diff --git a/src/bonsai/scripts/get_all_qtos.py b/src/bonsai/scripts/get_all_qtos.py index d364115559..8d407120eb 100644 --- a/src/bonsai/scripts/get_all_qtos.py +++ b/src/bonsai/scripts/get_all_qtos.py @@ -7,7 +7,6 @@ from typing import Union import ifc5d import ifcopenshell.util.pset -import ifcopenshell.util.type def order_dict(dictionary): diff --git a/src/bonsai/scripts/obj2ifc-meshlab.py b/src/bonsai/scripts/obj2ifc-meshlab.py index c8292bb0f7..70849e11d9 100644 --- a/src/bonsai/scripts/obj2ifc-meshlab.py +++ b/src/bonsai/scripts/obj2ifc-meshlab.py @@ -21,8 +21,6 @@ import argparse from pathlib import Path -import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.aggregate import ifcopenshell.api.context import ifcopenshell.api.geometry diff --git a/src/bonsai/scripts/obj2ifc.py b/src/bonsai/scripts/obj2ifc.py index 70f3bf7b41..ec5459c4a3 100644 --- a/src/bonsai/scripts/obj2ifc.py +++ b/src/bonsai/scripts/obj2ifc.py @@ -21,8 +21,6 @@ import argparse from pathlib import Path -import ifcopenshell -import ifcopenshell.api import ifcopenshell.api.aggregate import ifcopenshell.api.context import ifcopenshell.api.geometry diff --git a/src/bonsai/scripts/replace_drawing_path.py b/src/bonsai/scripts/replace_drawing_path.py index 500726082f..2dd4296fad 100644 --- a/src/bonsai/scripts/replace_drawing_path.py +++ b/src/bonsai/scripts/replace_drawing_path.py @@ -31,7 +31,6 @@ import os import sys from sys import platform -import ifcopenshell import ifcopenshell.api.pset import ifcopenshell.util.element diff --git a/src/bonsai/scripts/reregister_bonsai.py b/src/bonsai/scripts/reregister_bonsai.py index ba9ab2ba2a..4eb3764708 100644 --- a/src/bonsai/scripts/reregister_bonsai.py +++ b/src/bonsai/scripts/reregister_bonsai.py @@ -23,7 +23,6 @@ Use operators instead of `blender --command extension remove` to ensure disable and enable occur in the same Blender session. """ - import bpy import bonsai.tool as tool diff --git a/src/bonsai/scripts/setup_pytest.py b/src/bonsai/scripts/setup_pytest.py index 28dc7565f1..a4e56ca35c 100644 --- a/src/bonsai/scripts/setup_pytest.py +++ b/src/bonsai/scripts/setup_pytest.py @@ -45,10 +45,10 @@ for dep in dependencies: subprocess.check_call(command + [dep]) try: - import pygments - import pytest - import pytest_bdd - import pytest_blender + import pygments # noqa: F401 + import pytest # noqa: F401 + import pytest_bdd # noqa: F401 + import pytest_blender # noqa: F401 print("Test dependency installation was successful!") except Exception as e: diff --git a/src/bonsai/scripts/standalone_drawer.py b/src/bonsai/scripts/standalone_drawer.py index 3eed11b9c9..886887bf32 100644 --- a/src/bonsai/scripts/standalone_drawer.py +++ b/src/bonsai/scripts/standalone_drawer.py @@ -4,7 +4,6 @@ from typing import NamedTuple import ifcopenshell import ifcopenshell.geom -import ifcopenshell.ifcopenshell_wrapper as W import ifcopenshell.util.element # W.turn_on_detailed_logging() diff --git a/src/bonsai/scripts/waldo.py b/src/bonsai/scripts/waldo.py index 00243c5782..c58e1dc1ec 100644 --- a/src/bonsai/scripts/waldo.py +++ b/src/bonsai/scripts/waldo.py @@ -3,7 +3,6 @@ from itertools import cycle from math import radians -import ifcopenshell import ifcopenshell.api.aggregate import ifcopenshell.api.context import ifcopenshell.api.geometry diff --git a/src/bonsai/test/pyproject.toml b/src/bonsai/test/pyproject.toml new file mode 100644 index 0000000000..7567fe8627 --- /dev/null +++ b/src/bonsai/test/pyproject.toml @@ -0,0 +1,5 @@ +[tool.ruff] +extend = "../pyproject.toml" +lint.ignore = [ + "F401", # unused imports +] diff --git a/src/bonsai/test/tool/test_drawing.py b/src/bonsai/test/tool/test_drawing.py index 69d7fbde92..3fa2e68cae 100644 --- a/src/bonsai/test/tool/test_drawing.py +++ b/src/bonsai/test/tool/test_drawing.py @@ -162,7 +162,7 @@ class TestEditTextLiterals(NewFile): context = ifc.createIfcGeometricRepresentationSubContext(ContextType="Plan", ContextIdentifier="Annotation") item = ifc.createIfcTextLiteralWithExtent(Literal="Literal", Path="RIGHT", BoxAlignment="bottom-left") builder = ShapeBuilder(tool.Ifc.get()) - polyline = builder.polyline([(0.,0.,0.), (1.,0.,0.)]) + polyline = builder.polyline([(0.0, 0.0, 0.0), (1.0, 0.0, 0.0)]) representation = ifc.createIfcShapeRepresentation(ContextOfItems=context, Items=[item, polyline]) element.Representation.Representations = [representation] tool.Ifc.link(element, obj) diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index 79a2399821..a7c99043bd 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -36,11 +36,15 @@ else() endif() macro(build_example exe_name) - set (additional_targets ${ARGN}) + set(additional_targets ${ARGN}) add_executable(${exe_name} ${exe_name}.cpp) if(STANDALONE_PROJECT) - target_link_libraries(${exe_name} IfcOpenShell::IfcParse $<$:IfcOpenShell::${additional_targets}>) + target_link_libraries( + ${exe_name} + IfcOpenShell::IfcParse + $<$:IfcOpenShell::${additional_targets}> + ) else() target_include_directories(${exe_name} PRIVATE "${CMAKE_SOURCE_DIR}/../src") target_link_libraries(${exe_name} IfcParse ${additional_targets}) diff --git a/src/ifc2ca/_deprecated/scriptCodeAsterBonded.py b/src/ifc2ca/_deprecated/scriptCodeAsterBonded.py index 0b1184453b..e5bfd03aed 100644 --- a/src/ifc2ca/_deprecated/scriptCodeAsterBonded.py +++ b/src/ifc2ca/_deprecated/scriptCodeAsterBonded.py @@ -89,27 +89,22 @@ class COMMANDFILE: f.write("# Linear Static Analysis With Self-Weight\n") - f.write( - """ + f.write(""" # STEP: INITIALIZE STUDY DEBUT( PAR_LOT = 'NON' ) -""" - ) +""") - f.write( - """ + f.write(""" # STEP: READ MED FILE mesh = LIRE_MAILLAGE( FORMAT = 'MED', UNITE = 20 ) -""" - ) +""") - f.write( - """ + f.write(""" # STEP: DEFINE MODEL model = AFFE_MODELE( MAILLAGE = mesh, @@ -118,8 +113,7 @@ model = AFFE_MODELE( TOUT = 'OUI', PHENOMENE = 'MECANIQUE', MODELISATION = '3D' - ),""" - ) + ),""") if faceGroupNames: template = """ @@ -157,12 +151,10 @@ model = AFFE_MODELE( f.write(template.format(**context)) - f.write( - """ + f.write(""" ) )\n -""" - ) +""") f.write("# STEP: DEFINE MATERIALS") @@ -195,12 +187,10 @@ model = AFFE_MODELE( f.write(template.format(**context)) - f.write( - """ + f.write(""" material = AFFE_MATERIAU( MAILLAGE = mesh, - AFFE = (""" - ) + AFFE = (""") for i, material in enumerate(materials): template = """ @@ -227,20 +217,16 @@ material = AFFE_MATERIAU( f.write(template.format(**context)) - f.write( - """ + f.write(""" ) ) -""" - ) +""") - f.write( - """ + f.write(""" # STEP: DEFINE ELEMENTS element = AFFE_CARA_ELEM( MODELE = model, - POUTRE = (""" - ) + POUTRE = (""") for profile in profiles: if profile["profileShape"] == "rectangular" and profile["profileType"] == "AREA": @@ -296,11 +282,9 @@ element = AFFE_CARA_ELEM( f.write(template.format(**context)) - f.write( - """ + f.write(""" ), - COQUE = (""" - ) + COQUE = (""") for el in [el for el in elements if el["geometryType"] == "surface"]: @@ -319,15 +303,11 @@ element = AFFE_CARA_ELEM( f.write(template.format(**context)) - f.write( - """ - ),""" - ) + f.write(""" + ),""") - f.write( - """ - ORIENTATION = (""" - ) + f.write(""" + ORIENTATION = (""") for el in [el for el in elements if el["geometryType"] == "line"]: @@ -345,21 +325,16 @@ element = AFFE_CARA_ELEM( f.write(template.format(**context)) - f.write( - """ - ),""" - ) + f.write(""" + ),""") - f.write( - """ + f.write(""" )\n -""" - ) +""") f.write("# STEP: DEFINE SUPPORTS AND CONSTRAINTS") - f.write( - """ + f.write(""" liaisons = AFFE_CHAR_MECA( MODELE = model, DDL_IMPO = ( @@ -372,14 +347,11 @@ liaisons = AFFE_CHAR_MECA( DRY = 0.0, DRZ = 0.0 ) - ),""" - ) + ),""") if rigidLinkGroupNames: - f.write( - """ - LIAISON_SOLIDE = (""" - ) + f.write(""" + LIAISON_SOLIDE = (""") for groupName in rigidLinkGroupNames: template = """ @@ -391,16 +363,12 @@ liaisons = AFFE_CHAR_MECA( f.write(template.format(**context)) - f.write( - """ - ),""" - ) + f.write(""" + ),""") - f.write( - """ + f.write(""" ) -""" - ) +""") template = """ # STEP: DEFINE LOAD @@ -418,8 +386,7 @@ gravLoad = AFFE_CHAR_MECA( f.write(template.format(**context)) - f.write( - """ + f.write(""" # STEP: RUN ANALYSIS res_Bld = MECA_STATIQUE( MODELE = model, @@ -434,8 +401,7 @@ res_Bld = MECA_STATIQUE( ) ) ) -""" - ) +""") # f.write( # ''' @@ -515,8 +481,7 @@ res_Bld = MECA_STATIQUE( # ''' # ) # - f.write( - """ + f.write(""" # STEP: DEFORMED SHAPE EXTRACTION IMPR_RESU( FORMAT = 'MED', @@ -527,15 +492,12 @@ IMPR_RESU( NOM_CHAM_MED = ('Bld_DISP',), # 'Bld_REAC', 'Bld_FORC' ) ) -""" - ) +""") - f.write( - """ + f.write(""" # STEP: CONCLUDE STUDY FIN() -""" - ) +""") f.close() diff --git a/src/ifc2ca/_deprecated/scriptSalomeBonded.py b/src/ifc2ca/_deprecated/scriptSalomeBonded.py index fb2bd575f9..d3b6d506c8 100644 --- a/src/ifc2ca/_deprecated/scriptSalomeBonded.py +++ b/src/ifc2ca/_deprecated/scriptSalomeBonded.py @@ -53,16 +53,16 @@ class MODEL: """Function to define a Point from a polyline (list of 1 point)""" - (x, y, z) = pl + x, y, z = pl return self.geompy.MakeVertex(x, y, z) def makeLine(self, pl): """Function to define a Line from a polyline (list of 2 points)""" - (x, y, z) = pl[0] + x, y, z = pl[0] P1 = self.geompy.MakeVertex(x, y, z) - (x, y, z) = pl[1] + x, y, z = pl[1] P2 = self.geompy.MakeVertex(x, y, z) return self.geompy.MakeLineTwoPnt(P1, P2) diff --git a/src/ifcbimtester/bimtester/features/steps/aggregation/en.py b/src/ifcbimtester/bimtester/features/steps/aggregation/en.py index a2bbe621a1..f0c4af8f15 100644 --- a/src/ifcbimtester/bimtester/features/steps/aggregation/en.py +++ b/src/ifcbimtester/bimtester/features/steps/aggregation/en.py @@ -28,12 +28,8 @@ use_step_matcher("parse") @step('There must be exactly {number} "{ifc_class}" elements') def step_impl(context, number, ifc_class): num = len(IfcStore.file.by_type(ifc_class)) - assert num == int( - number - ), "Could not find {} elements of {}. \ - Found {} element(s).".format( - number, ifc_class, num - ) + assert num == int(number), "Could not find {} elements of {}. \ + Found {} element(s).".format(number, ifc_class, num) @given('a set of (key,value) called ("{key_name}","{value_name}")') @@ -95,13 +91,9 @@ def step_impl(context, attribute_name): @then('there must be exactly a number of "{ifc_class}" equals to the number of distinct value') def step_impl(context, ifc_class): try: - context.execute_steps( - """ + context.execute_steps(""" then There must be exactly {number} "{ifc_class}" elements - """.format( - ifc_class=ifc_class, number=context.model.get_count_distinct_values() - ) - ) + """.format(ifc_class=ifc_class, number=context.model.get_count_distinct_values())) except AssertionError as error: str_error = str(error) assert False, str_error[: str_error.find("Traceback")] diff --git a/src/ifcbimtester/examples/steps/aggregation.py b/src/ifcbimtester/examples/steps/aggregation.py index ccf46b5e0d..96e0375b43 100644 --- a/src/ifcbimtester/examples/steps/aggregation.py +++ b/src/ifcbimtester/examples/steps/aggregation.py @@ -51,13 +51,9 @@ def step_impl(context, path_file): @then("there must be exactly a number of {ifc_class} equals to the number of distinct row value") def step_impl(context, ifc_class): try: - context.execute_steps( - """ + context.execute_steps(""" then There must be exactly {number} {ifc_class} elements - """.format( - ifc_class=ifc_class, number=context.model.get_count_distinct_values() - ) - ) + """.format(ifc_class=ifc_class, number=context.model.get_count_distinct_values())) except AssertionError as error: str_error = str(error) assert False, str_error[: str_error.find("Traceback")] diff --git a/src/ifcgeom/mapping/CMakeLists.txt b/src/ifcgeom/mapping/CMakeLists.txt index 4e185b9fa9..6369b98b60 100644 --- a/src/ifcgeom/mapping/CMakeLists.txt +++ b/src/ifcgeom/mapping/CMakeLists.txt @@ -1,12 +1,21 @@ find_package(Eigen3 REQUIRED) +# When using `ENABLE_BUILD_OPTIMIZATIONS``/GL` compilation flags makes resulting mapping libs huge (e.g. 1.5GB each) +# and combining them together to a single IfcGeom won't be possible due to 4GB file size limit. +# So in this case we have to ensure each mapping is built as separate libs instead of .obj files to be linked together. +if(ENABLE_BUILD_OPTIMIZATIONS AND MSVC) + set(mapping_library_type "STATIC") +else() + set(mapping_library_type "OBJECT") +endif() + foreach(schema ${SCHEMA_VERSIONS}) file(GLOB IFCGEOM_I_FILES *.i) file(GLOB IFCGEOM_H_FILES *.h) file(GLOB IFCGEOM_CPP_FILES *.cpp) set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES} ${IFCGEOM_I_FILES}) - add_library(geometry_mapping_ifc${schema} OBJECT ${IFCGEOM_FILES}) + add_library(geometry_mapping_ifc${schema} ${mapping_library_type} ${IFCGEOM_FILES}) set_target_properties( geometry_mapping_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}" diff --git a/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp b/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp index 8b2fe01272..f6a9fc861c 100644 --- a/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp +++ b/src/ifcgeom/mapping/IfcRevolvedAreaSolid.cpp @@ -43,11 +43,20 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRevolvedAreaSolid* inst) { angle = ang; } + taxonomy::direction3::ptr axis; + if (inst->Axis()->Axis()) { + axis = taxonomy::cast(map(inst->Axis()->Axis())); + } else { + // IfcAxis1Placement.Axis is optional, and defaults to (0, 0, 1) if not provided. + axis = taxonomy::make(0, 0, 1); + } + + return taxonomy::make( matrix, taxonomy::cast(map(inst->SweptArea())), taxonomy::cast(map(inst->Axis()->Location())), - taxonomy::cast(map(inst->Axis()->Axis())), + axis, angle ); diff --git a/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp b/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp index f83c4ecf03..c5fe21b58b 100644 --- a/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp +++ b/src/ifcgeom/mapping/IfcSurfaceOfRevolution.cpp @@ -31,11 +31,19 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceOfRevolution* inst) { matrix = taxonomy::cast(map(inst->Position())); } + taxonomy::direction3::ptr axis; + if (inst->AxisPosition()->Axis()) { + axis = taxonomy::cast(map(inst->AxisPosition()->Axis())); + } else { + // IfcAxis1Placement.Axis is optional, and defaults to (0, 0, 1) if not provided. + axis = taxonomy::make(0, 0, 1); + } + return taxonomy::make( matrix, taxonomy::cast(map(inst->SweptCurve())), taxonomy::cast(map(inst->AxisPosition()->Location())), - taxonomy::cast(map(inst->AxisPosition()->Axis())), + axis, boost::none ); } diff --git a/src/ifcgeom/mapping/IfcToroidalSurface.cpp b/src/ifcgeom/mapping/IfcToroidalSurface.cpp index ce17a37dbc..d73e90bb1b 100644 --- a/src/ifcgeom/mapping/IfcToroidalSurface.cpp +++ b/src/ifcgeom/mapping/IfcToroidalSurface.cpp @@ -24,16 +24,11 @@ using namespace ifcopenshell::geometry; #ifdef SCHEMA_HAS_IfcToroidalSurface taxonomy::ptr mapping::map_impl(const IfcSchema::IfcToroidalSurface* inst) { - return nullptr; - - /* - gp_Trsf trsf; - IfcGeom::Kernel::convert(inst->Position(), trsf); - - // IfcElementarySurface.Position has unit scale factor - face = BRepBuilderAPI_MakeFace(new Geom_ToroidalSurface(gp::XOY(), inst->MajorRadius() * length_unit_, inst->MinorRadius() * length_unit_), getValue(GV_PRECISION)).Face().Moved(trsf); - return true; - */ + auto c = taxonomy::make(); + c->radius1 = inst->MajorRadius() * length_unit_; + c->radius2 = inst->MinorRadius() * length_unit_; + c->matrix = taxonomy::cast(map(inst->Position())); + return c; } #endif diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index f98bfe232d..edfdd3a13b 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -691,6 +691,10 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceStyle* style) { } taxonomy::ptr mapping::map(const IfcBaseInterface* inst) { + if (inst == nullptr) { + Logger::Error("Warning nullptr passed to map() function"); + return nullptr; + } auto iden = inst->as()->identity(); if (use_caching_) { std::lock_guard guard(cache_guard_); diff --git a/src/ifcopenshell-python/Makefile b/src/ifcopenshell-python/Makefile index 78370a46fb..b6cfe15b17 100644 --- a/src/ifcopenshell-python/Makefile +++ b/src/ifcopenshell-python/Makefile @@ -68,8 +68,8 @@ ifeq ($(PLATFORM), win64) PLATFORMTAG:=win_amd64 endif -BINARY_VERSION:=0.8.4 -BUILD_COMMIT:=e8eb5e4 +BINARY_VERSION:=0.8.5 +BUILD_COMMIT:=1c5b825 IOS_URL:=https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-$(PYNUMBER)-v$(BINARY_VERSION)-$(BUILD_COMMIT)-$(PLATFORM).zip IFCCONVERT_URL:=https://s3.amazonaws.com/ifcopenshell-builds/IfcConvert-v$(BINARY_VERSION)-$(BUILD_COMMIT)-$(PLATFORM).zip diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index fb38426aff..998eb6e5de 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -53,6 +53,7 @@ Example: for wall in walls: print(wall.Name) """ + from __future__ import annotations import os diff --git a/src/ifcopenshell-python/ifcopenshell/api/alignment/_create_offset_curve_representation.py b/src/ifcopenshell-python/ifcopenshell/api/alignment/_create_offset_curve_representation.py index a5675a4dc2..28a9f6ef49 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/alignment/_create_offset_curve_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/alignment/_create_offset_curve_representation.py @@ -36,7 +36,7 @@ def _create_offset_curve_representation( expected_type = "IfcAlignment" if not alignment.is_a(expected_type): raise TypeError(f"Expected {expected_type} but got {alignment.is_a()}") - + expected_type = "IfcPointByDistanceExpression" for offset in offsets: if not offset.is_a(expected_type): diff --git a/src/ifcopenshell-python/ifcopenshell/express/bootstrap.py b/src/ifcopenshell-python/ifcopenshell/express/bootstrap.py index 9ff87d5ad0..ef3c3c3ef0 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/bootstrap.py +++ b/src/ifcopenshell-python/ifcopenshell/express/bootstrap.py @@ -163,7 +163,18 @@ statements = [] terminals = reduce(lambda x, y: x | y, (find_bytype(e, Terminal) for id, e in express)) keywords = list(filter(operator.attrgetter("is_keyword"), terminals)) negated_keywords = map(lambda s: "~%s" % s, keywords) -no_action = {"letter", "digit", "digits", "real_literal", "integer_literal", "string_literal", "simple_string_literal", "letter", "not_quote", "not_paren_star_quote_special"} +no_action = { + "letter", + "digit", + "digits", + "real_literal", + "integer_literal", + "string_literal", + "simple_string_literal", + "letter", + "not_quote", + "not_paren_star_quote_special", +} while True: emitted_in_loop = set() @@ -194,7 +205,9 @@ for id in to_emit: if id in to_combine: stmt = "Suppress%s" % stmt if id not in no_action and not isinstance(expr.contents, Keyword): - children = list(map(operator.attrgetter('contents'), reduce(lambda x, y: x | y, (find_bytype(e, Keyword) for e in [expr])))) + children = list( + map(operator.attrgetter("contents"), reduce(lambda x, y: x | y, (find_bytype(e, Keyword) for e in [expr]))) + ) has_duplicates = len(children) > len(set(children)) node_type = "ListNode" if ("ZeroOrMore" in stmt or has_duplicates) else "Node" action = ".setParseAction(%s)" % ( @@ -243,5 +256,4 @@ if __name__ == "__main__": mdl = importlib.import_module(output) mdl.Generator(m).emit() sys.stdout.write(m.schema.name) -""" % ("\n ".join(statements)) - ) +""" % ("\n ".join(statements))) diff --git a/src/ifcopenshell-python/ifcopenshell/express/cat.py b/src/ifcopenshell-python/ifcopenshell/express/cat.py index d6e7b2c880..373afeb1d5 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/cat.py +++ b/src/ifcopenshell-python/ifcopenshell/express/cat.py @@ -1,15 +1,16 @@ import sys, fileinput -if sys.platform == "win32" and not hasattr(sys.stdout, 'buffer'): +if sys.platform == "win32" and not hasattr(sys.stdout, "buffer"): import os, msvcrt + msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) files = sys.argv[1:] -if files[0] == '-o': - b = open(files[1], 'wb') +if files[0] == "-o": + b = open(files[1], "wb") files = files[2:] else: - b = getattr(sys.stdout, 'buffer', sys.stdout) + b = getattr(sys.stdout, "buffer", sys.stdout) -for line in fileinput.input(files=files, mode='rb'): +for line in fileinput.input(files=files, mode="rb"): b.write(line) diff --git a/src/ifcopenshell-python/ifcopenshell/express/codegen.py b/src/ifcopenshell-python/ifcopenshell/express/codegen.py index fe997091b1..dfcf5083c8 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/codegen.py +++ b/src/ifcopenshell-python/ifcopenshell/express/codegen.py @@ -26,7 +26,7 @@ def indent(n, s): else: strs = s splitted = itertools.chain.from_iterable(map(functools.partial(str.split, sep="\n"), map(str, strs))) - return "\n".join(" "*n + l for l in splitted) + return "\n".join(" " * n + l for l in splitted) class Base: diff --git a/src/ifcopenshell-python/ifcopenshell/express/header.py b/src/ifcopenshell-python/ifcopenshell/express/header.py index 4cc8c8ea84..6059354925 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/header.py +++ b/src/ifcopenshell-python/ifcopenshell/express/header.py @@ -28,6 +28,7 @@ from collections import defaultdict USE_VIRTUAL_INHERITANCE = True + class Header(codegen.Base): def __init__(self, mapping): declarations = [] diff --git a/src/ifcopenshell-python/ifcopenshell/express/implementation.py b/src/ifcopenshell-python/ifcopenshell/express/implementation.py index 248bbd6e86..bc4b080ad6 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/implementation.py +++ b/src/ifcopenshell-python/ifcopenshell/express/implementation.py @@ -69,7 +69,7 @@ class Implementation(codegen.Base): templates.enum_from_string_stmt % dict(context, **locals()) for value in enum.values ), ) - + if USE_VIRTUAL_INHERITANCE: for name, enum in mapping.schema.selects.items(): write( @@ -118,10 +118,7 @@ class Implementation(codegen.Base): null_check = "" if arg["is_optional"]: - attr_check = ( - "if(get_attribute_value(%d).isNull()) { return %%s; }" - % (arg["index"] - 1,) - ) + attr_check = "if(get_attribute_value(%d).isNull()) { return %%s; }" % (arg["index"] - 1,) if "boost::optional" in arg["full_type"]: null_check = attr_check % "boost::none" else: @@ -157,7 +154,7 @@ class Implementation(codegen.Base): return templates.set_attr_stmt_enum elif arg["is_templated_list"] and not (select or simple or express): return templates.set_attr_stmt_array - elif arg["full_type"].endswith('*'): + elif arg["full_type"].endswith("*"): return templates.set_attr_instance else: return templates.set_attr_stmt @@ -178,7 +175,9 @@ class Implementation(codegen.Base): "non_optional_type": arg["non_optional_type"].replace("::Value", ""), "star_if_optional": "*" if "boost::optional" in arg["full_type"] else "", "check_optional_set_begin": "if (v) {" if "boost::optional" in arg["full_type"] else "", - "check_optional_set_else": "} else {" if "boost::optional" in arg["full_type"] else "if constexpr (false)", + "check_optional_set_else": ( + "} else {" if "boost::optional" in arg["full_type"] else "if constexpr (false)" + ), "check_optional_set_end": "}" if "boost::optional" in arg["full_type"] else "", }, ) @@ -193,11 +192,15 @@ class Implementation(codegen.Base): tmpl = ( templates.constructor_stmt_array if arg["is_templated_list"] - else templates.constructor_stmt_enum - if arg["is_enum"] - else templates.constructor_stmt_instance - if arg["full_type"].endswith('*') - else templates.constructor_stmt + else ( + templates.constructor_stmt_enum + if arg["is_enum"] + else ( + templates.constructor_stmt_instance + if arg["full_type"].endswith("*") + else templates.constructor_stmt + ) + ) ) impl = tmpl % { "name": deref_name, @@ -321,7 +324,7 @@ class Implementation(codegen.Base): else templates.simpletype_impl_is_without_supertype ) - constructor = templates.constructor_single_initlist# if superclass else templates.constructor + constructor = templates.constructor_single_initlist # if superclass else templates.constructor simpletype_impl_cast = ( templates.simpletype_impl_cast_templated @@ -374,8 +377,21 @@ class Implementation(codegen.Base): ("IfcEntityInstanceData&& e",), "", ), - ("", "", constructor, "", ("%s v" % type_str,), ("set_attribute_value(0, v%s);" % ("->generalize()" if mapping.is_templated_list(type) else ""))) if mapping.simple_type_parent(class_name) is None else \ - ("v", "", constructor, "", ("%s v" % type_str,), ""), + ( + ( + "", + "", + constructor, + "", + ("%s v" % type_str,), + ( + "set_attribute_value(0, v%s);" + % ("->generalize()" if mapping.is_templated_list(type) else "") + ), + ) + if mapping.simple_type_parent(class_name) is None + else ("v", "", constructor, "", ("%s v" % type_str,), "") + ), ("", "", templates.cast_function, type_str, (), simpletype_impl_cast), ), ), diff --git a/src/ifcopenshell-python/ifcopenshell/express/mapping.py b/src/ifcopenshell-python/ifcopenshell/express/mapping.py index 7ebac2478b..609f346c2c 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/mapping.py +++ b/src/ifcopenshell-python/ifcopenshell/express/mapping.py @@ -25,6 +25,7 @@ import schema from header import USE_VIRTUAL_INHERITANCE + class Mapping: express_to_cpp_typemapping = { diff --git a/src/ifcopenshell-python/ifcopenshell/express/nodes.py b/src/ifcopenshell-python/ifcopenshell/express/nodes.py index 34d3ef747b..2b8b872c83 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/nodes.py +++ b/src/ifcopenshell-python/ifcopenshell/express/nodes.py @@ -23,6 +23,7 @@ import operator import collections import bootstrap + class Node: def __init__(self, s, loc, tokens, rule=None): self.rule = rule or (type(self).__name__) @@ -58,15 +59,15 @@ class ListNode: rules_as_list = set() for t in self.tokens: - r = getattr(t, 'rule', None) + r = getattr(t, "rule", None) if r: rules_as_list.add(r) self.dict_tokens[r].append(t) - + for r, t in tokens.asDict().items(): if r not in rules_as_list: self.dict_tokens[r].append(t) - + self.flat = sum([getattr(t, "flat", [t]) for t in self.tokens], []) def __repr__(self): @@ -74,7 +75,7 @@ class ListNode: def __iter__(self): return iter(self.tokens) - + # Somehow indexing messes up the pyparsing results, so instead of x[0] use list(x)[0] # def __getitem__(self, i): # return self.tokens[i] @@ -110,7 +111,7 @@ def format_clause(exp): return "".join(whitespace(term) for term in exp.flat) -class TypeDeclaration(Node): +class TypeDeclaration(Node): name = property(lambda self: self.type_id[0]) utype = property(lambda self: self.underlying_type.any().any()) type = property(lambda self: self.utype[0] if isinstance(self.utype, list) else self.utype) @@ -245,7 +246,8 @@ class NamedType(Node): def do_try(fn): try: return fn() - except: pass + except: + pass def get_rule_id(x): @@ -255,8 +257,14 @@ def get_rule_id(x): if matches: return matches[0] + rule_dependencies = { - k: list(map(operator.attrgetter('contents'), bootstrap.reduce(lambda x, y: x | y, (bootstrap.find_bytype(e, bootstrap.Keyword) for e in [v])))) \ + k: list( + map( + operator.attrgetter("contents"), + bootstrap.reduce(lambda x, y: x | y, (bootstrap.find_bytype(e, bootstrap.Keyword) for e in [v])), + ) + ) for k, v in bootstrap.express } @@ -264,16 +272,17 @@ all_rules = [k for k, e in bootstrap.express] rule_definitions = {k: v for k, v in bootstrap.express} + def to_tree(x, key=None): - + def prune(di): # translate class names back to grammar rules if nested actions are encountered di = {get_rule_id(k) or k: v for k, v in di.items()} - + def replace_synonyms(x): for y in x: yield y - if False: # y in di: + if False: # y in di: # production element from grammar is found in parsed data, # return that. @@ -292,19 +301,21 @@ def to_tree(x, key=None): yield S # Do this recursively yield from replace_synonyms([S]) - + # is this a concatenation with zero or more synonyms? then also processs that # @todo catches: # - simple_expression = term { add_like_op term } . # but should probably also work on # - a = b { b } # in which case the second Concat would be eliminated - elif isinstance(rule, bootstrap.Concat) and \ - len(rule.contents) == 2 and \ - is_synonym(rule.contents[0]) and \ - isinstance(rule.contents[1].contents, bootstrap.Repeated) and \ - isinstance(rule.contents[1].contents.contents[0], bootstrap.Concat) and \ - str(rule.contents[1].contents.contents[0].contents[1]) == str(rule.contents[0]): + elif ( + isinstance(rule, bootstrap.Concat) + and len(rule.contents) == 2 + and is_synonym(rule.contents[0]) + and isinstance(rule.contents[1].contents, bootstrap.Repeated) + and isinstance(rule.contents[1].contents.contents[0], bootstrap.Concat) + and str(rule.contents[1].contents.contents[0].contents[1]) == str(rule.contents[0]) + ): S = is_synonym(rule.contents[0]) yield S # Do this recursively @@ -315,13 +326,13 @@ def to_tree(x, key=None): if key == "aggregation_types": # hack hack hack apparently the parser can't distinguish these subrules += list(replace_synonyms(rule_dependencies["general_aggregation_types"])) - + if rule_dependencies[key] and not subrules: # sometimes an intermediate production rule is missing # from the pyparsing output, e.g from parameter to simple_expression # directly. Recover from this. subrules = sum(map(rule_dependencies.__getitem__, rule_dependencies[key]), []) - + if not isinstance(rule_definitions[key], bootstrap.Union): # Filter out terminals when not a union. E.g no # reason to retain TYPE, END_TYPE, but operators @@ -331,7 +342,7 @@ def to_tree(x, key=None): vs = list(di.values()) return {k: v for k, v in di.items() if k in subrules or (k == key and len(vs) == 1 and vs[0] not in all_rules)} - + def simplify(di): if isinstance(di, list): if set(map(type, di)) == {str} and set(map(len, di)) == {1}: @@ -343,11 +354,11 @@ def to_tree(x, key=None): return {k: simplify(v) for k, v in di.items()} else: return di - + if isinstance(x, ListNode): d = to_tree(x.dict_tokens, key=get_rule_id(x) or key) - if key == 'if_stmt': + if key == "if_stmt": # The definition of if statement if (roughy): # 'if' expr 'then' stmt+ 'else' stmt+ # this causes stmt to be joined under the same @@ -355,39 +366,41 @@ def to_tree(x, key=None): # `else_stmt` that collects the second group # of stmts. - statements = x.dict_tokens['stmt'] - + statements = x.dict_tokens["stmt"] + else_index = None if_nesting = 0 - for i, tk in enumerate(x.flat): - if tk == 'if': if_nesting += 1 - if tk == 'end_if': if_nesting -= 1 - if tk == 'else' and if_nesting == 1: + for i, tk in enumerate(x.flat): + if tk == "if": + if_nesting += 1 + if tk == "end_if": + if_nesting -= 1 + if tk == "else" and if_nesting == 1: else_index = i if else_index: indices = [] for s in statements: for i in range(max(indices, default=0), len(x.flat)): - if x.flat[i:i+len(s.flat)] == s.flat: + if x.flat[i : i + len(s.flat)] == s.flat: indices.append(i) break assert len(indices) == len(statements) before_else = [i < else_index for i in indices] - else_stmt = [st for b, st in zip(before_else, d['stmt']) if not b] - d['stmt'] = [st for b, st in zip(before_else, d['stmt']) if b] + else_stmt = [st for b, st in zip(before_else, d["stmt"]) if not b] + d["stmt"] = [st for b, st in zip(before_else, d["stmt"]) if b] if else_stmt: - d['else_stmt'] = else_stmt - - if key == 'formal_parameter': + d["else_stmt"] = else_stmt + + if key == "formal_parameter": # Not so pretty hack to fix the overwriting of simple_id-like # ast nodes. The full solution would probably to register parse # actions. And directly reassign. - pid = d['parameter_id'][0][0] - d['parameter_id'][0] = x.flat[:x.flat.index(pid)+1:2] + pid = d["parameter_id"][0][0] + d["parameter_id"][0] = x.flat[: x.flat.index(pid) + 1 : 2] if key is None: return {get_rule_id(x): d} @@ -400,7 +413,10 @@ def to_tree(x, key=None): elif isinstance(x, dict): # d = {k: to_tree(v, key=k) for k, v in x.items()} # not fully understood, but when finding specific node Types and production rules, prioritize the former - d = {get_rule_id(k) or k: to_tree(v, key=k) for k, v in sorted(x.items(), key=lambda p: get_rule_id(p[0]) is not None)} + d = { + get_rule_id(k) or k: to_tree(v, key=k) + for k, v in sorted(x.items(), key=lambda p: get_rule_id(p[0]) is not None) + } return simplify(prune(d)) elif isinstance(x, list): return [to_tree(v, key=key) for v in x] @@ -459,7 +475,8 @@ class SuperTypeExpression(Node): else: constraint = self.supertype_rule[0] return [ - list(list(s)[0])[0].simple_id for s in list(list(list(constraint.subtype_constraint[0].supertype_expression[0])[0])[0].one_of[0])[2::2] + list(list(s)[0])[0].simple_id + for s in list(list(list(constraint.subtype_constraint[0].supertype_expression[0])[0])[0].one_of[0])[2::2] ] sub_types = property(get_sub_types) @@ -576,10 +593,11 @@ class ProcedureDeclaration(ListNode): @property def name(self): return self.flat[1] - - + + class FunctionDeclaration(ProcedureDeclaration): pass - + + class RuleDeclaration(ProcedureDeclaration): pass diff --git a/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py b/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py index 41fc6764c1..a77936d853 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py @@ -48,11 +48,7 @@ def to_graph(tree): # bootstrap.py that result in an intermediate list index node in to_tree() # Start with the intermediate nodes and filter out root (needs to have predecessors) - intermediate = [ - n - for n in g.nodes - if g.nodes[n].get("label") is None and list(g.predecessors(n)) - ] + intermediate = [n for n in g.nodes if g.nodes[n].get("label") is None and list(g.predecessors(n))] for n in intermediate: pr = list(g.predecessors(n)) @@ -82,8 +78,7 @@ def to_graph(tree): for n in g.nodes: if ( len(list(g.successors(n))) == 0 - and g.nodes[n].get("label") - not in ifcopenshell.express.express_parser.all_rules + and g.nodes[n].get("label") not in ifcopenshell.express.express_parser.all_rules ): g.nodes[n]["is_terminal"] = True @@ -105,8 +100,7 @@ def write_dot(fn, g): def format(di): Q = '"' inner = ",".join( - f"{k}={'' if v.startswith('<') else Q}{v}{'' if v.startswith('<') else Q}" - for k, v in di.items() + f"{k}={'' if v.startswith('<') else Q}{v}{'' if v.startswith('<') else Q}" for k, v in di.items() ) if inner: inner = f"[{inner}]" @@ -179,9 +173,7 @@ class context: def has_inverse(self, a): for r in self.rules: - if a in map( - lambda n: self.graph.nodes[n].get("label"), self.graph.predecessors(r) - ): + if a in map(lambda n: self.graph.nodes[n].get("label"), self.graph.predecessors(r)): return True return False @@ -190,10 +182,7 @@ class context: yield context(self.graph, [r]) def descendants(self): - return [ - b.rules[0][len(self.rules[0]) + 1 :] - for b in self.branches(allow_multiple=True) - ] + return [b.rules[0][len(self.rules[0]) + 1 :] for b in self.branches(allow_multiple=True)] def __repr__(self): try: @@ -206,14 +195,11 @@ class context: assert len(self.rules) == 1 nodes = itertools.chain( self.rules, - itertools.chain.from_iterable( - dict(nx.bfs_successors(self.graph, self.rules[0])).values() - ), + itertools.chain.from_iterable(dict(nx.bfs_successors(self.graph, self.rules[0])).values()), ) terminals_or_values = list( filter( - lambda n: self.graph.nodes[n].get("is_terminal") - or self.graph.nodes[n].get("value"), + lambda n: self.graph.nodes[n].get("is_terminal") or self.graph.nodes[n].get("value"), nodes, ) ) @@ -375,9 +361,7 @@ def calc_{class_name}_{str(derived_attr.attribute_decl.redeclared_attribute.qual """ if context.entity_body.derive_clause: - statements.extend( - map(format_derived, context.entity_body.derive_clause.branches()) - ) + statements.extend(map(format_derived, context.entity_body.derive_clause.branches())) return "\n\n".join(statements) @@ -420,10 +404,12 @@ def process_expression(context): exclude=[context.rel_op_extended], ) else: - if len(context.simple_expression.branches()) == 2 and str(context.rel_op_extended) == 'in': + if len(context.simple_expression.branches()) == 2 and str(context.rel_op_extended) == "in": # IfcBlobTexture try: - is_literal_str_list = set(map(type, ast.literal_eval(str(context.simple_expression.branches()[1])))) == {str} + is_literal_str_list = set( + map(type, ast.literal_eval(str(context.simple_expression.branches()[1]))) + ) == {str} except: is_literal_str_list = False if is_literal_str_list: @@ -567,9 +553,7 @@ def process_function_decl(context): str.lower, map( str, - context.function_head.formal_parameter.parameter_id.branches( - allow_multiple=True - ), + context.function_head.formal_parameter.parameter_id.branches(allow_multiple=True), ), ) return f"def {context.function_head.function_id}({', '.join(arguments)}):\n{indent(4, context.algorithm_head.local_decl)}\n{indent(4, context.stmt.branches())}" @@ -582,9 +566,7 @@ def process_query(context): def process_local_variable(context): if context.expression: expr = str(context.expression) - if ( - context.parameter_type.generalized_types.general_aggregation_types.general_set_type - ): + if context.parameter_type.generalized_types.general_aggregation_types.general_set_type: expr = re.sub(r"(\[[^\]]*\])", "express_set(\\1)", expr) return "%s = %s" % (str(context.variable_id).lower(), expr) @@ -623,9 +605,7 @@ def process_assignment(context): if m := re.match(r"^([^\[]+)\[([^\[]+)\]$", lhs): # @todo ugly regex hack aggr, index = m.groups() - return ( - f"temp = list({aggr})\ntemp[{index}] = {context.expression}\n{aggr} = temp" - ) + return f"temp = list({aggr})\ntemp[{index}] = {context.expression}\n{aggr} = temp" else: return "%s = %s" % (lhs, context.expression) @@ -643,11 +623,7 @@ def process_case_action(context): def process_case_statement(context): branches = context.branches( - exclude=[ - getattr(context, v) - for v in context.descendants() - if not v.startswith("case_action") - ] + exclude=[getattr(context, v) for v in context.descendants() if not v.startswith("case_action")] ) if context.stmt and context.stmt.branches(): branches += [f"else:\n{indent(4, context.stmt)}"] @@ -658,9 +634,7 @@ def process_aggregate_initializer(context): if context.element.repetition: return "([%s] * %s)" % (context.element.expression, context.element.repetition) else: - return "[%s]" % ",".join( - map(str, context.element.branches() if context.element else ()) - ) + return "[%s]" % ",".join(map(str, context.element.branches() if context.element else ())) def process_index(context): @@ -676,9 +650,7 @@ def process_index(context): codegen_rule("function_call", process_function_call) codegen_rule( "actual_parameter_list", - lambda context: ",".join( - map(str, context.expression.branches() if context.expression else []) - ), + lambda context: ",".join(map(str, context.expression.branches() if context.expression else [])), ) codegen_rule("entity_decl", functools.partial(process_type_decl, "entity")) codegen_rule("rule_decl", process_rule_decl) @@ -696,9 +668,7 @@ codegen_rule("simple_factor", simple_concat) codegen_rule("primary", simple_concat) codegen_rule("qualifier", simple_concat) codegen_rule("return_stmt", lambda context: "return %s" % context) -codegen_rule( - "compound_stmt", lambda context: "\n".join(map(str, context.stmt.branches())) -) +codegen_rule("compound_stmt", lambda context: "\n".join(map(str, context.stmt.branches()))) codegen_rule("if_stmt", process_if_stmt) codegen_rule("repeat_stmt", process_repeat_stmt) # codegen_rule("index", lambda context: '**express_index(%s)' % context) @@ -707,19 +677,14 @@ codegen_rule("index_qualifier", process_index) codegen_rule("group_qualifier", lambda context: empty()) codegen_rule("attribute_qualifier", lambda context: ".%s" % context) codegen_rule("rel_op", process_rel_op) -codegen_rule( - "built_in_constant", lambda context: "None" if str(context) == "?" else str(context) -) +codegen_rule("built_in_constant", lambda context: "None" if str(context) == "?" else str(context)) codegen_rule("assignment_stmt", process_assignment) codegen_rule("local_variable", process_local_variable) codegen_rule("local_decl", lambda context: "\n".join(map(str, context.branches()))) codegen_rule("general_ref/parameter_ref", make_lowercase) codegen_rule( "qualifiable_factor/attribute_ref", - make_lowercase_if( - lambda context: str(context) - not in set(map(str, schema.all_declarations.keys())) - ), + make_lowercase_if(lambda context: str(context) not in set(map(str, schema.all_declarations.keys()))), ) codegen_rule("case_action", process_case_action) codegen_rule("case_stmt", process_case_statement) @@ -824,17 +789,17 @@ if __name__ == "__main__": import subprocess schema = ifcopenshell.express.express_parser.parse(sys.argv[1]).schema - + try: ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema.name) except: # @nb note the difference here between: - # + # # - ifcopenshell.express.express_parser.parse # - ifcopenshell.express.parse.parse - # + # # First generates a pyparsing AST - # + # # Second populates a latebound schema # that can be registered in C++. builder = ifcopenshell.express.parse(sys.argv[1]) @@ -1056,13 +1021,13 @@ INDETERMINATE = indeterminate_type() if isinstance(v, str): nl = "\n" es = "\\n" - n[ - "label" - ] = f'<
{n.get("label")}
{v.replace("<", "<").replace(">", ">").replace(nl, "
")}
>' + n["label"] = ( + f'<
{n.get("label")}
{v.replace("<", "<").replace(">", ">").replace(nl, "
")}
>' + ) elif isinstance(v, empty): - n[ - "label" - ] = f'<
{n.get("label")}
---
>' + n["label"] = ( + f'<
{n.get("label")}
---
>' + ) fn = f"{nm}.dot" write_dot(fn, G) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rule_executor.py b/src/ifcopenshell-python/ifcopenshell/express/rule_executor.py index 9201e480be..68240aeddd 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rule_executor.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rule_executor.py @@ -9,24 +9,28 @@ from codegen import indent def reverse_compile(s): - return re.sub(r'\bself\b', 'SELF', re.sub( - r"\s*\-\s*EXPRESS_ONE_BASED_INDEXING", - "", + return re.sub( + r"\bself\b", + "SELF", re.sub( - ", )?+.(, INDETERMINATE)\\"[::-1], - "]\\1[", + r"\s*\-\s*EXPRESS_ONE_BASED_INDEXING", + "", re.sub( - r", '(\w+)', INDETERMINATE\)", - ".\\1", - s.strip() - .replace("len(", "SIZEOF(") - .replace("assert ", "") - .replace(" is not False", "") - .replace("express_getattr(", "") - .replace("express_getitem(", ""), + ", )?+.(, INDETERMINATE)\\"[::-1], + "]\\1[", + re.sub( + r", '(\w+)', INDETERMINATE\)", + ".\\1", + s.strip() + .replace("len(", "SIZEOF(") + .replace("assert ", "") + .replace(" is not False", "") + .replace("express_getattr(", "") + .replace("express_getitem(", ""), + )[::-1], )[::-1], - )[::-1], - )) + ), + ) @dataclass @@ -68,9 +72,13 @@ def run(f: ifcopenshell.file, logger: Logger) -> None: if hasattr(logger, "set_instance"): # when using the json logger, we notify it of the relevant instance - pre_annotate_instance = lambda instance: logger.set_state('instance', instance) if hasattr(logger, 'set_state') else None + pre_annotate_instance = lambda instance: ( + logger.set_state("instance", instance) if hasattr(logger, "set_state") else None + ) post_annotate_instance = lambda instance: instance - pre_annotate_attribute = lambda attribute: logger.set_state('attribute', attribute) if hasattr(logger, 'set_state') else None + pre_annotate_attribute = lambda attribute: ( + logger.set_state("attribute", attribute) if hasattr(logger, "set_state") else None + ) post_annotate_attribute = lambda attribute: None else: # when using the normal text logger the instance is appended to the method @@ -90,13 +98,13 @@ def run(f: ifcopenshell.file, logger: Logger) -> None: import time import subprocess - current_dir_files = {fn.lower(): fn for fn in os.listdir('.')} - schema_name = str(f.schema_identifier).split(' ')[-1].lower() - schema_path = current_dir_files.get(schema_name + '.exp') - fn = schema_path[:-4] + '.py' + current_dir_files = {fn.lower(): fn for fn in os.listdir(".")} + schema_name = str(f.schema_identifier).split(" ")[-1].lower() + schema_path = current_dir_files.get(schema_name + ".exp") + fn = schema_path[:-4] + ".py" if not os.path.exists(fn): subprocess.run([sys.executable, "-m", "ifcopenshell.express.rule_compiler", schema_path, fn], check=True) - time.sleep(1.) + time.sleep(1.0) source = open(fn, "r").read() a = ast.parse(source) @@ -108,12 +116,14 @@ def run(f: ifcopenshell.file, logger: Logger) -> None: rules = list(filter(lambda x: hasattr(x, "SCOPE"), scope.values())) - if hasattr(logger, 'set_state'): - logger.set_state('type', 'global_rule') + if hasattr(logger, "set_state"): + logger.set_state("type", "global_rule") for R in [r for r in rules if r.SCOPE == "file"]: try: R()(f) + except RecursionError as e: + logger.info(str(e)) except Exception as e: ln = e.__traceback__.tb_next.tb_lineno pre_annotate_attribute(R.__name__) @@ -127,17 +137,15 @@ def run(f: ifcopenshell.file, logger: Logger) -> None: ) ) - if hasattr(logger, 'set_state'): - logger.set_state('type', 'simpletype_rule') + if hasattr(logger, "set_state"): + logger.set_state("type", "simpletype_rule") types = {} subtypes = collections.defaultdict(list) for d in S.declarations(): if isinstance(d, ifcopenshell.ifcopenshell_wrapper.type_declaration): types[d.name()] = d - if isinstance( - d.declared_type(), ifcopenshell.ifcopenshell_wrapper.named_type - ): + if isinstance(d.declared_type(), ifcopenshell.ifcopenshell_wrapper.named_type): subtypes[d.declared_type().declared_type().name()].append(d.name()) D = collections.defaultdict(list) @@ -170,6 +178,8 @@ def run(f: ifcopenshell.file, logger: Logger) -> None: for R in D[type_name(type)]: try: R()(fix_type(value)) + except RecursionError as e: + logger.info(str(e)) except Exception as e: ln = e.__traceback__.tb_next.tb_lineno pre_annotate_instance(instance) @@ -220,6 +230,8 @@ def run(f: ifcopenshell.file, logger: Logger) -> None: for inst in f: try: values = list(inst) + except RecursionError as e: + logger.info(str(e)) except Exception as e: if hasattr(logger, "set_state"): logger.error(str(e)) @@ -228,22 +240,22 @@ def run(f: ifcopenshell.file, logger: Logger) -> None: continue entity = S.declaration_by_name(inst.is_a()) attrs = entity.all_attributes() - for i, (attr, val, is_derived) in enumerate( - zip(attrs, values, entity.derived()) - ): + for i, (attr, val, is_derived) in enumerate(zip(attrs, values, entity.derived())): if is_derived: # @todo pass else: check(val, attr.type_of_attribute(), instance=inst) - if hasattr(logger, 'set_state'): - logger.set_state('type', 'entity_rule') + if hasattr(logger, "set_state"): + logger.set_state("type", "entity_rule") for R in [r for r in rules if r.SCOPE == "entity"]: for inst in f.by_type(R.TYPE_NAME): try: R()(inst) + except RecursionError as e: + logger.info(str(e)) except Exception as e: ln = e.__traceback__.tb_next.tb_lineno pre_annotate_instance(inst) diff --git a/src/ifcopenshell-python/ifcopenshell/express/schema.py b/src/ifcopenshell-python/ifcopenshell/express/schema.py index ebb050d1ae..315db817b6 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/schema.py +++ b/src/ifcopenshell-python/ifcopenshell/express/schema.py @@ -27,6 +27,7 @@ if tuple(map(int, platform.python_version_tuple())) < (2, 7): collections.OrderedDict = ordereddict.OrderedDict + # According to ISO 10303-11 7.1.2: Letters: "... The case of # letters is significant only within explicit string literals." class OrderedCaseInsensitiveDict_KeyObject(str): @@ -92,23 +93,21 @@ class Schema: sort = lambda d: OrderedCaseInsensitiveDict(sorted(d)) - declarations = [ - d.any()[0] - for d in schema_declarations - if d.rule == "declaration" - ] + [ - d - for d in schema_declarations - if d.rule == "RuleDeclaration" + declarations = [d.any()[0] for d in schema_declarations if d.rule == "declaration"] + [ + d for d in schema_declarations if d.rule == "RuleDeclaration" ] - + self.types = sort([(t.name, t) for t in declarations if isinstance(t, nodes.TypeDeclaration)]) self.entities = sort([(t.name, t) for t in declarations if isinstance(t, nodes.EntityDeclaration)]) self.rules = sort([(t.name, t) for t in declarations if isinstance(t, nodes.RuleDeclaration)]) self.functions = sort([(t.name, t) for t in declarations if isinstance(t, nodes.FunctionDeclaration)]) - self.keys = list(self.types.keys()) + list(self.entities.keys()) + list(self.rules.keys()) + list(self.functions.keys()) - self.all_declarations = {k: v for d in (self.types, self.entities, self.rules, self.functions) for k, v in d.items()} + self.keys = ( + list(self.types.keys()) + list(self.entities.keys()) + list(self.rules.keys()) + list(self.functions.keys()) + ) + self.all_declarations = { + k: v for d in (self.types, self.entities, self.rules, self.functions) for k, v in d.items() + } of_type = lambda *types: sort( [(a, b.type) for a, b in self.types.items() if any(isinstance(b.type, ty) for ty in types)] diff --git a/src/ifcopenshell-python/ifcopenshell/express/schema_class.py b/src/ifcopenshell-python/ifcopenshell/express/schema_class.py index 50a4e50c5d..d7595ad6cb 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/schema_class.py +++ b/src/ifcopenshell-python/ifcopenshell/express/schema_class.py @@ -123,6 +123,7 @@ class string_pool: def __init__(self, fn): self.di = {} self.fn = fn + def append(self, v): def _(): if i := self.di.get(v): @@ -131,7 +132,9 @@ class string_pool: i = len(self.di) self.di[v] = i return i + return self.fn(_()) + def __iter__(self): return iter(self.di.keys()) @@ -146,9 +149,9 @@ class EarlyBoundCodeWriter: "", '#include "../ifcparse/IfcSchema.h"', '#include "../ifcparse/%(schema_name_title)s.h"' % self.__dict__, - '#include ', + "#include ", "", - 'using namespace std::string_literals;', + "using namespace std::string_literals;", "using namespace IfcParse;", "", ] @@ -180,18 +183,18 @@ class EarlyBoundCodeWriter: self.statements.append("{factory_placeholder}") -# self.statements.append( -# """ -# #if defined(__clang__) -# __attribute__((optnone)) -# #elif defined(__GNUC__) || defined(__GNUG__) -# #pragma GCC push_options -# #pragma GCC optimize ("O0") -# #elif defined(_MSC_VER) -# #pragma optimize("", off) -# #endif -# """ -# ) + # self.statements.append( + # """ + # #if defined(__clang__) + # __attribute__((optnone)) + # #elif defined(__GNUC__) || defined(__GNUG__) + # #pragma GCC push_options + # #pragma GCC optimize ("O0") + # #elif defined(_MSC_VER) + # #pragma optimize("", off) + # #endif + # """ + # ) self.statements.append("IfcParse::schema_definition* %s_populate_schema() {" % self.schema_name.upper()) self.statements.append("{string_pool_placeholder}") @@ -200,7 +203,7 @@ class EarlyBoundCodeWriter: index_in_schema = self.names.index(name) ref = self.strings.append(name) self.statements.append( - ' %(schema_name)s_types[%(index_in_schema)d] = new type_declaration(%(ref)s, %(index_in_schema)d, %(declared_type)s);' + " %(schema_name)s_types[%(index_in_schema)d] = new type_declaration(%(ref)s, %(index_in_schema)d, %(declared_type)s);" % locals() ) @@ -210,7 +213,7 @@ class EarlyBoundCodeWriter: ref = self.strings.append(name) items = ",".join(self.strings.append(v) for v in enum.values) self.statements.append( - ' %(schema_name)s_types[%(index_in_schema)d] = new enumeration_type(%(ref)s, %(index_in_schema)d, {%(items)s});' + " %(schema_name)s_types[%(index_in_schema)d] = new enumeration_type(%(ref)s, %(index_in_schema)d, {%(items)s});" % locals() ) @@ -218,10 +221,14 @@ class EarlyBoundCodeWriter: schema_name = self.schema_name.upper() index_in_schema = self.names.index(name) ref = self.strings.append(name) - supertype = "0" if len(type.supertypes) == 0 else "%s_types[%d]" % (self.schema_name, self.names.index(type.supertypes[0])) + supertype = ( + "0" + if len(type.supertypes) == 0 + else "%s_types[%d]" % (self.schema_name, self.names.index(type.supertypes[0])) + ) is_abstract = "true" if type.abstract else "false" self.statements.append( - ' %(schema_name)s_types[%(index_in_schema)d] = new entity(%(ref)s, %(is_abstract)s, %(index_in_schema)d, (entity*) %(supertype)s);' + " %(schema_name)s_types[%(index_in_schema)d] = new entity(%(ref)s, %(is_abstract)s, %(index_in_schema)d, (entity*) %(supertype)s);" % locals() ) @@ -233,73 +240,89 @@ class EarlyBoundCodeWriter: map(lambda v: "%s_types[%d]" % (self.schema_name, self.names.index(v)), sorted(map(str, type.values))) ) self.statements.append( - ' %(schema_name)s_types[%(index_in_schema)d] = new select_type(%(ref)s, %(index_in_schema)d, {%(items)s});' + " %(schema_name)s_types[%(index_in_schema)d] = new select_type(%(ref)s, %(index_in_schema)d, {%(items)s});" % locals() ) def entity_attributes(self, name, attribute_definitions, is_derived): schema_name = self.schema_name.upper() index_in_schema = self.names.index(name) + def _(): index_in_schema = self.names.index(name) schema_name = self.schema_name for attr_name, decl_type, optional in attribute_definitions: attr_name_ref = self.strings.append(attr_name) optional_cpp = str(optional).lower() - yield 'new attribute(%(attr_name_ref)s, %(decl_type)s, %(optional_cpp)s)' % locals() + yield "new attribute(%(attr_name_ref)s, %(decl_type)s, %(optional_cpp)s)" % locals() + attributes = ",".join(_()) derived = ",".join(map(lambda b: str(b).lower(), is_derived)) - self.statements.append(" ((entity*)%(schema_name)s_types[%(index_in_schema)d])->set_attributes({%(attributes)s}, {%(derived)s});" % locals()) + self.statements.append( + " ((entity*)%(schema_name)s_types[%(index_in_schema)d])->set_attributes({%(attributes)s}, {%(derived)s});" + % locals() + ) def inverse_attributes(self, name, inv_attrs): schema_name = self.schema_name.upper() index_in_schema = self.names.index(name) + def _(): schema_name = self.schema_name index_in_schema = self.names.index(name) for attr_name, aggr_type, bound1, bound2, entity_ref, attribute_entity, attribute_entity_index in inv_attrs: attr_name_ref = self.strings.append(attr_name) opposite_index_in_schema = self.names.index(entity_ref) - opposite1 = '%(schema_name)s_types[%(opposite_index_in_schema)d]' % locals() + opposite1 = "%(schema_name)s_types[%(opposite_index_in_schema)d]" % locals() opposite_index_in_schema = self.names.index(attribute_entity) - opposite2 = '%(schema_name)s_types[%(opposite_index_in_schema)d]' % locals() - yield 'new inverse_attribute(%(attr_name_ref)s, inverse_attribute::%(aggr_type)s_type, %(bound1)d, %(bound2)d, ((entity*) %(opposite1)s), ((entity*) %(opposite2)s)->attributes()[%(attribute_entity_index)d])' % locals() + opposite2 = "%(schema_name)s_types[%(opposite_index_in_schema)d]" % locals() + yield "new inverse_attribute(%(attr_name_ref)s, inverse_attribute::%(aggr_type)s_type, %(bound1)d, %(bound2)d, ((entity*) %(opposite1)s), ((entity*) %(opposite2)s)->attributes()[%(attribute_entity_index)d])" % locals() + attributes = ",".join(_()) - self.statements.append(" ((entity*) %(schema_name)s_types[%(index_in_schema)d])->set_inverse_attributes({%(attributes)s});" % locals()) + self.statements.append( + " ((entity*) %(schema_name)s_types[%(index_in_schema)d])->set_inverse_attributes({%(attributes)s});" + % locals() + ) def entity_subtypes(self, name, tys): schema_name = self.schema_name.upper() index_in_schema = self.names.index(name) - subtypes = ",".join(map(lambda t: ("((entity*) %%(schema_name)s_types[%d])" % self.names.index(t)), tys)) % locals() - self.statements.append(" ((entity*) %(schema_name)s_types[%(index_in_schema)d])->set_subtypes({%(subtypes)s});" % locals()) + subtypes = ( + ",".join(map(lambda t: ("((entity*) %%(schema_name)s_types[%d])" % self.names.index(t)), tys)) % locals() + ) + self.statements.append( + " ((entity*) %(schema_name)s_types[%(index_in_schema)d])->set_subtypes({%(subtypes)s});" % locals() + ) def finalize(self, can_be_instantiated_set): schema_name = self.schema_name.upper() schema_name_title = self.schema_name.capitalize() + def _(): schema_name = self.schema_name.upper() schema_name_title = self.schema_name.capitalize() for type_name in self.names: index_in_schema = self.names.index(type_name) yield "%(schema_name)s_types[%(index_in_schema)d]" % locals() + declarations = ",".join(_()) schema_name_ref = self.strings.append(schema_name) self.statements.append( - ' return new schema_definition(%(schema_name_ref)s, {%(declarations)s}, new %(schema_name)s_instance_factory());' + " return new schema_definition(%(schema_name_ref)s, {%(declarations)s}, new %(schema_name)s_instance_factory());" % locals() ) - self.statements.append("}"); + self.statements.append("}") -# self.statements.append( -# """ -# #if defined(__clang__) -# #elif defined(__GNUC__) || defined(__GNUG__) -# #pragma GCC pop_options -# #elif defined(_MSC_VER) -# #pragma optimize("", on) -# #endif -# """ -# ) + # self.statements.append( + # """ + # #if defined(__clang__) + # #elif defined(__GNUC__) || defined(__GNUG__) + # #pragma GCC pop_options + # #elif defined(_MSC_VER) + # #pragma optimize("", on) + # #endif + # """ + # ) self.statements.extend( ( @@ -340,24 +363,18 @@ class EarlyBoundCodeWriter: ) ) - self.statements[self.statements.index("{factory_placeholder}")] = ( - """ + self.statements[self.statements.index("{factory_placeholder}")] = """ class %(schema_name)s_instance_factory : public IfcParse::instance_factory { virtual IfcUtil::IfcBaseClass* operator()(const IfcParse::declaration* decl, IfcEntityInstanceData&& data) const { %(instance_mapping)s } }; -""" - % locals() - ) +""" % locals() "" - self.statements[self.statements.index("{string_pool_placeholder}")] = ( - """ + self.statements[self.statements.index("{string_pool_placeholder}")] = """ const std::string strings[] = {%s}; -""" - % ",".join(map(lambda s: '"%s"s' % s, self.strings)) - ) +""" % ",".join(map(lambda s: '"%s"s' % s, self.strings)) def __str__(self): return "\n".join(self.statements) @@ -379,16 +396,19 @@ class SchemaClass(codegen.Base): def wrapper(*args, **kwargs): schema_name_upper = mapping.schema.name.upper() declared_type = fn(*args, **kwargs) - if 'simple_type' in declared_type: + if "simple_type" in declared_type: pass else: - match = re.search(r'\((\w+?_[\w+]+?_\w+?)\)', declared_type) + match = re.search(r"\((\w+?_[\w+]+?_\w+?)\)", declared_type) if match: old_decl = match.group(1) - name = old_decl.lower().replace(schema_name.lower() + '_', '').replace('_type', '') + name = old_decl.lower().replace(schema_name.lower() + "_", "").replace("_type", "") idx = [n.lower() for n in x.names].index(name) - declared_type = declared_type.replace(old_decl, '%(schema_name_upper)s_types[%(idx)d]' % locals()) + declared_type = declared_type.replace( + old_decl, "%(schema_name_upper)s_types[%(idx)d]" % locals() + ) return declared_type + return wrapper if code == EarlyBoundCodeWriter else fn @transform_to_indexed diff --git a/src/ifcopenshell-python/ifcopenshell/express/templates.py b/src/ifcopenshell-python/ifcopenshell/express/templates.py index e0398fd58d..564fe881a5 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/templates.py +++ b/src/ifcopenshell-python/ifcopenshell/express/templates.py @@ -217,7 +217,7 @@ const IfcParse::entity& %(schema_name)s::%(name)s::Class() { return *((IfcParse: %(schema_name)s::%(name)s::%(name)s(%(constructor_arguments)s) : %(superclass_num_attrs)s { %(constructor_implementation)s; populate_derived(); } """ -# data_ = e; +# data_ = e; # data_ = new IfcEntityInstanceData(%(schema_name_upper)s_types[%(index_in_schema)d]); optional_attribute_description = "/// Whether the optional attribute %s is defined for this %s" @@ -255,32 +255,16 @@ get_attr_stmt_nested_array = "%(null_check)s aggregate_of_aggregate_of_instance: get_inverse = "if (!file_) { return nullptr; } return file_->getInverse(id_, %(schema_name_upper)s_types[%(type_index)d], %(index)d)->as<%(type)s>();" -set_attr_stmt = ( - "%(check_optional_set_begin)sset_attribute_value(%(index)d, %(star_if_optional)sv);%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" -) -set_attr_instance = ( - "%(check_optional_set_begin)sset_attribute_value(%(index)d, v->as());%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" -) -set_attr_stmt_enum = "%(check_optional_set_begin)sset_attribute_value(%(index)d, EnumerationReference(&%(non_optional_type)s::Class(), (size_t) %(star_if_optional)sv));%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" -set_attr_stmt_array = ( - "%(check_optional_set_begin)sset_attribute_value(%(index)d, (%(star_if_optional)sv)->generalize());%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" -) +set_attr_stmt = "%(check_optional_set_begin)sset_attribute_value(%(index)d, %(star_if_optional)sv);%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" +set_attr_instance = "%(check_optional_set_begin)sset_attribute_value(%(index)d, v->as());%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" +set_attr_stmt_enum = "%(check_optional_set_begin)sset_attribute_value(%(index)d, EnumerationReference(&%(non_optional_type)s::Class(), (size_t) %(star_if_optional)sv));%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" +set_attr_stmt_array = "%(check_optional_set_begin)sset_attribute_value(%(index)d, (%(star_if_optional)sv)->generalize());%(check_optional_set_else)sunset_attribute_value(%(index)d);%(check_optional_set_end)s" -constructor_stmt = ( - "set_attribute_value(%(index)d, (%(name)s));" -) -constructor_stmt_enum = ( - "set_attribute_value(%(index)d, (EnumerationReference(&%(type)s::Class(),(size_t)%(name)s)));" -) -constructor_stmt_array = ( - "set_attribute_value(%(index)d, (%(name)s)->generalize());" -) -constructor_stmt_derived = ( - "" -) -constructor_stmt_instance = ( - "set_attribute_value(%(index)d, %(name)s ? %(name)s->as() : (IfcUtil::IfcBaseClass*) nullptr);" -) +constructor_stmt = "set_attribute_value(%(index)d, (%(name)s));" +constructor_stmt_enum = "set_attribute_value(%(index)d, (EnumerationReference(&%(type)s::Class(),(size_t)%(name)s)));" +constructor_stmt_array = "set_attribute_value(%(index)d, (%(name)s)->generalize());" +constructor_stmt_derived = "" +constructor_stmt_instance = "set_attribute_value(%(index)d, %(name)s ? %(name)s->as() : (IfcUtil::IfcBaseClass*) nullptr);" constructor_stmt_optional = " if (%(name)s) {%(stmt)s }" diff --git a/src/ifcopenshell-python/ifcopenshell/geom/app.py b/src/ifcopenshell-python/ifcopenshell/geom/app.py index fa07f3f2b8..d6bab207f1 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/app.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/app.py @@ -145,8 +145,7 @@ class configuration: config.set( "snippets", "print all wall ids", - self.config_encode( - """ + self.config_encode(""" ########################################################################### # A simple script that iterates over all walls in the current model # # and prints their Globally unique IDs (GUIDS) to the console window # @@ -154,15 +153,13 @@ class configuration: for wall in model.by_type("IfcWall"): print ("wall with global id: "+str(wall.GlobalId)) -""".lstrip() - ), +""".lstrip()), ) config.set( "snippets", "print properties of current selection", - self.config_encode( - """ + self.config_encode(""" ########################################################################### # A simple script that iterates over all IfcPropertySets of the currently # # selected object and prints them to the console # @@ -180,8 +177,7 @@ if selection: for prop in relDefinesByProperties.RelatingPropertyDefinition.HasProperties: print ("{:<20} :{}".format(prop.Name,prop.NominalValue.wrappedValue)) print ("\\n") -""".lstrip() - ), +""".lstrip()), ) with open(conf_file, "w") as configfile: config.write(configfile) diff --git a/src/ifcopenshell-python/ifcopenshell/util/cost.py b/src/ifcopenshell-python/ifcopenshell/util/cost.py index 19172c4710..875594f1a5 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/cost.py +++ b/src/ifcopenshell-python/ifcopenshell/util/cost.py @@ -352,8 +352,7 @@ def get_cost_rate( class CostValueUnserialiser: def parse(self, formula: str): - l = lark.Lark( - """start: formula + l = lark.Lark("""start: formula formula: operand (operator operand)* operand: value | category "(" formula ")" value: NUMBER? @@ -390,8 +389,7 @@ class CostValueUnserialiser: NEWLINE: (CR? LF)+ %ignore WS // Disregard spaces in text - """ - ) + """) start = l.parse(formula) return self.get_formula(start.children[0]) diff --git a/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py b/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py index 2ddf444704..5ba2466f29 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py +++ b/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py @@ -25,7 +25,6 @@ Things we do check: - class hierarchy """ - import ast import difflib from pathlib import Path diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index d3bef9758f..c6ee820ab8 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -39,8 +39,7 @@ import ifcopenshell.util.shape import ifcopenshell.util.system import ifcopenshell.util.unit -filter_elements_grammar = lark.Lark( - """start: filter_group +filter_elements_grammar = lark.Lark("""start: filter_group filter_group: facet_list ("+" facet_list)* facet_list: facet ("," facet)* @@ -111,11 +110,9 @@ filter_elements_grammar = lark.Lark( NEWLINE: (CR? LF)+ %ignore WS // Disregard spaces in text -""" -) +""") -get_element_grammar = lark.Lark( - """start: keys +get_element_grammar = lark.Lark("""start: keys keys: key ("." key)* key: quoted_string | regex_string | unquoted_string @@ -130,11 +127,9 @@ get_element_grammar = lark.Lark( WS: /[ \\t\\f\\r\\n]/+ %ignore WS // Disregard spaces in text - """ -) + """) -format_grammar = lark.Lark( - """start: expression +format_grammar = lark.Lark("""start: expression ?expression: add_sub ?add_sub: mul_div @@ -193,8 +188,7 @@ format_grammar = lark.Lark( NEWLINE: (CR? LF)+ %ignore WS // Disregard spaces in text -""" -) +""") class FormatTransformer(lark.Transformer): diff --git a/src/ifcopenshell-python/ifcopenshell/validate.py b/src/ifcopenshell-python/ifcopenshell/validate.py index 13f148d520..e1270afb57 100644 --- a/src/ifcopenshell-python/ifcopenshell/validate.py +++ b/src/ifcopenshell-python/ifcopenshell/validate.py @@ -793,6 +793,12 @@ if __name__ == "__main__": parser.add_argument("files", nargs="+", help="The IFC file to validate.") parser.add_argument("--rules", action="store_true", help="Run express rules.") parser.add_argument("--json", action="store_true", help="Output in JSON format.") + parser.add_argument( + "--recursion-limit", + type=int, + default=-1, + help="Override sys.getrecursionlimit to process express rules on deeply nested structures (e.g 10000)", + ) parser.add_argument( "--fields", action="store_true", @@ -804,6 +810,9 @@ if __name__ == "__main__": filenames: list[str] = args.files some_file_is_invalid = False + if args.recursion_limit > 0: + sys.setrecursionlimit(args.recursion_limit) + for fn in filenames: handler = None if args.json: diff --git a/src/ifcopenshell-python/test/typing_tests.py b/src/ifcopenshell-python/test/typing_tests.py index 5b2d789613..ccf007fa62 100644 --- a/src/ifcopenshell-python/test/typing_tests.py +++ b/src/ifcopenshell-python/test/typing_tests.py @@ -21,7 +21,6 @@ This file should produce no warnings from type checker (currently pyright). Those tests are not automatically checked and just there to make sure overloads are making sense. """ - from typing import Union from typing_extensions import assert_type diff --git a/src/ifcopenshell-python/test/util/test_pset.py b/src/ifcopenshell-python/test/util/test_pset.py index 3b44951ec4..bec1a10ba0 100644 --- a/src/ifcopenshell-python/test/util/test_pset.py +++ b/src/ifcopenshell-python/test/util/test_pset.py @@ -17,6 +17,7 @@ # along with IfcOpenShell. If not, see . """Run this test from src/ifcopenshell-python folder: pytest --durations=0 ifcopenshell/util/test_pset.py""" + from ifcopenshell.util import pset from ifcopenshell.util.pset import ApplicableEntity diff --git a/src/ifcopenshell-python/test/util/test_selector.py b/src/ifcopenshell-python/test/util/test_selector.py index 3c94876a66..b8302e0f4a 100644 --- a/src/ifcopenshell-python/test/util/test_selector.py +++ b/src/ifcopenshell-python/test/util/test_selector.py @@ -54,7 +54,7 @@ class TestFormat(test.bootstrap.IFC4): def test_number_formatting(self): assert subject.format("round(123, 5)") == "125" assert subject.format('round("123", 5)') == "125" - assert subject.format('round(-123, 5)') == "-125" + assert subject.format("round(-123, 5)") == "-125" assert subject.format("int(123.123)") == "123" assert subject.format("int(123)") == "123" assert subject.format("number(123)") == "123" @@ -79,14 +79,14 @@ class TestFormat(test.bootstrap.IFC4): assert subject.format('imperial_length(3.0, 4, "foot", "foot", False)') == "3' - 0\"" def test_variable_formatting(self): - assert subject.format('{{undefined}}') is None - assert subject.format('upper({{undefined}})') == "NONE" - assert subject.format('int({{undefined}})') == "0" + assert subject.format("{{undefined}}") is None + assert subject.format("upper({{undefined}})") == "NONE" + assert subject.format("int({{undefined}})") == "0" element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") - assert subject.format('{{undefined}}', element) is None - assert subject.format('{{class}}', element) == "IfcWall" - assert subject.format('{{ class }}', element) == "IfcWall" - assert subject.format('upper({{ class }})', element) == "IFCWALL" + assert subject.format("{{undefined}}", element) is None + assert subject.format("{{class}}", element) == "IfcWall" + assert subject.format("{{ class }}", element) == "IfcWall" + assert subject.format("upper({{ class }})", element) == "IFCWALL" def test_list_formatting(self): element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") @@ -98,17 +98,17 @@ class TestFormat(test.bootstrap.IFC4): layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material2) layer = ifcopenshell.api.material.add_layer(self.file, layer_set=material_set, material=material3) ifcopenshell.api.material.assign_material(self.file, products=[element], material=material_set) - assert subject.format('{{materials.Name}}', element) == "CON01, CON03, CON02" - assert subject.format('sort({{materials.Name}})', element) == "CON01, CON02, CON03" - assert subject.format('reverse({{materials.Name}})', element) == "CON02, CON03, CON01" + assert subject.format("{{materials.Name}}", element) == "CON01, CON03, CON02" + assert subject.format("sort({{materials.Name}})", element) == "CON01, CON02, CON03" + assert subject.format("reverse({{materials.Name}})", element) == "CON02, CON03, CON01" assert subject.format('join("-", {{materials.Name}})', element) == "CON01-CON03-CON02" def test_expressions(self): - assert subject.format('2+3') == "5" - assert subject.format('-2+3') == "1" - assert subject.format('2-3') == "-1" - assert subject.format('3*2') == "6" - assert subject.format('3/2') == "1.5" + assert subject.format("2+3") == "5" + assert subject.format("-2+3") == "1" + assert subject.format("2-3") == "-1" + assert subject.format("3*2") == "6" + assert subject.format("3/2") == "1.5" class TestGetElementValue(test.bootstrap.IFC4): diff --git a/src/ifcpatch/ifcpatch/recipes/ExtractPropertiesToSQLite.py b/src/ifcpatch/ifcpatch/recipes/ExtractPropertiesToSQLite.py index 634a8fb796..0f9dc8544d 100644 --- a/src/ifcpatch/ifcpatch/recipes/ExtractPropertiesToSQLite.py +++ b/src/ifcpatch/ifcpatch/recipes/ExtractPropertiesToSQLite.py @@ -55,8 +55,7 @@ class Patcher: self.c = self.db.cursor() self.file_patched = db_file - self.c.execute( - """ + self.c.execute(""" CREATE TABLE IF NOT EXISTS elements ( id integer PRIMARY KEY NOT NULL UNIQUE, global_id text, @@ -65,33 +64,28 @@ class Patcher: name text, description text ); - """ - ) + """) self.c.execute("CREATE INDEX IF NOT EXISTS idx_global_id ON elements (global_id);") self.c.execute("CREATE INDEX IF NOT EXISTS idx_ifc_class ON elements (ifc_class);") self.c.execute("CREATE INDEX IF NOT EXISTS idx_predefined_type ON elements (predefined_type);") - self.c.execute( - """ + self.c.execute(""" CREATE TABLE IF NOT EXISTS relationships ( from_id integer NOT NULL, type text, to_id integer NOT NULL ); - """ - ) + """) self.c.execute("CREATE INDEX IF NOT EXISTS idx_from_id ON relationships (from_id);") - self.c.execute( - """ + self.c.execute(""" CREATE TABLE IF NOT EXISTS properties ( element_id integer NOT NULL, set_name text, name text, value text ); - """ - ) + """) self.c.execute("CREATE INDEX IF NOT EXISTS idx_element_id ON properties (element_id);") elements = self.file.by_type("IfcObjectDefinition") diff --git a/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py b/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py index f7e294898a..256ffa99ce 100644 --- a/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py +++ b/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py @@ -349,13 +349,11 @@ class Patcher(ifcpatch.BasePatcher): assert cursor is not None row = cursor.fetchone() elif self.sql_type == "mysql": - cursor = self.c.execute( - f""" + cursor = self.c.execute(f""" SELECT 1 FROM information_schema.tables WHERE table_schema = '{self.database}' AND table_name = 'id_map' LIMIT 1; - """ - ) + """) row = self.c.fetchone() else: assert_never(self.sql_type) diff --git a/src/ifctester/webapp/package-lock.json b/src/ifctester/webapp/package-lock.json index e1527f59f3..2e136aaffa 100644 --- a/src/ifctester/webapp/package-lock.json +++ b/src/ifctester/webapp/package-lock.json @@ -24,7 +24,7 @@ "clsx": "^2.1.1", "mode-watcher": "^1.1.0", "sass-embedded": "^1.89.0", - "svelte": "^5.28.1", + "svelte": "^5.53.0", "svelte-sonner": "^1.0.5", "tailwind-merge": "^3.3.0", "tailwind-variants": "^1.0.0", @@ -37,6 +37,7 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", @@ -543,6 +544,16 @@ "node": ">=6.0.0" } }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", @@ -588,9 +599,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.41.1.tgz", - "integrity": "sha512-NELNvyEWZ6R9QMkiytB4/L4zSEaBC03KIXEghptLGLZWJ6VPrL63ooZQCOnlx36aQPGhzuOMwDerC1Eb2VmrLw==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.59.0.tgz", + "integrity": "sha512-upnNBkA6ZH2VKGcBj9Fyl9IGNPULcjXRlg0LLeaioQWueH30p6IXtJEbKAgvyv+mJaMxSm1l6xwDXYjpEMiLMg==", "cpu": [ "arm" ], @@ -602,9 +613,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.41.1.tgz", - "integrity": "sha512-DXdQe1BJ6TK47ukAoZLehRHhfKnKg9BjnQYUu9gzhI8Mwa1d2fzxA1aw2JixHVl403bwp1+/o/NhhHtxWJBgEA==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.59.0.tgz", + "integrity": "sha512-hZ+Zxj3SySm4A/DylsDKZAeVg0mvi++0PYVceVyX7hemkw7OreKdCvW2oQ3T1FMZvCaQXqOTHb8qmBShoqk69Q==", "cpu": [ "arm64" ], @@ -616,9 +627,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.41.1.tgz", - "integrity": "sha512-5afxvwszzdulsU2w8JKWwY8/sJOLPzf0e1bFuvcW5h9zsEg+RQAojdW0ux2zyYAz7R8HvvzKCjLNJhVq965U7w==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.59.0.tgz", + "integrity": "sha512-W2Psnbh1J8ZJw0xKAd8zdNgF9HRLkdWwwdWqubSVk0pUuQkoHnv7rx4GiF9rT4t5DIZGAsConRE3AxCdJ4m8rg==", "cpu": [ "arm64" ], @@ -630,9 +641,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.41.1.tgz", - "integrity": "sha512-egpJACny8QOdHNNMZKf8xY0Is6gIMz+tuqXlusxquWu3F833DcMwmGM7WlvCO9sB3OsPjdC4U0wHw5FabzCGZg==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.59.0.tgz", + "integrity": "sha512-ZW2KkwlS4lwTv7ZVsYDiARfFCnSGhzYPdiOU4IM2fDbL+QGlyAbjgSFuqNRbSthybLbIJ915UtZBtmuLrQAT/w==", "cpu": [ "x64" ], @@ -644,9 +655,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.41.1.tgz", - "integrity": "sha512-DBVMZH5vbjgRk3r0OzgjS38z+atlupJ7xfKIDJdZZL6sM6wjfDNo64aowcLPKIx7LMQi8vybB56uh1Ftck/Atg==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.59.0.tgz", + "integrity": "sha512-EsKaJ5ytAu9jI3lonzn3BgG8iRBjV4LxZexygcQbpiU0wU0ATxhNVEpXKfUa0pS05gTcSDMKpn3Sx+QB9RlTTA==", "cpu": [ "arm64" ], @@ -658,9 +669,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.41.1.tgz", - "integrity": "sha512-3FkydeohozEskBxNWEIbPfOE0aqQgB6ttTkJ159uWOFn42VLyfAiyD9UK5mhu+ItWzft60DycIN1Xdgiy8o/SA==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.59.0.tgz", + "integrity": "sha512-d3DuZi2KzTMjImrxoHIAODUZYoUUMsuUiY4SRRcJy6NJoZ6iIqWnJu9IScV9jXysyGMVuW+KNzZvBLOcpdl3Vg==", "cpu": [ "x64" ], @@ -672,9 +683,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.41.1.tgz", - "integrity": "sha512-wC53ZNDgt0pqx5xCAgNunkTzFE8GTgdZ9EwYGVcg+jEjJdZGtq9xPjDnFgfFozQI/Xm1mh+D9YlYtl+ueswNEg==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.59.0.tgz", + "integrity": "sha512-t4ONHboXi/3E0rT6OZl1pKbl2Vgxf9vJfWgmUoCEVQVxhW6Cw/c8I6hbbu7DAvgp82RKiH7TpLwxnJeKv2pbsw==", "cpu": [ "arm" ], @@ -686,9 +697,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.41.1.tgz", - "integrity": "sha512-jwKCca1gbZkZLhLRtsrka5N8sFAaxrGz/7wRJ8Wwvq3jug7toO21vWlViihG85ei7uJTpzbXZRcORotE+xyrLA==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.59.0.tgz", + "integrity": "sha512-CikFT7aYPA2ufMD086cVORBYGHffBo4K8MQ4uPS/ZnY54GKj36i196u8U+aDVT2LX4eSMbyHtyOh7D7Zvk2VvA==", "cpu": [ "arm" ], @@ -700,9 +711,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.41.1.tgz", - "integrity": "sha512-g0UBcNknsmmNQ8V2d/zD2P7WWfJKU0F1nu0k5pW4rvdb+BIqMm8ToluW/eeRmxCared5dD76lS04uL4UaNgpNA==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.59.0.tgz", + "integrity": "sha512-jYgUGk5aLd1nUb1CtQ8E+t5JhLc9x5WdBKew9ZgAXg7DBk0ZHErLHdXM24rfX+bKrFe+Xp5YuJo54I5HFjGDAA==", "cpu": [ "arm64" ], @@ -714,9 +725,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.41.1.tgz", - "integrity": "sha512-XZpeGB5TKEZWzIrj7sXr+BEaSgo/ma/kCgrZgL0oo5qdB1JlTzIYQKel/RmhT6vMAvOdM2teYlAaOGJpJ9lahg==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.59.0.tgz", + "integrity": "sha512-peZRVEdnFWZ5Bh2KeumKG9ty7aCXzzEsHShOZEFiCQlDEepP1dpUl/SrUNXNg13UmZl+gzVDPsiCwnV1uI0RUA==", "cpu": [ "arm64" ], @@ -727,10 +738,10 @@ "linux" ] }, - "node_modules/@rollup/rollup-linux-loongarch64-gnu": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.41.1.tgz", - "integrity": "sha512-bkCfDJ4qzWfFRCNt5RVV4DOw6KEgFTUZi2r2RuYhGWC8WhCA8lCAJhDeAmrM/fdiAH54m0mA0Vk2FGRPyzI+tw==", + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.59.0.tgz", + "integrity": "sha512-gbUSW/97f7+r4gHy3Jlup8zDG190AuodsWnNiXErp9mT90iCy9NKKU0Xwx5k8VlRAIV2uU9CsMnEFg/xXaOfXg==", "cpu": [ "loong64" ], @@ -741,10 +752,38 @@ "linux" ] }, - "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.41.1.tgz", - "integrity": "sha512-3mr3Xm+gvMX+/8EKogIZSIEF0WUu0HL9di+YWlJpO8CQBnoLAEL/roTCxuLncEdgcfJcvA4UMOf+2dnjl4Ut1A==", + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.59.0.tgz", + "integrity": "sha512-yTRONe79E+o0FWFijasoTjtzG9EBedFXJMl888NBEDCDV9I2wGbFFfJQQe63OijbFCUZqxpHz1GzpbtSFikJ4Q==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.59.0.tgz", + "integrity": "sha512-sw1o3tfyk12k3OEpRddF68a1unZ5VCN7zoTNtSn2KndUE+ea3m3ROOKRCZxEpmT9nsGnogpFP9x6mnLTCaoLkA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.59.0.tgz", + "integrity": "sha512-+2kLtQ4xT3AiIxkzFVFXfsmlZiG5FXYW7ZyIIvGA7Bdeuh9Z0aN4hVyXS/G1E9bTP/vqszNIN/pUKCk/BTHsKA==", "cpu": [ "ppc64" ], @@ -756,9 +795,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.41.1.tgz", - "integrity": "sha512-3rwCIh6MQ1LGrvKJitQjZFuQnT2wxfU+ivhNBzmxXTXPllewOF7JR1s2vMX/tWtUYFgphygxjqMl76q4aMotGw==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.59.0.tgz", + "integrity": "sha512-NDYMpsXYJJaj+I7UdwIuHHNxXZ/b/N2hR15NyH3m2qAtb/hHPA4g4SuuvrdxetTdndfj9b1WOmy73kcPRoERUg==", "cpu": [ "riscv64" ], @@ -770,9 +809,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.41.1.tgz", - "integrity": "sha512-LdIUOb3gvfmpkgFZuccNa2uYiqtgZAz3PTzjuM5bH3nvuy9ty6RGc/Q0+HDFrHrizJGVpjnTZ1yS5TNNjFlklw==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.59.0.tgz", + "integrity": "sha512-nLckB8WOqHIf1bhymk+oHxvM9D3tyPndZH8i8+35p/1YiVoVswPid2yLzgX7ZJP0KQvnkhM4H6QZ5m0LzbyIAg==", "cpu": [ "riscv64" ], @@ -784,9 +823,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.41.1.tgz", - "integrity": "sha512-oIE6M8WC9ma6xYqjvPhzZYk6NbobIURvP/lEbh7FWplcMO6gn7MM2yHKA1eC/GvYwzNKK/1LYgqzdkZ8YFxR8g==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.59.0.tgz", + "integrity": "sha512-oF87Ie3uAIvORFBpwnCvUzdeYUqi2wY6jRFWJAy1qus/udHFYIkplYRW+wo+GRUP4sKzYdmE1Y3+rY5Gc4ZO+w==", "cpu": [ "s390x" ], @@ -798,9 +837,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.41.1.tgz", - "integrity": "sha512-cWBOvayNvA+SyeQMp79BHPK8ws6sHSsYnK5zDcsC3Hsxr1dgTABKjMnMslPq1DvZIp6uO7kIWhiGwaTdR4Og9A==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.59.0.tgz", + "integrity": "sha512-3AHmtQq/ppNuUspKAlvA8HtLybkDflkMuLK4DPo77DfthRb71V84/c4MlWJXixZz4uruIH4uaa07IqoAkG64fg==", "cpu": [ "x64" ], @@ -812,9 +851,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.41.1.tgz", - "integrity": "sha512-y5CbN44M+pUCdGDlZFzGGBSKCA4A/J2ZH4edTYSSxFg7ce1Xt3GtydbVKWLlzL+INfFIZAEg1ZV6hh9+QQf9YQ==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.59.0.tgz", + "integrity": "sha512-2UdiwS/9cTAx7qIUZB/fWtToJwvt0Vbo0zmnYt7ED35KPg13Q0ym1g442THLC7VyI6JfYTP4PiSOWyoMdV2/xg==", "cpu": [ "x64" ], @@ -825,10 +864,38 @@ "linux" ] }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.59.0.tgz", + "integrity": "sha512-M3bLRAVk6GOwFlPTIxVBSYKUaqfLrn8l0psKinkCFxl4lQvOSz8ZrKDz2gxcBwHFpci0B6rttydI4IpS4IS/jQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.59.0.tgz", + "integrity": "sha512-tt9KBJqaqp5i5HUZzoafHZX8b5Q2Fe7UjYERADll83O4fGqJ49O1FsL6LpdzVFQcpwvnyd0i+K/VSwu/o/nWlA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.41.1.tgz", - "integrity": "sha512-lZkCxIrjlJlMt1dLO/FbpZbzt6J/A8p4DnqzSa4PWqPEUUUnzXLeki/iyPLfV0BmHItlYgHUqJe+3KiyydmiNQ==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.59.0.tgz", + "integrity": "sha512-V5B6mG7OrGTwnxaNUzZTDTjDS7F75PO1ae6MJYdiMu60sq0CqN5CVeVsbhPxalupvTX8gXVSU9gq+Rx1/hvu6A==", "cpu": [ "arm64" ], @@ -840,9 +907,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.41.1.tgz", - "integrity": "sha512-+psFT9+pIh2iuGsxFYYa/LhS5MFKmuivRsx9iPJWNSGbh2XVEjk90fmpUEjCnILPEPJnikAU6SFDiEUyOv90Pg==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.59.0.tgz", + "integrity": "sha512-UKFMHPuM9R0iBegwzKF4y0C4J9u8C6MEJgFuXTBerMk7EJ92GFVFYBfOZaSGLu6COf7FxpQNqhNS4c4icUPqxA==", "cpu": [ "ia32" ], @@ -853,10 +920,24 @@ "win32" ] }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.59.0.tgz", + "integrity": "sha512-laBkYlSS1n2L8fSo1thDNGrCTQMmxjYY5G0WFWjFFYZkKPjsMBsgJfGf4TLxXrF6RyhI60L8TMOjBMvXiTcxeA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.41.1.tgz", - "integrity": "sha512-Wq2zpapRYLfi4aKxf2Xff0tN+7slj2d4R87WEzqw7ZLsVvO5zwYCIuEGSZYiK41+GlwUo1HiR+GdkLEJnCKTCw==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.59.0.tgz", + "integrity": "sha512-2HRCml6OztYXyJXAvdDXPKcawukWY2GpR5/nxKp4iBgiO3wcoEGkAaqctIbZcNB6KlUQBIqt8VYkNSj2397EfA==", "cpu": [ "x64" ], @@ -1270,9 +1351,15 @@ } }, "node_modules/@types/estree": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz", - "integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "license": "MIT" + }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", "license": "MIT" }, "node_modules/acorn": { @@ -1445,6 +1532,12 @@ "node": ">=8" } }, + "node_modules/devalue": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.6.3.tgz", + "integrity": "sha512-nc7XjUU/2Lb+SvEFVGcWLiKkzfw8+qHI7zn8WYXKkLMgfGSHbgCEaR6bJpev8Cm6Rmrb19Gfd/tZvGqx9is3wg==", + "license": "MIT" + }, "node_modules/engine.io-client": { "version": "6.6.3", "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.6.3.tgz", @@ -1546,9 +1639,9 @@ "license": "MIT" }, "node_modules/esrap": { - "version": "1.4.6", - "resolved": "https://registry.npmjs.org/esrap/-/esrap-1.4.6.tgz", - "integrity": "sha512-F/D2mADJ9SHY3IwksD4DAXjTt7qt7GWUf3/8RhCNWmC/67tyb55dpimHmy7EplakFaflV0R/PC+fdSPqrRHAQw==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.2.3.tgz", + "integrity": "sha512-8fOS+GIGCQZl/ZIlhl59htOlms6U8NvX6ZYgYHpRU/b6tVSh3uHkOHZikl3D4cMbYM0JlpBe+p/BkZEi8J9XIQ==", "license": "MIT", "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" @@ -2118,13 +2211,13 @@ } }, "node_modules/rollup": { - "version": "4.41.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.41.1.tgz", - "integrity": "sha512-cPmwD3FnFv8rKMBc1MxWCwVQFxwf1JEmSX3iQXrRVVG15zerAIXRjMFVWnd5Q5QvgKF7Aj+5ykXFhUl+QGnyOw==", + "version": "4.59.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.59.0.tgz", + "integrity": "sha512-2oMpl67a3zCH9H79LeMcbDhXW/UmWG/y2zuqnF2jQq5uq9TbM9TVyXvA4+t+ne2IIkBdrLpAaRQAvo7YI/Yyeg==", "dev": true, "license": "MIT", "dependencies": { - "@types/estree": "1.0.7" + "@types/estree": "1.0.8" }, "bin": { "rollup": "dist/bin/rollup" @@ -2134,26 +2227,31 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.41.1", - "@rollup/rollup-android-arm64": "4.41.1", - "@rollup/rollup-darwin-arm64": "4.41.1", - "@rollup/rollup-darwin-x64": "4.41.1", - "@rollup/rollup-freebsd-arm64": "4.41.1", - "@rollup/rollup-freebsd-x64": "4.41.1", - "@rollup/rollup-linux-arm-gnueabihf": "4.41.1", - "@rollup/rollup-linux-arm-musleabihf": "4.41.1", - "@rollup/rollup-linux-arm64-gnu": "4.41.1", - "@rollup/rollup-linux-arm64-musl": "4.41.1", - "@rollup/rollup-linux-loongarch64-gnu": "4.41.1", - "@rollup/rollup-linux-powerpc64le-gnu": "4.41.1", - "@rollup/rollup-linux-riscv64-gnu": "4.41.1", - "@rollup/rollup-linux-riscv64-musl": "4.41.1", - "@rollup/rollup-linux-s390x-gnu": "4.41.1", - "@rollup/rollup-linux-x64-gnu": "4.41.1", - "@rollup/rollup-linux-x64-musl": "4.41.1", - "@rollup/rollup-win32-arm64-msvc": "4.41.1", - "@rollup/rollup-win32-ia32-msvc": "4.41.1", - "@rollup/rollup-win32-x64-msvc": "4.41.1", + "@rollup/rollup-android-arm-eabi": "4.59.0", + "@rollup/rollup-android-arm64": "4.59.0", + "@rollup/rollup-darwin-arm64": "4.59.0", + "@rollup/rollup-darwin-x64": "4.59.0", + "@rollup/rollup-freebsd-arm64": "4.59.0", + "@rollup/rollup-freebsd-x64": "4.59.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.59.0", + "@rollup/rollup-linux-arm-musleabihf": "4.59.0", + "@rollup/rollup-linux-arm64-gnu": "4.59.0", + "@rollup/rollup-linux-arm64-musl": "4.59.0", + "@rollup/rollup-linux-loong64-gnu": "4.59.0", + "@rollup/rollup-linux-loong64-musl": "4.59.0", + "@rollup/rollup-linux-ppc64-gnu": "4.59.0", + "@rollup/rollup-linux-ppc64-musl": "4.59.0", + "@rollup/rollup-linux-riscv64-gnu": "4.59.0", + "@rollup/rollup-linux-riscv64-musl": "4.59.0", + "@rollup/rollup-linux-s390x-gnu": "4.59.0", + "@rollup/rollup-linux-x64-gnu": "4.59.0", + "@rollup/rollup-linux-x64-musl": "4.59.0", + "@rollup/rollup-openbsd-x64": "4.59.0", + "@rollup/rollup-openharmony-arm64": "4.59.0", + "@rollup/rollup-win32-arm64-msvc": "4.59.0", + "@rollup/rollup-win32-ia32-msvc": "4.59.0", + "@rollup/rollup-win32-x64-gnu": "4.59.0", + "@rollup/rollup-win32-x64-msvc": "4.59.0", "fsevents": "~2.3.2" } }, @@ -2677,21 +2775,23 @@ } }, "node_modules/svelte": { - "version": "5.33.10", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.33.10.tgz", - "integrity": "sha512-/yArPQIBoQS2p86LKnvJywOXkVHeEXnFgrDPSxkEfIAEkykopYuy2bF6UUqHG4IbZlJD6OurLxJT8Kn7kTk9WA==", + "version": "5.53.0", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.53.0.tgz", + "integrity": "sha512-7dhHkSamGS2vtoBmIW2hRab+gl5Z60alEHZB4910ePqqJNxAWnDAxsofVmlZ2tREmWyHNE+A1nCKwICAquoD2A==", "license": "MIT", "dependencies": { - "@ampproject/remapping": "^2.3.0", + "@jridgewell/remapping": "^2.3.4", "@jridgewell/sourcemap-codec": "^1.5.0", "@sveltejs/acorn-typescript": "^1.0.5", "@types/estree": "^1.0.5", + "@types/trusted-types": "^2.0.7", "acorn": "^8.12.1", "aria-query": "^5.3.1", "axobject-query": "^4.1.0", "clsx": "^2.1.1", + "devalue": "^5.6.3", "esm-env": "^1.2.1", - "esrap": "^1.4.6", + "esrap": "^2.2.2", "is-reference": "^3.0.3", "locate-character": "^3.0.0", "magic-string": "^0.30.11", diff --git a/src/ifctester/webapp/package.json b/src/ifctester/webapp/package.json index 4a8abd7897..b97ba2c8b5 100644 --- a/src/ifctester/webapp/package.json +++ b/src/ifctester/webapp/package.json @@ -18,7 +18,7 @@ "clsx": "^2.1.1", "mode-watcher": "^1.1.0", "sass-embedded": "^1.89.0", - "svelte": "^5.28.1", + "svelte": "^5.53.0", "svelte-sonner": "^1.0.5", "tailwind-merge": "^3.3.0", "tailwind-variants": "^1.0.0", diff --git a/src/opencdeserver/api/app/repository/bcf.py b/src/opencdeserver/api/app/repository/bcf.py index a65c43d115..3812334e41 100644 --- a/src/opencdeserver/api/app/repository/bcf.py +++ b/src/opencdeserver/api/app/repository/bcf.py @@ -694,8 +694,7 @@ class BCFDB(MyDB): snapshot_type = "" snapshot = False set_snapshot = "" - cypher_viewpoint = ( - """ + cypher_viewpoint = """ MATCH (u:User)-[r1:HAS_ACTIONS_ON]->(p:Project)-[r2:HAS]->(t:Topic) WHERE u.username = $username AND r1.createViewpoint = True @@ -713,9 +712,7 @@ class BCFDB(MyDB): v.spaces_visible = $spaces_visible, v.space_boundaries_visible = $space_boundaries_visible, v.openings_visible = $openings_visible - """ - % set_snapshot - ) + """ % set_snapshot if viewpoint.guid is None: viewpoint.guid = uuid4() if viewpoint.orthogonal_camera is None: @@ -1450,8 +1447,7 @@ class BCFDB(MyDB): else: document_url = "" document_reference.url = "" - cypher = ( - """ + cypher = """ MATCH (u:User)-[r1:HAS_ACTIONS_ON]->(p:Project)-[r2:HAS]->(t:Topic) WHERE u.username = $username AND r1.updateDocumentReferences = True @@ -1461,9 +1457,7 @@ class BCFDB(MyDB): SET r3.guid: $document_reference_id, %s d.description = $description - """ - % document_url - ) + """ % document_url result = tx.run( cypher, username=current_user.username, diff --git a/src/opencdeserver/api/app/repository/documents.py b/src/opencdeserver/api/app/repository/documents.py index 95c669a7bc..d03512c8e3 100644 --- a/src/opencdeserver/api/app/repository/documents.py +++ b/src/opencdeserver/api/app/repository/documents.py @@ -36,17 +36,14 @@ class DOCDB(MyDB): else: version_index_criteria = "AND d.version_index = $version_index" - cypher = ( - """ + cypher = """ MATCH (d:Document) WHERE d.document_id = $document_id %s RETURN d AS document ORDER by d.version_index DESC LIMIT 1 - """ - % version_index_criteria - ) + """ % version_index_criteria result = tx.run(cypher, document_id=document_id, version_index=version_index) @@ -891,8 +888,7 @@ class DOCDB(MyDB): else: version_index_criteria = "" - cypher = ( - """ + cypher = """ MATCH (u:User)-[r3:HAS_ACTIONS_ON]->(p:Project)-[r4:CONTAINS]->(d:Document) WHERE u.username = $username AND d.document_id = $document_id @@ -900,9 +896,7 @@ class DOCDB(MyDB): RETURN d AS document ORDER by d.version_index DESC LIMIT 1 - """ - % version_index_criteria - ) + """ % version_index_criteria result = tx.run( cypher, username=current_user.username, document_id=document_id, version_index=version_index @@ -927,8 +921,7 @@ class DOCDB(MyDB): else: version_index_criteria = "" - cypher = ( - """ + cypher = """ MATCH (u:User)-[r3:HAS_ACTIONS_ON]->(p:Project)-[r4:CONTAINS]->(d:Document) WHERE u.username = $username AND d.document_id = $document_id @@ -936,9 +929,7 @@ class DOCDB(MyDB): RETURN d AS document ORDER by d.version_index DESC LIMIT 1 - """ - % version_index_criteria - ) + """ % version_index_criteria result = tx.run( cypher, username=current_user.username, document_id=document_id, version_index=version_index diff --git a/src/serializers/schema_dependent/CMakeLists.txt b/src/serializers/schema_dependent/CMakeLists.txt index ef877342e9..73c1e5d3e7 100644 --- a/src/serializers/schema_dependent/CMakeLists.txt +++ b/src/serializers/schema_dependent/CMakeLists.txt @@ -9,9 +9,9 @@ foreach(schema ${SCHEMA_VERSIONS}) Serializers_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}" ) - target_link_libraries(Serializers_ifc${schema} ${HDF5_LIBRARIES} ${GLTF_LIBRARIES}) + target_link_libraries(Serializers_ifc${schema} IfcGeom ${HDF5_LIBRARIES} ${GLTF_LIBRARIES}) if(NOT WASM_BUILD) - target_link_libraries(Serializers_ifc${schema} IfcGeom ${OpenCASCADE_LIBRARIES}) + target_link_libraries(Serializers_ifc${schema} ${OpenCASCADE_LIBRARIES}) endif() endforeach() diff --git a/src/svgfill/CMakeLists.txt b/src/svgfill/CMakeLists.txt index f2f8c1a062..0d9764013a 100644 --- a/src/svgfill/CMakeLists.txt +++ b/src/svgfill/CMakeLists.txt @@ -36,7 +36,14 @@ message(STATUS "Boost include files found in ${Boost_INCLUDE_DIRS}") find_package(LibXml2 REQUIRED) find_package(CGAL REQUIRED) -include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/svgpp/include) +set(SVGPP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/svgpp/include") +if(NOT EXISTS ${SVGPP_INCLUDE}) + message( + FATAL_ERROR + "Missing svgpp include path, probably you forgot to initialize submodules in git repo. Missing path - '${SVGPP_INCLUDE}'." + ) +endif() +include_directories(${Boost_INCLUDE_DIRS} ${SVGPP_INCLUDE}) file(GLOB LIB_H_FILES src/*.h) file(GLOB LIB_CPP_FILES src/svgfill.cpp src/arrange_polygons.cpp) diff --git a/win/build-all-win.py b/win/build-all-win.py index 087f869ac4..e1bd5cccdf 100644 --- a/win/build-all-win.py +++ b/win/build-all-win.py @@ -6,6 +6,7 @@ but also archives them to '~/outputs'. import os import subprocess +import zipfile from pathlib import Path from zipfile import ZipFile @@ -27,7 +28,23 @@ ZIP_TEMPLATE = f"{{package_name}}-v{VERSION}-{SHA}-win64.zip" def run(command: list[str]) -> None: print("Running:", command) - subprocess.check_call(command) # nosec B603 + subprocess.check_call(command) + + +def set_env(var_name: str, value: str) -> tuple[str, str | None]: + """ + :return: Tuple of ``(var_name, old_value)`` to be passed to ``restore_env``. + """ + old_value = os.getenv(var_name) + os.environ[var_name] = value + return var_name, old_value + + +def restore_env(var_name: str, old_value: str | None) -> None: + if old_value is None: + del os.environ[var_name] + else: + os.environ[var_name] = old_value def build() -> None: @@ -40,16 +57,16 @@ def build() -> None: text=True, input="y\n", ) + OLD_ADD_COMMIT_SHA = set_env("ADD_COMMIT_SHA", "ON") run( [ str(REPO_WIN / "run-cmake.bat"), "vs2022-x64", "-DENABLE_BUILD_OPTIMIZATIONS=ON", "-DGLTF_SUPPORT=ON", - "-DADD_COMMIT_SHA=ON", - "-DVERSION_OVERRIDE=ON", ] ) + restore_env(*OLD_ADD_COMMIT_SHA) run([str(REPO_WIN / "install-ifcopenshell.bat"), "vs2022-x64", "Release"]) @@ -61,7 +78,7 @@ def archive_executables() -> None: if file.suffix.lower() != ".exe": continue zip_name = ZIP_TEMPLATE.format(package_name=file.stem) - with ZipFile(OUTPUT_DIR / zip_name, "w") as zipf: + with ZipFile(OUTPUT_DIR / zip_name, "w", compression=zipfile.ZIP_DEFLATED) as zipf: zipf.write(file, arcname=file.name) print(f"{file} -> {zip_name}") @@ -76,7 +93,7 @@ def archive_python_package(python_version: str, python_path: Path) -> None: file.unlink() zip_name = ZIP_TEMPLATE.format(package_name=f"ifcopenshell-python-{python_version_major_minor}") - with ZipFile(OUTPUT_DIR / zip_name, "w") as zipf: + with ZipFile(OUTPUT_DIR / zip_name, "w", compression=zipfile.ZIP_DEFLATED) as zipf: for file in package_path.rglob("*"): arcname = file.relative_to(site_packages) zipf.write(file, arcname=arcname) diff --git a/win/build-deps.cmd b/win/build-deps.cmd index c81541104f..811f381f19 100644 --- a/win/build-deps.cmd +++ b/win/build-deps.cmd @@ -249,8 +249,9 @@ IF NOT %ERRORLEVEL%==0 GOTO :Error :proj -IF EXIST "%INSTALL_DIR%\proj-9.2.1" ( - echo Found existing "%INSTALL_DIR%\proj-9.2.1", skipping +set PROJ_VERSION=9.4.1 +IF EXIST "%INSTALL_DIR%\proj-%PROJ_VERSION%" ( + echo Found existing "%INSTALL_DIR%\proj-%PROJ_VERSION%", skipping goto :mpir ) @@ -269,13 +270,13 @@ copy sqlite3.h %INSTALL_DIR%\sqlite3\include popd set DEPENDENCY_NAME=proj -set DEPENDENCY_DIR=%DEPS_DIR%\proj-9.2.1 -call :DownloadFile https://download.osgeo.org/proj/proj-9.2.1.zip "%DEPS_DIR%" proj-9.2.1.zip +set DEPENDENCY_DIR=%DEPS_DIR%\proj-%PROJ_VERSION% +call :DownloadFile https://download.osgeo.org/proj/proj-%PROJ_VERSION%.zip "%DEPS_DIR%" proj-%PROJ_VERSION%.zip IF NOT %ERRORLEVEL%==0 GOTO :Error -call :ExtractArchive proj-9.2.1.zip "%DEPS_DIR%" "%DEPS_DIR%\proj-9.2.1" +call :ExtractArchive proj-%PROJ_VERSION%.zip "%DEPS_DIR%" "%DEPS_DIR%\proj-%PROJ_VERSION%" IF NOT %ERRORLEVEL%==0 GOTO :Error pushd "%DEPENDENCY_DIR%" -call :RunCMake -DCMAKE_INSTALL_PREFIX="%INSTALL_DIR%\proj-9.2.1" ^ +call :RunCMake -DCMAKE_INSTALL_PREFIX="%INSTALL_DIR%\proj-%PROJ_VERSION%" ^ -DSQLITE3_INCLUDE_DIR=%INSTALL_DIR%\sqlite3\include ^ -DSQLITE3_LIBRARY=%INSTALL_DIR%\sqlite3\lib\sqlite3.lib ^ -DENABLE_TIFF=Off -DENABLE_CURL=Off -DBUILD_PROJSYNC=Off ^ @@ -297,8 +298,9 @@ IF EXIST "%INSTALL_DIR%\mpir" ( ) set DEPENDENCY_NAME=mpir +:: `mpfr` depends on relative path `..\mpir\config.h`, so dependency name should match exactly. set DEPENDENCY_DIR=%DEPS_DIR%\mpir -call :GitCloneAndCheckoutRevision https://github.com/BrianGladman/mpir.git "%DEPENDENCY_DIR%" +call :GitCloneAndCheckoutRevision https://github.com/Andrej730/mpir-vs2026.git "%DEPENDENCY_DIR%" IF NOT %ERRORLEVEL%==0 GOTO :Error pushd "%DEPENDENCY_DIR%" git reset --hard @@ -412,6 +414,11 @@ if exist "%DEPS_DIR%\boost-%BOOST_VERSION%". ( ren %DEPS_DIR%\boost-%BOOST_VERSION% boost_%BOOST_VER% ) +:: As boost 1.90.0 it still includes b2 that doesn't support vc145 (not to mention older boost versions). +:: So to support vc145 we download b2 separately (only if we do use vc145). +call :check_boost_vc145_compatibility "%VC_VER%" "%DEPS_DIR%" "%DEPENDENCY_DIR%" +if NOT %ERRORLEVEL%==0 GOTO :Error + :: Build Boost build script if not exist "%DEPENDENCY_DIR%\project-config.jam". ( cd "%DEPS_DIR%" @@ -462,8 +469,10 @@ IF NOT %ERRORLEVEL%==0 git apply --reject --whitespace=fix "%~dp0patches\OpenCOL :: uncomment to following line in order to delete the CMakeCache.txt always if experiencing problems. REM IF EXIST "%DEPENDENCY_DIR%\%BUILD_DIR%\CMakeCache.txt". del "%DEPENDENCY_DIR%\%BUILD_DIR%\CMakeCache.txt" :: NOTE Enforce that the embedded LibXml2 and PCRE are used as there might be problems with arbitrary versions of the libraries. +:: OpenCOLLADA is ancient at this point and allows cmake 2.6+, which results in error in cmake 4, so we override minimum cmake version. call :RunCMake -DCMAKE_INSTALL_PREFIX="%INSTALL_DIR%\%DEPENDENCY_INSTALL_NAME%" -DUSE_STATIC_MSVC_RUNTIME=0 -DCMAKE_DEBUG_POSTFIX=d ^ - -DLIBXML2_LIBRARIES="" -DLIBXML2_INCLUDE_DIR="" -DPCRE_INCLUDE_DIR="" -DPCRE_LIBRARIES="" + -DLIBXML2_LIBRARIES="" -DLIBXML2_INCLUDE_DIR="" -DPCRE_INCLUDE_DIR="" -DPCRE_LIBRARIES="" ^ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 IF NOT %ERRORLEVEL%==0 GOTO :Error REM IF NOT EXIST "%DEPS_DIR%\OpenCOLLADA\%BUILD_DIR%\lib\%DEBUG_OR_RELEASE%\OpenCOLLADASaxFrameworkLoader.lib". call :BuildCMakeProject "%DEPENDENCY_DIR%\%BUILD_DIR%" %DEBUG_OR_RELEASE% @@ -509,9 +518,18 @@ cd "%DEPENDENCY_DIR%" :: TODO: remove CMAKE_DEBUG_POSTFIX setting later. :: Temporarily explicitly set `CMAKE_DEBUG_POSTFIX` to empty to override it's perviously being set to `d`. :: OCCT don't need it, since it's layout is separating debug and release build by different folders. +:: +:: OCCT 7.8.1 we're using is becoming old and it was targeting cmake 3.1+. +::To make it buildable on cmake 4, we override policy version, but it may have some quirks in the future and we may consider version bump. call :RunCMake -DINSTALL_DIR="%DEPENDENCY_INSTALL_DIR%" -DBUILD_LIBRARY_TYPE="Static" -DCMAKE_DEBUG_POSTFIX="" ^ - -DBUILD_MODULE_Draw=0 -DUSE_FREETYPE=OFF ^ - -DBUILD_USE_PCH=ON + -DBUILD_MODULE_Draw=0 ^ + -DBUILD_RELEASE_DISABLE_EXCEPTIONS=OFF ^ + -DUSE_XLIB=OFF ^ + -DUSE_FREETYPE=OFF ^ + -DUSE_OPENGL=OFF ^ + -DUSE_GLES2=OFF ^ + -DBUILD_USE_PCH=ON ^ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 if not %ERRORLEVEL%==0 goto :Error :: whole program optimization avoids Visual C++ hanging when compiling 32-bit release OCCT up to version 7.4.0 @@ -572,7 +590,7 @@ IF NOT %ERRORLEVEL%==0 GOTO :Error :SWIG set DEPENDENCY_NAME=SWIG -set SWIG_VERSION=4.1.0 +set SWIG_VERSION=4.2.1 set DEPENDENCY_DIR=%DEPS_DIR%\swig-%SWIG_VERSION% set DEPENDENCY_INSTALL_DIR=%INSTALL_DIR%\swig-%SWIG_VERSION% echo SWIG_INSTALL_DIR=%DEPENDENCY_INSTALL_DIR%>>"%~dp0\%BUILD_DEPS_CACHE_PATH%" @@ -917,6 +935,15 @@ exit /b 0 IF NOT %ERRORLEVEL%==0 GOTO :Error exit /b 0 +:: Params: +:: - %1 - VC_VER +:: - %2 - DEPS_DIR +:: - %3 - BOOST_ROOT +:check_boost_vc145_compatibility +%PWSH_TOOLS% check_boost_vc145_compatibility "%1" "%2" "%3" +IF NOT %ERRORLEVEL%==0 GOTO :Error +exit /b 0 + :: PrintUsage - Prints usage information :PrintUsage call "%~dp0\utils\cecho.cmd" 0 10 "Requirements for a successful execution:" diff --git a/win/patches/V7_8_1.patch b/win/patches/V7_8_1.patch index 842a52bad6..9f185521c2 100644 --- a/win/patches/V7_8_1.patch +++ b/win/patches/V7_8_1.patch @@ -84,3 +84,16 @@ index c9399159f1..0aa55392f9 100644 endif() if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "") +diff --git a/adm/cmake/cotire.cmake b/adm/cmake/cotire.cmake +index acdca71a9f..6c6e29b374 100644 +--- a/adm/cmake/cotire.cmake ++++ b/adm/cmake/cotire.cmake +@@ -37,7 +37,7 @@ set(__COTIRE_INCLUDED TRUE) + if (NOT CMAKE_SCRIPT_MODE_FILE) + cmake_policy(PUSH) + endif() +-cmake_minimum_required(VERSION 2.8.12) ++cmake_minimum_required(VERSION 3.5) + if (NOT CMAKE_SCRIPT_MODE_FILE) + cmake_policy(POP) + endif() diff --git a/win/run-cmake.bat b/win/run-cmake.bat index 397887eb6c..2a49a65042 100755 --- a/win/run-cmake.bat +++ b/win/run-cmake.bat @@ -20,6 +20,10 @@ :: Example usage: :: run-cmake.bat vs2022-x64 :: run-cmake.bat vs2022-x64 -DGLTF_SUPPORT=ON -DHDF5_SUPPORT=OFF +:: +:: Used environment variables: +:: - `ADD_COMMIT_SHA` - if defined then `ADD_COMMIT_SHA` and `VERSION_OVERRIDE` cmake args will be set to `ON`. +:: - `USE_NINJA` - if defined then the Ninja generator will be used instead of the Visual Studio. @if not defined ECHO_ON ( echo off ) @@ -105,7 +109,13 @@ set PYTHON_LIBRARY=%PYTHONHOME%\libs\python%PY_VER_MAJOR_MINOR%.lib :: we can remove it later. if not defined SWIG_INSTALL_DIR set SWIG_INSTALL_DIR=%INSTALL_DIR%\swigwin set JSON_INCLUDE_DIR=%INSTALL_DIR%\json -if not defined ADD_COMMIT_SHA set ADD_COMMIT_SHA=Off +if defined ADD_COMMIT_SHA ( + set ADD_COMMIT_SHA=ON + set VERSION_OVERRIDE=ON +) else ( + set ADD_COMMIT_SHA=OFF + set VERSION_OVERRIDE=OFF +) set CGAL_INSTALL_DIR=%INSTALL_DIR%\cgal set GMP_INSTALL_DIR=%INSTALL_DIR%\mpir @@ -180,19 +190,16 @@ if defined USE_NINJA ( ) IF NOT "%VS_TOOLSET_HOST%"=="" ( - cmake.exe %CMAKELISTS_DIR% -G %GENERATOR% %ARCH_OPTION% -T %VS_TOOLSET_HOST% ^ - -DCMAKE_INSTALL_PREFIX="%CMAKE_INSTALL_PREFIX%" ^ - -DWITH_ROCKSDB=On -DWITH_ZSTD=On ^ - -DCMAKE_PREFIX_PATH="%CMAKE_PREFIX_PATH%" ^ - -DADD_COMMIT_SHA=%ADD_COMMIT_SHA% %ARGUMENTS% -) ELSE ( - cmake.exe %CMAKELISTS_DIR% -G %GENERATOR% %ARCH_OPTION% ^ - -DCMAKE_INSTALL_PREFIX="%CMAKE_INSTALL_PREFIX%" ^ - -DWITH_ROCKSDB=On -DWITH_ZSTD=On ^ - -DCMAKE_PREFIX_PATH="%CMAKE_PREFIX_PATH%" ^ - -DADD_COMMIT_SHA=%ADD_COMMIT_SHA% %ARGUMENTS% + set VS_TOOLSET_OPTION=-T %VS_TOOLSET_HOST% ) +cmake.exe %CMAKELISTS_DIR% -G %GENERATOR% %ARCH_OPTION% %VS_TOOLSET_OPTION% ^ + -DCMAKE_INSTALL_PREFIX="%CMAKE_INSTALL_PREFIX%" ^ + -DWITH_ROCKSDB=On -DWITH_ZSTD=On ^ + -DCMAKE_PREFIX_PATH="%CMAKE_PREFIX_PATH%" ^ + -DADD_COMMIT_SHA=%ADD_COMMIT_SHA% -DVERSION_OVERRIDE=%VERSION_OVERRIDE% ^ + %ARGUMENTS% + IF NOT %ERRORLEVEL%==0 GOTO :Error echo. diff --git a/win/utils/tools.ps1 b/win/utils/tools.ps1 index c143581789..583e4cfb3b 100644 --- a/win/utils/tools.ps1 +++ b/win/utils/tools.ps1 @@ -2,6 +2,8 @@ Set-PSDebug -Trace 0 Set-StrictMode -Version 3 $ErrorActionPreference = "Stop" +$cecho = "$PSScriptRoot\cecho.cmd" + # Create marker file to indicate whether Release or Debug build was installed. function mark { @@ -18,7 +20,7 @@ function mark { if (Test-Path -Path $marker_filepath) { return } - cecho.cmd 0 13 "Marking installation in '$installation_dir' with '$ENV:MARKER_FILE'." + . $cecho 0 13 "Marking installation in '$installation_dir' with '$ENV:MARKER_FILE'." New-Item -Path $marker_filepath -ItemType File | Out-Null } @@ -76,7 +78,7 @@ function mark_based_on_artifacts { if (Test-Path -Path $marker_filepath) { return } - cecho.cmd 0 13 "Found artifact '$artifact' for dependency '$dependency_name' $env:BUILD_CFG." + . $cecho 0 13 "Found artifact '$artifact' for dependency '$dependency_name' $env:BUILD_CFG." & mark $installation_dir } @@ -138,12 +140,11 @@ function extract_file { [string]$dir_after_extraction ) if (Test-Path -Path "$dir_after_extraction") { - cecho.cmd 0 13 "$dependency_name already extracted into '$dir_after_extraction'. Skipping." - exit 0 + . $cecho 0 13 "$dependency_name already extracted into '$dir_after_extraction'. Skipping." + return } - cecho.cmd 0 13 "Extracting $dependency_name into '$destination_dir' from '$filename'." + . $cecho 0 13 "Extracting $dependency_name into '$destination_dir' from '$filename'." 7za x "$filename" -o"$destination_dir" - exit 0 } @@ -161,13 +162,12 @@ function download_file { mkdir "$destination_dir" -Force | Out-Null pushd "$destination_dir" if (Test-Path -Path "$filename") { - cecho.cmd 0 13 "$dependency_name already downloaded. Skipping." - exit 0 + . $cecho 0 13 "$dependency_name already downloaded. Skipping." + return } - cecho.cmd 0 13 "Downloading $dependency_name into '$destination_dir'" + . $cecho 0 13 "Downloading $dependency_name into '$destination_dir'" Invoke-WebRequest $url -OutFile $filename - exit 0 } @@ -185,21 +185,20 @@ function git_clone_and_checkout_revision { [string]$revision ) if (Test-Path -Path "$dest_dir") { - cecho.cmd 0 13 "Cloning $dependency_name is already cloned." - exit 0 + . $cecho 0 13 "Cloning $dependency_name is already cloned." + return } - cecho.cmd 0 13 "Cloning $dependency_name into '$dest_dir'." + . $cecho 0 13 "Cloning $dependency_name into '$dest_dir'." pushd "$env:DEPS_DIR" git clone $git_url $dest_dir popd pushd "$dest_dir" git fetch - cecho.cmd 0 13 "Checking out $dependency_name revision $revision." + . $cecho 0 13 "Checking out $dependency_name revision $revision." git reset --hard git checkout $revision popd - exit 0 } function install_cmake_project { @@ -212,20 +211,61 @@ function install_cmake_project { [string]$configuration ) pushd "$build_dir" - cecho.cmd 0 13 "Installing $dependency_name ($configuration). Please be patient, this may take a while." + . $cecho 0 13 "Installing $dependency_name ($configuration). Please be patient, this may take a while." $command = "cmake --install . --config $configuration" - cecho.cmd 0 13 "$command" + . $cecho 0 13 "$command" Invoke-Expression $command popd - exit 0 } +function check_boost_vc145_compatibility { + param( + [Parameter(Mandatory = $true)] + [string]$VC_VER, + [Parameter(Mandatory = $true)] + [string]$DEPS_DIR, + [Parameter(Mandatory = $true)] + [string]$BOOST_ROOT + ) + + $boost_build_path = "$BOOST_ROOT/tools/build" + + if ($VC_VER -ne "14.5") { + . $cecho 0 13 "VC_VER is not 14.5, no need to install updated b2." + return + } + + $res = Select-String -Path "$boost_build_path/src/engine/build.bat" -Pattern 'vc143, vc145' -Quiet; + if ($res) { + . $cecho 0 13 "vc145 already supported, no need to install updated b2." + return + } + + $b2_version = "5.4.2" + $b2_stem = "b2-$b2_version" + $b2_path = "$DEPS_DIR\$b2_stem" + $b2_filename = "$b2_stem.zip" + + & download_file "b2" "https://github.com/bfgroup/b2/releases/download/$b2_version/$b2_filename" "$DEPS_DIR" "$b2_filename" + & extract_file "b2" "$b2_filename" "$DEPS_DIR" "$b2_path" + + . $cecho 0 13 "Installing b2 with vc145 support..." + Remove-Item -Recurse -Path "$boost_build_path" + Copy-Item -Path "$b2_path" -Destination "$boost_build_path" -Recurse + . $cecho 0 13 "b2 with vc145 support installed." +} + function main { & setup_build_cfg # Dispatch command. $command = $Args[0] - $command_args = $Args[1..($args.Count - 1)] + if ($args.Count -gt 1) { + $command_args = $Args[1..($args.Count - 1)] + } + else { + $command_args = @() + } & $command @command_args } diff --git a/win/vs-cfg.cmd b/win/vs-cfg.cmd index 794291792b..d89f3fa88b 100644 --- a/win/vs-cfg.cmd +++ b/win/vs-cfg.cmd @@ -35,6 +35,11 @@ :: "vs2019-x86-v141_xp" => cmake -G "Visual Studio 16 2019" -A Win32 -T v141_xp :: :: NOTE: The delayed environment variable expansion needs to be enabled before calling this. +:: +:: Output variables: +:: - VC_VER - e.g. "14.5" +:: - VS_VER - e.g. "2026" +:: - BOOST_BOOTSTRAP_VER - e.g. "vc145" @if not defined ECHO_ON ( echo off ) @@ -46,7 +51,8 @@ set GENERATORS[2]="Visual Studio 14 2015" set GENERATORS[3]="Visual Studio 15 2017" set GENERATORS[4]="Visual Studio 16 2019" set GENERATORS[5]="Visual Studio 17 2022" -set LAST_GENERATOR_IDX=5 +set GENERATORS[6]="Visual Studio 18 2026" +set LAST_GENERATOR_IDX=6 :: Is generator shorthand used? set GEN_SHORTHAND=!GENERATOR:vs=! @@ -104,6 +110,9 @@ IF "!GENERATOR!"=="" IF NOT "%VisualStudioVersion%"=="" ( GOTO :GeneratorValid ) ) + call utils\cecho.cmd 0 12 ^ + "Generator is not provided and VisualStudioVersion='%VisualStudioVersion%' is not supported - cannot proceed." + exit /b 1 ) :: Check that the used CMake version supports the chosen generator @@ -157,6 +166,7 @@ IF %VS_VER%==2015 ( set "VC_VER=14.0" ) IF %VS_VER%==2017 ( set "VC_VER=14.1" ) IF %VS_VER%==2019 ( set "VC_VER=14.2" ) IF %VS_VER%==2022 ( set "VC_VER=14.3" ) +IF %VS_VER%==2026 ( set "VC_VER=14.5" ) :: determine the argument for Boost bootstrap set BOOST_BOOTSTRAP_VER=vc%VC_VER%