From b82710164486151b3650283f1280648c264a18f3 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Mon, 10 Mar 2025 13:57:04 +0100 Subject: [PATCH 01/25] ci: simplify blitz ci --- .github/workflows/ci_cd.yml | 496 +++--------------------------------- 1 file changed, 40 insertions(+), 456 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index c417ed8322..ae74b44eb5 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -1,12 +1,9 @@ name: GitHub CI on: pull_request: - workflow_dispatch: push: - tags: - - "*" branches: - - main + - blitz env: MAIN_PYTHON_VERSION: '3.12' @@ -27,20 +24,6 @@ concurrency: jobs: - update-changelog: - name: "Update CHANGELOG (on release)" - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - steps: - - uses: ansys/actions/doc-deploy-changelog@v8 - with: - token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} - bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} - bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} - vulnerabilities: name: Vulnerabilities runs-on: ubuntu-latest @@ -71,29 +54,6 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} - smoke-tests: - name: Build and Smoke tests - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ['3.10', '3.11', '3.12', '3.13'] - should-release: - - ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }} - exclude: - - should-release: false - os: macos-latest - steps: - - name: Build wheelhouse and perform smoke test - uses: ansys/actions/build-wheelhouse@v8 - with: - library-name: ${{ env.PACKAGE_NAME }} - operating-system: ${{ matrix.os }} - python-version: ${{ matrix.python-version }} - whitelist-license-check: 'attrs,referencing' - target: 'all' - docker-style: name: Docker Style Check runs-on: ubuntu-latest @@ -161,8 +121,8 @@ jobs: testing-windows: name: Testing and coverage (Windows) - needs: [smoke-tests, manifests] - runs-on: [self-hosted, Windows, pygeometry] + needs: [manifests] + runs-on: [self-hosted, Windows, pygeometry-blitz] continue-on-error: ${{ matrix.experimental }} env: SKIP_UNSTABLE: false @@ -332,10 +292,42 @@ jobs: docker rm $dockerContainers } + - name: Clean all Docker dangling images + if: always() + run: docker image prune -f + + is_docs_pr: + name: Check if modifications are made to the docs folder + runs-on: ubuntu-latest + outputs: + build_required: ${{ steps.docs-build-required.outputs.build_required }} + steps: + - name: Checkouts the repository + uses: actions/checkout@v4 + + - name: Check if modifications are made to the doc folder with respect to the blitz branch + # Only run if the branch is not blitz + if: github.ref != 'refs/heads/blitz' + run: | + git fetch origin blitz + git diff --name-only origin/blitz doc/source/ | grep -q . + # Set the output variable to true if modifications are made to the docs folder + echo "build_docs=$(test $? -eq 0 && echo true || echo false)" >> $GITHUB_ENV + + - name: Always run on the blitz branch + if: github.ref == 'refs/heads/blitz' + run: echo "build_docs=true" >> $GITHUB_ENV + + - name: Store on output variable + id: docs-build-required + run: echo "build_required=${{ env.build_docs }}" >> $GITHUB_OUTPUT + docs: name: Documentation - needs: [docs-style] + needs: [is_docs_pr] runs-on: [self-hosted, Windows, pygeometry] + # Only run if docs build is required + if: ${{ needs.is_docs_pr.outputs.build_required == 'true' }} env: PYVISTA_OFF_SCREEN: true steps: @@ -393,6 +385,9 @@ jobs: docker rm $dockerContainers } + - name: Clean all Docker dangling images + if: always() + run: docker image prune -f # ================================================================================================= # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUNNING ON SELF-HOSTED RUNNER ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -400,7 +395,7 @@ jobs: testing-linux: name: Testing and coverage (Linux) - needs: [smoke-tests, manifests] + needs: [manifests] runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental }} env: @@ -498,109 +493,8 @@ jobs: docker rm ${{ env.GEO_CONT_NAME }} fi - testing-min-reqs: - name: Testing with minimum requirements - needs: [smoke-tests] - runs-on: ubuntu-latest - env: - ANSRV_GEO_IMAGE_MINREQS: 'ghcr.io/ansys/geometry:core-linux-latest' - strategy: - fail-fast: false - matrix: - python-version: ['3.10', '3.11', '3.12', '3.13'] - steps: - - name: Login in Github Container registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Pull and launch geometry service - run: | - docker pull ${{ env.ANSRV_GEO_IMAGE_MINREQS }} - docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ${{ env.ANSRV_GEO_IMAGE_MINREQS }} - - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install minimum requirements - run: | - python -m pip install --upgrade pip - pip install -e .[all,tests-minimal] - pip install pytest - - - name: Run pytest - run: | - pytest -v - - - name: Stop the Geometry service - if: always() - run: | - docker stop ${{ env.GEO_CONT_NAME }} - docker logs ${{ env.GEO_CONT_NAME }} - docker rm ${{ env.GEO_CONT_NAME }} - - testing-no-graphics: - name: Testing with minimum requirements (no graphics) - needs: [smoke-tests] - runs-on: ubuntu-latest - env: - ANSRV_GEO_IMAGE_MINREQS: 'ghcr.io/ansys/geometry:core-linux-latest' - strategy: - fail-fast: false - matrix: - python-version: ['3.10', '3.13'] - steps: - - name: Login in Github Container registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Pull and launch geometry service - run: | - docker pull ${{ env.ANSRV_GEO_IMAGE_MINREQS }} - docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ${{ env.ANSRV_GEO_IMAGE_MINREQS }} - - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install minimum requirements - run: | - python -m pip install --upgrade pip - pip install -e .[tests-minimal] - # Uninstall pytest-pyvista (not needed for these tests) - pip uninstall -y pytest-pyvista - # Installing docker (needed for the tests) - pip install docker - - - name: Run pytest - run: | - pytest -v -c pytest-nographics.ini - - - name: Stop the Geometry service - if: always() - run: | - docker stop ${{ env.GEO_CONT_NAME }} - docker logs ${{ env.GEO_CONT_NAME }} - docker rm ${{ env.GEO_CONT_NAME }} - - package: name: Package library - needs: [testing-windows, testing-linux, testing-min-reqs, testing-no-graphics, docs] runs-on: ubuntu-latest steps: - name: Build library source and wheel artifacts @@ -608,313 +502,3 @@ jobs: with: library-name: ${{ env.PACKAGE_NAME }} python-version: ${{ env.MAIN_PYTHON_VERSION }} - -# ================================================================================================= -# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv -# ================================================================================================= - - fetch-release-artifacts: - name: Fetch release artifacts - needs: [testing-windows, testing-linux, docs] - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - runs-on: - group: ansys-network - labels: [self-hosted, Windows, pygeometry] - env: - REUSE_LAST_ARTIFACTS: ${{ vars.REUSE_LAST_ARTIFACTS == 1 }} - - steps: - - name: Check out repository pyansys-geometry-binaries - uses: actions/checkout@v4 - with: - repository: 'ansys/pyansys-geometry-binaries' - token: ${{ secrets.BINARIES_TOKEN }} - - - name: Download binaries (if conditions met) - if: env.REUSE_LAST_ARTIFACTS == 'false' - run: | - curl.exe -X GET -H "X-JFrog-Art-Api: ${{ secrets.ARTIFACTORY_KEY }}" ${{ secrets.ARTIFACTORY_URL }}/${{ env.ARTIFACTORY_VERSION }}/DockerWindows.zip --output windows-dms-binaries.zip - curl.exe -X GET -H "X-JFrog-Art-Api: ${{ secrets.ARTIFACTORY_KEY }}" ${{ secrets.ARTIFACTORY_URL }}/${{ env.ARTIFACTORY_VERSION }}/DockerCoreWindows.zip --output windows-core-binaries.zip - curl.exe -X GET -H "X-JFrog-Art-Api: ${{ secrets.ARTIFACTORY_KEY }}" ${{ secrets.ARTIFACTORY_URL }}/${{ env.ARTIFACTORY_VERSION }}/DockerCoreLinux.zip --output linux-core-binaries.zip - - - name: Reuse last binaries (if conditions met) - if: env.REUSE_LAST_ARTIFACTS == 'true' - env: - VERSION_WITH_PREFIX: ${{ github.ref_name }} - run: | - # We are on a Windows machine. We need to copy the binaries from the previous tag, - # based on the current tag. We will also remove the trailing "v" from the tag. This will give - # us the folder from where we need to copy the binaries. - $env:VERSION=$env:VERSION_WITH_PREFIX.substring(1) - $env:PREVIOUS_VERSION=$env:VERSION.substring(0, $env:VERSION.Length - 1) - $env:PREVIOUS_PATCH_VERSION_NUMBER=$env:VERSION.substring($env:VERSION.Length - 1) - $env:PREVIOUS_PATCH_VERSION_NUMBER=[int]$env:PREVIOUS_PATCH_VERSION_NUMBER - 1 - $env:PREVIOUS_VERSION=$env:PREVIOUS_VERSION + $env:PREVIOUS_PATCH_VERSION_NUMBER - # Fetch the LFS files from the previous version - git lfs fetch origin --include="$env:PREVIOUS_VERSION/*" - git lfs checkout $env:PREVIOUS_VERSION - # Copy the binaries from the previous version - cp ./$env:PREVIOUS_VERSION/windows-dms-binaries.zip windows-dms-binaries.zip - cp ./$env:PREVIOUS_VERSION/windows-core-binaries.zip windows-core-binaries.zip - cp ./$env:PREVIOUS_VERSION/linux-core-binaries.zip linux-core-binaries.zip - - - name: Upload DMS Windows binaries as workflow artifacts - uses: actions/upload-artifact@v4 - with: - name: windows-dms-binaries.zip - path: windows-dms-binaries.zip - retention-days: 1 - - - name: Upload Linux Core service binaries as workflow artifacts - uses: actions/upload-artifact@v4 - with: - name: linux-core-binaries.zip - path: linux-core-binaries.zip - retention-days: 1 - - - name: Upload Windows Core service binaries as workflow artifacts - uses: actions/upload-artifact@v4 - with: - name: windows-core-binaries.zip - path: windows-core-binaries.zip - retention-days: 1 - - - name: Publish the binaries to private repo - env: - VERSION_WITH_PREFIX: ${{ github.ref_name }} - run: | - $env:VERSION=$env:VERSION_WITH_PREFIX.substring(1) - mkdir $env:VERSION -ErrorAction SilentlyContinue - Remove-Item -Recurse -Force .\$env:VERSION\* - mv windows-dms-binaries.zip .\$env:VERSION\ - mv windows-core-binaries.zip .\$env:VERSION\ - mv linux-core-binaries.zip .\$env:VERSION\ - git config user.email ${{ secrets.BINARIES_EMAIL }} - git config user.name ${{ secrets.BINARIES_USERNAME }} - git add * - git commit -m "adding binaries for ${{ github.ref_name }}" - git push origin main - - build-windows-container: - name: Building Geometry Service - Windows - runs-on: [self-hosted, Windows, pygeometry] - needs: [fetch-release-artifacts] - strategy: - fail-fast: false - matrix: - include: - - mode: "dms" - docker-file: "windows-dms-dockerfile.zip" - zip-file: "windows-dms-binaries.zip" - - mode: "coreservice" - docker-file: "windows-core-dockerfile.zip" - zip-file: "windows-core-binaries.zip" - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: Download Windows binaries for ${{ matrix.mode }} - uses: actions/download-artifact@v4 - with: - name: ${{ matrix.zip-file }} - path: docker/${{ matrix.zip-file }} - - - name: Build Docker image - working-directory: docker - run: | - docker build -f windows/${{ matrix.mode }}/Dockerfile -t ghcr.io/ansys/geometry:windows-tmp . - - - name: Check location of self-hosted runner and define license server accordingly - if: runner.name == 'pygeometry-ci-2' - run: - echo "ANSRV_GEO_LICENSE_SERVER=${{ secrets.INTERNAL_LICENSE_SERVER }}" | Out-File -FilePath $env:GITHUB_ENV -Append - - - name: Launch Geometry service - run: | - docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ghcr.io/ansys/geometry:windows-tmp - - - name: Validate connection using PyAnsys Geometry - run: | - python -m venv .venv - .\.venv\Scripts\Activate.ps1 - python -m pip install --upgrade pip - pip install -e .[tests] - python -c "from ansys.geometry.core.connection.validate import validate; validate()" - - - name: Restore images cache - uses: actions/cache@v4 - with: - path: .\tests\integration\image_cache - key: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}-${{ hashFiles('pyproject.toml') }} - restore-keys: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }} - - - name: Testing - run: | - .\.venv\Scripts\Activate.ps1 - pytest -v --use-existing-service=yes - - - name: "Compressing Windows Dockerfile" - uses: vimtor/action-zip@v1.2 - with: - files: docker/windows/${{ matrix.mode }}/Dockerfile - dest: ${{ matrix.docker-file }} - - - name: Upload Windows Dockerfile - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.docker-file }} - path: ${{ matrix.docker-file }} - retention-days: 7 - - - name: Stop the Geometry service - if: always() - run: | - docker stop ${{ env.GEO_CONT_NAME }} - docker logs ${{ env.GEO_CONT_NAME }} - docker rm ${{ env.GEO_CONT_NAME }} - - - name: Stop any remaining containers - if: always() - run: | - $dockerContainers = docker ps -a -q - if (-not [string]::IsNullOrEmpty($dockerContainers)) { - docker stop $dockerContainers - docker rm $dockerContainers - } - - - name: Delete the Docker images (and untagged ones) - if: always() - run: | - docker image rm ghcr.io/ansys/geometry:windows-tmp - docker system prune -f - -# ================================================================================================= -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUNNING ON SELF-HOSTED RUNNER ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# ================================================================================================= - - build-linux-container: - name: Building Geometry Service - Linux - runs-on: ubuntu-latest - needs: [fetch-release-artifacts] - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: Download Linux binaries - uses: actions/download-artifact@v4 - with: - name: linux-core-binaries.zip - path: docker/linux-core-binaries.zip - - - name: Build Docker image - working-directory: docker - run: | - docker build -f linux/coreservice/Dockerfile -t ghcr.io/ansys/geometry:linux-tmp . - - - name: Launch Geometry service - run: | - docker run --detach --name ${{ env.GEO_CONT_NAME }} -e LICENSE_SERVER=${{ env.ANSRV_GEO_LICENSE_SERVER }} -p ${{ env.ANSRV_GEO_PORT }}:50051 ghcr.io/ansys/geometry:linux-tmp - - - name: Validate connection using PyAnsys Geometry - run: | - python -m pip install --upgrade pip - pip install -e .[tests] - python -c "from ansys.geometry.core.connection.validate import validate; validate()" - - - name: Restore images cache - uses: actions/cache@v4 - with: - path: .\tests\integration\image_cache - key: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}-${{ hashFiles('pyproject.toml') }} - restore-keys: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }} - - - name: Run pytest - uses: ansys/actions/tests-pytest@v8 - env: - ALLOW_PLOTTING: true - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - pytest-extra-args: "--use-existing-service=yes" - checkout: false - requires-xvfb: true - - - name: "Compressing Linux Dockerfile" - uses: vimtor/action-zip@v1.2 - with: - files: docker/linux/coreservice/Dockerfile - dest: linux-core-dockerfile.zip - - - name: Upload Linux Dockerfile - uses: actions/upload-artifact@v4 - with: - name: linux-core-dockerfile.zip - path: linux-core-dockerfile.zip - retention-days: 7 - - - name: Stop the Geometry service - if: always() - run: | - docker stop ${{ env.GEO_CONT_NAME }} - docker logs ${{ env.GEO_CONT_NAME }} - docker rm ${{ env.GEO_CONT_NAME }} - - release: - name: Release project - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - needs: [package, build-windows-container, build-linux-container, update-changelog] - runs-on: ubuntu-latest - # Specifying a GitHub environment is optional, but strongly encouraged - environment: release - permissions: - id-token: write - contents: write - steps: - - name: Release to the public PyPI repository - uses: ansys/actions/release-pypi-public@v8 - with: - library-name: ${{ env.PACKAGE_NAME }} - use-trusted-publisher: true - - - name: Release to GitHub - uses: ansys/actions/release-github@v8 - with: - library-name: ${{ env.PACKAGE_NAME }} - additional-artifacts: windows-dms-dockerfile.zip windows-core-dockerfile.zip linux-core-dockerfile.zip - - upload_dev_docs: - name: Upload dev documentation - if: github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - needs: [package] - steps: - - name: Deploy the latest documentation - uses: ansys/actions/doc-deploy-dev@v8 - with: - cname: ${{ env.DOCUMENTATION_CNAME }} - token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} - bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} - bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} - - upload_docs_release: - name: Upload release documentation - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - runs-on: ubuntu-latest - needs: [release] - steps: - - name: Deploy the stable documentation - uses: ansys/actions/doc-deploy-stable@v8 - with: - cname: ${{ env.DOCUMENTATION_CNAME }} - token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} - bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} - bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} From 7039876ac4af0500f45346f689f990ef4402f92e Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Mon, 10 Mar 2025 15:13:10 -0500 Subject: [PATCH 02/25] fix: translating sketch issues when using a custom default unit (#1808) Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> --- .github/workflows/ci_cd.yml | 8 ++++--- doc/changelog.d/1808.fixed.md | 1 + src/ansys/geometry/core/sketch/sketch.py | 16 +++++++++---- tests/integration/test_issues.py | 29 ++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 doc/changelog.d/1808.fixed.md diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index ae74b44eb5..83e0383c27 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -310,9 +310,11 @@ jobs: if: github.ref != 'refs/heads/blitz' run: | git fetch origin blitz - git diff --name-only origin/blitz doc/source/ | grep -q . - # Set the output variable to true if modifications are made to the docs folder - echo "build_docs=$(test $? -eq 0 && echo true || echo false)" >> $GITHUB_ENV + if [ -n "$(git diff --name-only origin/blitz doc/source/)" ]; then + echo "build_docs=true" >> $GITHUB_ENV + else + echo "build_docs=false" >> $GITHUB_ENV + fi - name: Always run on the blitz branch if: github.ref == 'refs/heads/blitz' diff --git a/doc/changelog.d/1808.fixed.md b/doc/changelog.d/1808.fixed.md new file mode 100644 index 0000000000..be95a47cab --- /dev/null +++ b/doc/changelog.d/1808.fixed.md @@ -0,0 +1 @@ +translating sketch issues when using a custom default unit \ No newline at end of file diff --git a/src/ansys/geometry/core/sketch/sketch.py b/src/ansys/geometry/core/sketch/sketch.py index 4dd2fffcb5..d83006fe05 100644 --- a/src/ansys/geometry/core/sketch/sketch.py +++ b/src/ansys/geometry/core/sketch/sketch.py @@ -28,7 +28,7 @@ from ansys.geometry.core.math.constants import ZERO_POINT2D from ansys.geometry.core.math.plane import Plane -from ansys.geometry.core.math.point import Point2D +from ansys.geometry.core.math.point import Point2D, Point3D from ansys.geometry.core.math.vector import UnitVector3D, Vector2D, Vector3D from ansys.geometry.core.misc.checks import graphics_required from ansys.geometry.core.misc.measurements import DEFAULT_UNITS, Angle, Distance @@ -121,16 +121,24 @@ def translate_sketch_plane(self, translation: Vector3D) -> "Sketch": Parameters ---------- translation : Vector3D - Vector defining the translation. Meters is the expected unit. + Vector defining the translation. Default units are the expected + units, otherwise it will be inconsistent. Returns ------- Sketch Revised sketch state ready for further sketch actions. """ - self.plane = Plane( - self.plane.origin + translation, self.plane.direction_x, self.plane.direction_y + new_origin = Point3D( + [ + self.plane.origin.x.m_as(DEFAULT_UNITS.LENGTH) + translation.x, + self.plane.origin.y.m_as(DEFAULT_UNITS.LENGTH) + translation.y, + self.plane.origin.z.m_as(DEFAULT_UNITS.LENGTH) + translation.z, + ] ) + # Set the same unit system as the plane origin + new_origin.unit = self.plane.origin.unit + self.plane = Plane(new_origin, self.plane.direction_x, self.plane.direction_y) return self @check_input_types diff --git a/tests/integration/test_issues.py b/tests/integration/test_issues.py index 4cfa07538b..ca727c4703 100644 --- a/tests/integration/test_issues.py +++ b/tests/integration/test_issues.py @@ -33,6 +33,7 @@ Point2D, Point3D, ) +from ansys.geometry.core.math.vector import UnitVector3D from ansys.geometry.core.misc import DEFAULT_UNITS, UNITS, Angle, Distance from ansys.geometry.core.modeler import Modeler from ansys.geometry.core.sketch import Sketch @@ -260,3 +261,31 @@ def test_issue_1724_intersect_failures(modeler: Modeler): # Verify that the volume of the cylinder is the same (the intersect is the same as the cylinder) assert np.isclose(design.bodies[0].volume.m, np.pi * radius**2 * (wz - 0.1)) + + +def test_issue_1807_translate_sketch_non_default_units(): + """Test that translating a sketch with non-default units is handled properly. + + For more info see + https://github.com/ansys/pyansys-geometry/issues/1807 + """ + try: + # Set the default units to mm + DEFAULT_UNITS.LENGTH = UNITS.mm + + # Draw a box sketch + sketch = Sketch() + sketch.box(Point2D([0, 0]), 10, 10) + + # Verify the sketch plane origin + assert sketch.plane.origin == Point3D([0, 0, 0]) + + # Translate the sketch + sketch.translate_sketch_plane_by_distance(UnitVector3D([0, 0, 1]), Distance(10, UNITS.mm)) + + # Verify the new sketch plane origin + assert sketch.plane.origin == Point3D([0, 0, 10], unit=UNITS.mm) + + finally: + # Reset the default units to meters + DEFAULT_UNITS.LENGTH = UNITS.meter From f26f02c44ccb8d34765e82f1b4b3387129448da6 Mon Sep 17 00:00:00 2001 From: Umut Soysal <97195410+umutsoysalansys@users.noreply.github.com> Date: Tue, 11 Mar 2025 14:56:00 +0100 Subject: [PATCH 03/25] feat: matrix helper methods (#1806) Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Co-authored-by: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> --- doc/changelog.d/1806.added.md | 1 + src/ansys/geometry/core/math/matrix.py | 59 ++++++++++++++++ src/ansys/geometry/core/math/vector.py | 17 +++++ tests/test_math.py | 95 ++++++++++++++++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 doc/changelog.d/1806.added.md diff --git a/doc/changelog.d/1806.added.md b/doc/changelog.d/1806.added.md new file mode 100644 index 0000000000..c1bd214626 --- /dev/null +++ b/doc/changelog.d/1806.added.md @@ -0,0 +1 @@ +matrix helper methods \ No newline at end of file diff --git a/src/ansys/geometry/core/math/matrix.py b/src/ansys/geometry/core/math/matrix.py index f0fdcf41f3..fb9577316b 100644 --- a/src/ansys/geometry/core/math/matrix.py +++ b/src/ansys/geometry/core/math/matrix.py @@ -30,6 +30,7 @@ from ansys.geometry.core.typing import Real, RealSequence if TYPE_CHECKING: + from ansys.geometry.core.math.frame import Frame from ansys.geometry.core.math.vector import Vector3D # For type hints DEFAULT_MATRIX33 = np.identity(3) @@ -308,3 +309,61 @@ def create_rotation( ] ) return matrix + + @classmethod + def create_matrix_from_rotation_about_axis(cls, axis: "Vector3D", angle: float) -> "Matrix44": + """ + Create a matrix representing a rotation about a given axis. + + Parameters + ---------- + axis : Vector3D + The axis of rotation. + angle : float + The angle of rotation in radians. + + Returns + ------- + Matrix44 + A 4x4 matrix representing the rotation. + """ + axis_dir = axis.normalize() + x, y, z = axis_dir[0], axis_dir[1], axis_dir[2] + + k = np.array([[0, -z, y], [z, 0, -x], [-y, x, 0]]) + + identity = np.eye(3) + cos_theta = np.cos(angle) + sin_theta = np.sin(angle) + + # Rodrigues' rotation formula + rotation_3x3 = identity + sin_theta * k + (1 - cos_theta) * (k @ k) + + # Convert to a 4x4 homogeneous matrix + rotation_matrix = np.eye(4) + rotation_matrix[:3, :3] = rotation_3x3 + + return cls(rotation_matrix) + + @classmethod + def create_matrix_from_mapping(cls, frame: "Frame") -> "Matrix44": + """ + Create a matrix representing the specified mapping. + + Parameters + ---------- + frame : Frame + The frame containing the origin and direction vectors. + + Returns + ------- + Matrix44 + A 4x4 matrix representing the translation and rotation defined by the frame. + """ + from ansys.geometry.core.math.vector import Vector3D + + translation_matrix = Matrix44.create_translation( + Vector3D([frame.origin[0], frame.origin[1], frame.origin[2]]) + ) + rotation_matrix = Matrix44.create_rotation(frame.direction_x, frame.direction_y) + return translation_matrix * rotation_matrix diff --git a/src/ansys/geometry/core/math/vector.py b/src/ansys/geometry/core/math/vector.py index b986196175..3e850b535f 100644 --- a/src/ansys/geometry/core/math/vector.py +++ b/src/ansys/geometry/core/math/vector.py @@ -32,6 +32,7 @@ from ansys.geometry.core.math.point import Point2D, Point3D from ansys.geometry.core.misc.accuracy import Accuracy from ansys.geometry.core.misc.checks import check_ndarray_is_float_int +from ansys.geometry.core.misc.measurements import Angle from ansys.geometry.core.misc.units import UNITS from ansys.geometry.core.typing import Real, RealSequence @@ -163,6 +164,22 @@ def transform(self, matrix: "Matrix44") -> "Vector3D": result_vector = Vector3D(result_4x1[0:3]) return result_vector + @check_input_types + def rotate_vector(self, vector: "Vector3D", angle: Real | Quantity | Angle) -> "Vector3D": + """Rotate a vector around a given axis by a specified angle.""" + if self.is_zero: + raise Exception("Invalid vector operation: rotation axis cannot be zero.") + + # Convert angle to Angle object and get its value in radians + angle = angle if isinstance(angle, Angle) else Angle(angle) + angle_m = angle.value.m_as(UNITS.radian) + + axis = self.normalize() + parallel = axis * (vector.dot(axis)) + perpendicular1 = vector - parallel + perpendicular2 = axis.cross(perpendicular1) + return parallel + perpendicular1 * np.cos(angle_m) + perpendicular2 * np.sin(angle_m) + @check_input_types def get_angle_between(self, v: "Vector3D") -> Quantity: """Get the angle between this 3D vector and another 3D vector. diff --git a/tests/test_math.py b/tests/test_math.py index 779845e003..630cbfc5f5 100644 --- a/tests/test_math.py +++ b/tests/test_math.py @@ -24,6 +24,7 @@ from beartype.roar import BeartypeCallHintParamViolation import numpy as np +from pint import Quantity import pytest from ansys.geometry.core.math import ( @@ -627,6 +628,24 @@ def test_vector2d_errors(): v1.get_angle_between(v2) +def test_rotate_vector(): + """Test the rotate_vector method.""" + # Define the vectors and angle + axis = Vector3D([0.0, 0.0, 1.0]) + vector = Vector3D([1.0, 0.0, 0.0]) + + angle = Quantity(np.pi / 2) # 90 degrees + + # Expected result after rotating vector around axis by 90 degrees + expected_vector = Vector3D([0.0, 1.0, 0.0]) + + # Call the method under test + result_vector = axis.rotate_vector(vector, angle) + + # Assert that the result matches the expected vector + assert np.allclose(result_vector, expected_vector) + + def test_matrix(): """Simple test to create a ``Matrix``.""" # Create two matrix objects @@ -827,6 +846,82 @@ def test_create_rotation_matrix(): assert np.array_equal(expected_matrix, rotation_matrix) +def test_create_matrix_from_rotation_about_axis_x(): + """Test the create_matrix_from_rotation_about_axis method for rotation about the x-axis.""" + axis = Vector3D([1.0, 0.0, 0.0]) + angle = np.pi / 2 # 90 degrees + expected_matrix = Matrix44([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) + + result_matrix = Matrix44.create_matrix_from_rotation_about_axis(axis, angle) + + print(result_matrix) + assert np.allclose(result_matrix, expected_matrix) + + +def test_create_matrix_from_rotation_about_axis_y(): + """Test the create_matrix_from_rotation_about_axis method for rotation about the y-axis.""" + axis = Vector3D([0.0, 1.0, 0.0]) + angle = np.pi / 2 # 90 degrees + expected_matrix = Matrix44([[0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 1]]) + + result_matrix = Matrix44.create_matrix_from_rotation_about_axis(axis, angle) + assert np.allclose(result_matrix, expected_matrix) + + +def test_create_matrix_from_rotation_about_axis_z(): + """Test the create_matrix_from_rotation_about_axis method for rotation about the z-axis.""" + axis = Vector3D([0.0, 0.0, 1.0]) + angle = np.pi / 2 # 90 degrees + expected_matrix = Matrix44([[0, -1, 0, 0], [1, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) + + result_matrix = Matrix44.create_matrix_from_rotation_about_axis(axis, angle) + assert np.allclose(result_matrix, expected_matrix) + + +def test_create_matrix_from_rotation_about_arbitrary_axis(): + """Test the create_matrix_from_rotation_about_axis method for + rotation about an arbitrary axis. + """ + axis = Vector3D([1.0, 1.0, 1.0]).normalize() + angle = np.pi / 3 # 60 degrees + # Expected matrix calculated using external tools or libraries + expected_matrix = Matrix44( + [ + [0.66666667, -0.33333333, 0.66666667, 0], + [0.66666667, 0.66666667, -0.33333333, 0], + [-0.33333333, 0.66666667, 0.66666667, 0], + [0, 0, 0, 1], + ] + ) + + result_matrix = Matrix44.create_matrix_from_rotation_about_axis(axis, angle) + assert np.allclose(result_matrix, expected_matrix) + + +def test_create_matrix_from_mapping(): + """Test the create_matrix_from_mapping method.""" + # Define the frame with origin and direction vectors + origin = Vector3D([1.0, 2.0, 3.0]) + direction_x = Vector3D([1.0, 0.0, 0.0]) + direction_y = Vector3D([0.0, 1.0, 0.0]) + frame = Frame(origin, direction_x, direction_y) + + # Create the expected translation matrix + expected_translation_matrix = Matrix44.create_translation(origin) + + # Create the expected rotation matrix + expected_rotation_matrix = Matrix44.create_rotation(direction_x, direction_y) + + # Create the expected result by multiplying the translation and rotation matrices + expected_matrix = expected_translation_matrix * expected_rotation_matrix + + # Call the method under test + result_matrix = Matrix44.create_matrix_from_mapping(frame) + + # Assert that the result matches the expected matrix + assert np.allclose(result_matrix, expected_matrix) + + def test_frame(): """``Frame`` construction and equivalency.""" origin = Point3D([42, 99, 13]) From 472f787bf281e7cbf466bcc970dbf61a1262c7b2 Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Tue, 11 Mar 2025 09:49:59 -0500 Subject: [PATCH 04/25] new method --- src/ansys/geometry/core/designer/design.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index bb63f6e72d..039c7187fa 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1221,3 +1221,6 @@ def _update_design_inplace(self) -> None: # Read the existing design self.__read_existing_design() + + def _update_from_delta(): + return True From 6e267725d1aaedf0d061ca11beb758ef0a568542 Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Thu, 13 Mar 2025 15:53:50 -0500 Subject: [PATCH 05/25] surface body --- src/ansys/geometry/core/designer/design.py | 35 +++++++++++++++++-- .../geometry/core/tools/problem_areas.py | 3 +- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 039c7187fa..620774b991 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1222,5 +1222,36 @@ def _update_design_inplace(self) -> None: # Read the existing design self.__read_existing_design() - def _update_from_delta(): - return True + def update_from_tracker(self, changed_bodies): + """ + Update the design with the changed bodies while preserving unchanged ones. + + Parameters + ---------- + changed_bodies : list[dict] + A list of dictionaries representing changed body information. Each dictionary + should contain 'id', 'name', and 'is_surface' keys. + """ + print("Updating design using the tracker...") + # Create a mapping of existing bodies for quick lookup + existing_body_map = {body.id: body for body in self.bodies} + + # Process changed bodies + for body_info in changed_bodies.modified_bodies: + body_id = body_info.id + body_name = body_info.name + is_surface = body_info.is_surface + + if body_id in existing_body_map: + # Update existing body + existing_body = existing_body_map[body_id] + existing_body.name = body_name + existing_body._template._is_surface = is_surface + print(f"Updated body: {body_name} (ID: {body_id})") + else: + # Create and add new body + new_body = MasterBody(body_id, body_name, self._grpc_client, is_surface=is_surface) + self.bodies.append(new_body) + print(f"Added new body: {body_name} (ID: {body_id})") + + print("Design update completed.") diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index bea39b436d..628eb3164f 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -185,12 +185,13 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixMissingFaces( FixMissingFacesRequest(missing_face_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, response.result.modified_bodies_monikers, ) + parent_design.update_from_tracker(response.result.complete_command_response) return message From ed2c9a57d2013b320b18d3f2d023e3ee2b01c22c Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Wed, 19 Mar 2025 09:04:59 -0500 Subject: [PATCH 06/25] update with latest tracker for bodies --- src/ansys/geometry/core/designer/design.py | 125 ++++++++++++++++-- .../geometry/core/tools/problem_areas.py | 4 +- 2 files changed, 115 insertions(+), 14 deletions(-) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 620774b991..646c225db0 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1222,7 +1222,7 @@ def _update_design_inplace(self) -> None: # Read the existing design self.__read_existing_design() - def update_from_tracker(self, changed_bodies): + def update_from_tracker(self, tracker_response): """ Update the design with the changed bodies while preserving unchanged ones. @@ -1233,23 +1233,122 @@ def update_from_tracker(self, changed_bodies): should contain 'id', 'name', and 'is_surface' keys. """ print("Updating design using the tracker...") - # Create a mapping of existing bodies for quick lookup - existing_body_map = {body.id: body for body in self.bodies} - # Process changed bodies - for body_info in changed_bodies.modified_bodies: + # Function to update a body if it exists + def update_body(existing_body, body_info): + existing_body.name = body_info.name + existing_body._template._is_surface = body_info.is_surface + print(f"Updated body: {body_info.name} (ID: {body_info.id})") + + # Function to find and add bodies within components recursively + def find_and_add_body(body_info, components): + for component in components: + if component.id == body_info["parent_id"]: + new_body = MasterBody( + body_info["id"], + body_info["name"], + self._grpc_client, + is_surface=body_info["is_surface"], + ) + component.bodies.append(new_body) + print(f"Added new body: {body_info['name']} (ID: {body_info['id']})") + return True # Found and added + + # Recursively search in subcomponents + if find_and_add_body(body_info, component.components): + return True + + return False # Not found + + # Function to find and update bodies within components recursively + def find_and_update_body(body_info, components): + for component in components: + if component.id == body_info.parent_id: + for body in component.bodies: + if body.id == body_info.id: + update_body(body, body_info) + return True # Found and updated + + # Recursively search in subcomponents + if find_and_update_body(body_info, component.components): + return True + + return False # Not found + + # Function to find and remove bodies within components recursively + + def find_and_remove_body(body_info, components): + for component in components: + if component.id == body_info.parent_id: + for body in component.bodies: + if body.id == body_info.id: + component.bodies.remove(body) + print(f"Removed body: {body_info.id}") + return True # Found and removed + + # Recursively search in subcomponents + if find_and_remove_body(body_info, component.components): + return True + + return False # Not found + + # Loop through all changed bodies from the tracker + for body_info in tracker_response.modified_bodies: body_id = body_info.id body_name = body_info.name is_surface = body_info.is_surface - if body_id in existing_body_map: - # Update existing body - existing_body = existing_body_map[body_id] - existing_body.name = body_name - existing_body._template._is_surface = is_surface - print(f"Updated body: {body_name} (ID: {body_id})") - else: - # Create and add new body + updated = False # Track if a body was updated + + # First, check bodies at the root level + for body in self.bodies: + if body.id == body_id: + update_body(body, body_info) + updated = True + break + + # If not found in root, search within components + if not updated: + updated = find_and_update_body(body_info, self.components) + + # Loop through all deleted bodies from the tracker + for body_info in tracker_response.deleted_bodies: + body_id = body_info.id + + removed = False # Track if a body was removed + + # First, check bodies at the root level + for body in self.bodies: + if body.id == body_id: + self.bodies.remove(body) + print(f"Removed body: {body_id}") + removed = True + break + + # If not found in root, search within components + if not removed: + removed = find_and_remove_body(body_info, self.components) + + # Loop through all added bodies from the tracker + for body_info in tracker_response.added_bodies: + body_id = body_info["id"] + body_name = body_info["name"] + is_surface = body_info["is_surface"] + + added = False # Track if a body was added + + # First, check if the body already exists at the root level + for body in self.bodies: + if body.id == body_id: + added = True + break + + # If not found in root, search within components + if not added: + added = find_and_add_body(body_info, self.components) + + # If still not found, add it as a new body at the root level + if not added: new_body = MasterBody(body_id, body_name, self._grpc_client, is_surface=is_surface) self.bodies.append(new_body) print(f"Added new body: {body_name} (ID: {body_id})") diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index 628eb3164f..be94736449 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -130,13 +130,15 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixDuplicateFaces( FixDuplicateFacesRequest(duplicate_face_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, response.result.modified_bodies_monikers, ) + parent_design.update_from_tracker(response.result.complete_command_response) + return message From 3c376bbd2c7fd531d1c5cd8b622a372b8ec29396 Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Mon, 7 Apr 2025 15:11:46 -0500 Subject: [PATCH 07/25] update in tracker --- src/ansys/geometry/core/designer/design.py | 39 ++++++++++--------- .../core/tools/repair_tool_message.py | 4 ++ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 554012c813..965218aefc 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1287,6 +1287,8 @@ def update_from_tracker(self, tracker_response): """ print("Updating design using the tracker...") + def update_component(component, component_info): + # Function to update a body if it exists def update_body(existing_body, body_info): existing_body.name = body_info.name @@ -1294,7 +1296,7 @@ def update_body(existing_body, body_info): print(f"Updated body: {body_info.name} (ID: {body_info.id})") # Function to find and add bodies within components recursively - def find_and_add_body(body_info, components): + def find_and_add_body(body_info, component): for component in components: if component.id == body_info["parent_id"]: new_body = MasterBody( @@ -1314,13 +1316,13 @@ def find_and_add_body(body_info, components): return False # Not found # Function to find and update bodies within components recursively - def find_and_update_body(body_info, components): - for component in components: - if component.id == body_info.parent_id: - for body in component.bodies: - if body.id == body_info.id: - update_body(body, body_info) - return True # Found and updated + def find_and_update_body(body_info, component): + if component == []: + return False + for body in component.bodies: + if body.id == body_info.id: + update_body(body, body_info) + return True # Found and updated # Recursively search in subcomponents if find_and_update_body(body_info, component.components): @@ -1330,14 +1332,14 @@ def find_and_update_body(body_info, components): # Function to find and remove bodies within components recursively - def find_and_remove_body(body_info, components): - for component in components: - if component.id == body_info.parent_id: - for body in component.bodies: - if body.id == body_info.id: - component.bodies.remove(body) - print(f"Removed body: {body_info.id}") - return True # Found and removed + def find_and_remove_body(body_info, component): + if component =[]: + return False + for body in component.bodies: + if body.id == body_info.id: + component.bodies.remove(body) + print(f"Removed body: {body_info.id}") + return True # Found and removed # Recursively search in subcomponents if find_and_remove_body(body_info, component.components): @@ -1362,7 +1364,8 @@ def find_and_remove_body(body_info, components): # If not found in root, search within components if not updated: - updated = find_and_update_body(body_info, self.components) + for component in self.components: + updated = find_and_update_body(body_info, component) # Loop through all deleted bodies from the tracker for body_info in tracker_response.deleted_bodies: @@ -1383,7 +1386,7 @@ def find_and_remove_body(body_info, components): removed = find_and_remove_body(body_info, self.components) # Loop through all added bodies from the tracker - for body_info in tracker_response.added_bodies: + for body_info in tracker_response.created_bodies: body_id = body_info["id"] body_name = body_info["name"] is_surface = body_info["is_surface"] diff --git a/src/ansys/geometry/core/tools/repair_tool_message.py b/src/ansys/geometry/core/tools/repair_tool_message.py index 4329c7d7f7..5b4148223c 100644 --- a/src/ansys/geometry/core/tools/repair_tool_message.py +++ b/src/ansys/geometry/core/tools/repair_tool_message.py @@ -30,6 +30,10 @@ def __init__( success: bool, created_bodies: list[str], modified_bodies: list[str], + deleted_bodies: list[str] = None, + craeted_components: list[str] = None, + modified_components: list[str] = None, + deleted_components: list[str]= None, found: int = -1, repaired: int = -1, ): From 99f00f339c45accf33911ad094697936f97f46d1 Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Mon, 7 Apr 2025 16:56:20 -0500 Subject: [PATCH 08/25] tracker updated --- src/ansys/geometry/core/designer/design.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 965218aefc..9ec81eb361 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1287,7 +1287,7 @@ def update_from_tracker(self, tracker_response): """ print("Updating design using the tracker...") - def update_component(component, component_info): + # Function to update a body if it exists def update_body(existing_body, body_info): @@ -1333,7 +1333,7 @@ def find_and_update_body(body_info, component): # Function to find and remove bodies within components recursively def find_and_remove_body(body_info, component): - if component =[]: + if component ==[]: return False for body in component.bodies: if body.id == body_info.id: From 32be1b10d0f7dce530bf9b0301b5cd63f3093e52 Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Tue, 8 Apr 2025 09:23:49 -0500 Subject: [PATCH 09/25] duplicate and inexact faces --- src/ansys/geometry/core/tools/problem_areas.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index fbc3615e06..17905636e4 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -136,7 +136,7 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixDuplicateFaces( FixDuplicateFacesRequest(duplicate_face_problem_area_id=self._grpc_id) ) - # parent_design._update_design_inplace() + #parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, @@ -248,7 +248,7 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixInexactEdges( FixInexactEdgesRequest(inexact_edge_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + #parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, @@ -301,12 +301,12 @@ def fix(self) -> RepairToolMessage: parent_design = get_design_from_edge(self.edges[0]) request = FixExtraEdgesRequest(extra_edge_problem_area_id=self._grpc_id) response = self._repair_stub.FixExtraEdges(request) - parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, response.result.modified_bodies_monikers, ) + parent_design.update_from_tracker(response.result.complete_command_response) return message From b70665ca48d1e04a1e7fe76c0d092091388a9cd3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 14:49:26 +0000 Subject: [PATCH 10/25] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/designer/design.py | 4 +--- src/ansys/geometry/core/tools/problem_areas.py | 4 ++-- src/ansys/geometry/core/tools/repair_tool_message.py | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 83d4ac70a0..74b542807f 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1284,8 +1284,6 @@ def update_from_tracker(self, tracker_response): """ print("Updating design using the tracker...") - - # Function to update a body if it exists def update_body(existing_body, body_info): existing_body.name = body_info.name @@ -1330,7 +1328,7 @@ def find_and_update_body(body_info, component): # Function to find and remove bodies within components recursively def find_and_remove_body(body_info, component): - if component ==[]: + if component == []: return False for body in component.bodies: if body.id == body_info.id: diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index 0a2a67f494..83de5da23d 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -131,7 +131,7 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixDuplicateFaces( FixDuplicateFacesRequest(duplicate_face_problem_area_id=self._grpc_id) ) - #parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, @@ -243,7 +243,7 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixInexactEdges( FixInexactEdgesRequest(inexact_edge_problem_area_id=self._grpc_id) ) - #parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, diff --git a/src/ansys/geometry/core/tools/repair_tool_message.py b/src/ansys/geometry/core/tools/repair_tool_message.py index 5b4148223c..45ef82c33e 100644 --- a/src/ansys/geometry/core/tools/repair_tool_message.py +++ b/src/ansys/geometry/core/tools/repair_tool_message.py @@ -33,7 +33,7 @@ def __init__( deleted_bodies: list[str] = None, craeted_components: list[str] = None, modified_components: list[str] = None, - deleted_components: list[str]= None, + deleted_components: list[str] = None, found: int = -1, repaired: int = -1, ): From cc056172219ebfa5c3df5317f1b5899b485f770a Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Fri, 18 Apr 2025 14:50:59 +0000 Subject: [PATCH 11/25] chore: adding changelog file 1922.added.md [dependabot-skip] --- doc/changelog.d/1922.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/1922.added.md diff --git a/doc/changelog.d/1922.added.md b/doc/changelog.d/1922.added.md new file mode 100644 index 0000000000..b150ea1e50 --- /dev/null +++ b/doc/changelog.d/1922.added.md @@ -0,0 +1 @@ +update with delta \ No newline at end of file From e2a9046e2b06f55f8160d7462f570bee4b8a76a2 Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Fri, 18 Apr 2025 12:09:43 -0500 Subject: [PATCH 12/25] replacing update design inplace --- src/ansys/geometry/core/tools/problem_areas.py | 12 +++++++++--- src/ansys/geometry/core/tools/repair_tools.py | 13 +++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index 83de5da23d..412272c395 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -351,12 +351,13 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixShortEdges( FixShortEdgesRequest(short_edge_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + #parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, response.result.modified_bodies_monikers, ) + parent_design.update_from_tracker(response.result.complete_command_response) return message @@ -406,12 +407,15 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixSmallFaces( FixSmallFacesRequest(small_face_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + #parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, response.result.modified_bodies_monikers, ) + + parent_design.update_from_tracker(response.result.complete_command_response) + return message @@ -460,12 +464,14 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixSplitEdges( FixSplitEdgesRequest(split_edge_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + #parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, response.result.modified_bodies_monikers, ) + parent_design.update_from_tracker(response.result.complete_command_response) + return message diff --git a/src/ansys/geometry/core/tools/repair_tools.py b/src/ansys/geometry/core/tools/repair_tools.py index 8bb984088f..0a6451dfe6 100644 --- a/src/ansys/geometry/core/tools/repair_tools.py +++ b/src/ansys/geometry/core/tools/repair_tools.py @@ -509,7 +509,7 @@ def find_and_fix_short_edges( ) parent_design = get_design_from_body(bodies[0]) - parent_design._update_design_inplace() + #parent_design._update_design_inplace() message = RepairToolMessage( response.success, response.created_bodies_monikers, @@ -517,6 +517,7 @@ def find_and_fix_short_edges( response.found, response.repaired, ) + parent_design.update_from_tracker(response.result.complete_command_response) return message @protect_grpc @@ -560,7 +561,7 @@ def find_and_fix_extra_edges( ) parent_design = get_design_from_body(bodies[0]) - parent_design._update_design_inplace() + #parent_design._update_design_inplace() message = RepairToolMessage( response.success, response.created_bodies_monikers, @@ -568,6 +569,7 @@ def find_and_fix_extra_edges( response.found, response.repaired, ) + parent_design.update_from_tracker(response.result.complete_command_response) return message @protect_grpc @@ -626,7 +628,7 @@ def find_and_fix_split_edges( ) parent_design = get_design_from_body(bodies[0]) - parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.success, response.created_bodies_monikers, @@ -634,6 +636,8 @@ def find_and_fix_split_edges( response.found, response.repaired, ) + parent_design.update_from_tracker(response.result.complete_command_response) + return message @protect_grpc @@ -675,7 +679,7 @@ def find_and_fix_simplify( ) parent_design = get_design_from_body(bodies[0]) - parent_design._update_design_inplace() + #parent_design._update_design_inplace() message = RepairToolMessage( response.success, response.created_bodies_monikers, @@ -683,6 +687,7 @@ def find_and_fix_simplify( response.found, response.repaired, ) + parent_design.update_from_tracker(response.result.complete_command_response) return message @protect_grpc From 8b94ad857e038e860aa9c4dd5f9b48c83903630d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 17:09:56 +0000 Subject: [PATCH 13/25] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/tools/problem_areas.py | 6 +++--- src/ansys/geometry/core/tools/repair_tools.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index 412272c395..259cfe3ee2 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -351,7 +351,7 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixShortEdges( FixShortEdgesRequest(short_edge_problem_area_id=self._grpc_id) ) - #parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, @@ -407,7 +407,7 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixSmallFaces( FixSmallFacesRequest(small_face_problem_area_id=self._grpc_id) ) - #parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, @@ -464,7 +464,7 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixSplitEdges( FixSplitEdgesRequest(split_edge_problem_area_id=self._grpc_id) ) - #parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, diff --git a/src/ansys/geometry/core/tools/repair_tools.py b/src/ansys/geometry/core/tools/repair_tools.py index 0a6451dfe6..9adc73ec8b 100644 --- a/src/ansys/geometry/core/tools/repair_tools.py +++ b/src/ansys/geometry/core/tools/repair_tools.py @@ -509,7 +509,7 @@ def find_and_fix_short_edges( ) parent_design = get_design_from_body(bodies[0]) - #parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.success, response.created_bodies_monikers, @@ -561,7 +561,7 @@ def find_and_fix_extra_edges( ) parent_design = get_design_from_body(bodies[0]) - #parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.success, response.created_bodies_monikers, @@ -679,7 +679,7 @@ def find_and_fix_simplify( ) parent_design = get_design_from_body(bodies[0]) - #parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.success, response.created_bodies_monikers, From b52d54f4d89028d1f4f488ff7274ddbbcc4bdcb4 Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Fri, 18 Apr 2025 13:54:33 -0500 Subject: [PATCH 14/25] Update problem_areas.py --- src/ansys/geometry/core/tools/problem_areas.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index 259cfe3ee2..dccbafda93 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -188,13 +188,13 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixMissingFaces( FixMissingFacesRequest(missing_face_problem_area_id=self._grpc_id) ) - # parent_design._update_design_inplace() + parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, response.result.modified_bodies_monikers, ) - parent_design.update_from_tracker(response.result.complete_command_response) + #parent_design.update_from_tracker(response.result.complete_command_response) return message @@ -520,12 +520,13 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixStitchFaces( FixStitchFacesRequest(stitch_face_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + #parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, response.result.modified_bodies_monikers, ) + parent_design.update_from_tracker(response.result.complete_command_response) return message @@ -569,12 +570,13 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixAdjustSimplify( FixAdjustSimplifyRequest(adjust_simplify_problem_area_id=self._grpc_id) ) - parent_design._update_design_inplace() + #parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, response.result.modified_bodies_monikers, ) + parent_design.update_from_tracker(response.result.complete_command_response) return message From cc59f6a1eccc36633406c992f147db50f3f08c42 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Apr 2025 18:54:45 +0000 Subject: [PATCH 15/25] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/tools/problem_areas.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index dccbafda93..e5eecfe022 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -194,7 +194,7 @@ def fix(self) -> RepairToolMessage: response.result.created_bodies_monikers, response.result.modified_bodies_monikers, ) - #parent_design.update_from_tracker(response.result.complete_command_response) + # parent_design.update_from_tracker(response.result.complete_command_response) return message @@ -520,7 +520,7 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixStitchFaces( FixStitchFacesRequest(stitch_face_problem_area_id=self._grpc_id) ) - #parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, @@ -570,7 +570,7 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixAdjustSimplify( FixAdjustSimplifyRequest(adjust_simplify_problem_area_id=self._grpc_id) ) - #parent_design._update_design_inplace() + # parent_design._update_design_inplace() message = RepairToolMessage( response.result.success, response.result.created_bodies_monikers, From be524f699d9bfdc5a43723830c7f2feb48ccd4b7 Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Mon, 21 Apr 2025 12:53:47 -0500 Subject: [PATCH 16/25] fixing function arguments ordre --- .../geometry/core/tools/prepare_tools.py | 10 ++-- .../geometry/core/tools/problem_areas.py | 56 +++++++++---------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/ansys/geometry/core/tools/prepare_tools.py b/src/ansys/geometry/core/tools/prepare_tools.py index 241d47ad37..ad613442bc 100644 --- a/src/ansys/geometry/core/tools/prepare_tools.py +++ b/src/ansys/geometry/core/tools/prepare_tools.py @@ -266,11 +266,11 @@ def enhanced_share_topology( ) message = RepairToolMessage( - response.get("success"), - response.get("created_bodies_monikers"), - response.get("modified_bodies_monikers"), - response.get("found"), - response.get("repaired"), + success=response.get("success"), + created_bodies=response.get("created_bodies_monikers"), + modified_bodies=response.get("modified_bodies_monikers"), + found=response.get("found"), + repaired=response.get("repaired"), ) return message diff --git a/src/ansys/geometry/core/tools/problem_areas.py b/src/ansys/geometry/core/tools/problem_areas.py index e5eecfe022..fdbdf29c13 100644 --- a/src/ansys/geometry/core/tools/problem_areas.py +++ b/src/ansys/geometry/core/tools/problem_areas.py @@ -133,9 +133,9 @@ def fix(self) -> RepairToolMessage: ) # parent_design._update_design_inplace() message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) parent_design.update_from_tracker(response.result.complete_command_response) @@ -190,9 +190,9 @@ def fix(self) -> RepairToolMessage: ) parent_design._update_design_inplace() message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) # parent_design.update_from_tracker(response.result.complete_command_response) return message @@ -243,11 +243,11 @@ def fix(self) -> RepairToolMessage: response = self._repair_stub.FixInexactEdges( FixInexactEdgesRequest(inexact_edge_problem_area_id=self._grpc_id) ) - # parent_design._update_design_inplace() + parent_design._update_design_inplace() message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) return message @@ -297,9 +297,9 @@ def fix(self) -> RepairToolMessage: request = FixExtraEdgesRequest(extra_edge_problem_area_id=self._grpc_id) response = self._repair_stub.FixExtraEdges(request) message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) parent_design.update_from_tracker(response.result.complete_command_response) @@ -353,9 +353,9 @@ def fix(self) -> RepairToolMessage: ) # parent_design._update_design_inplace() message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) parent_design.update_from_tracker(response.result.complete_command_response) @@ -409,9 +409,9 @@ def fix(self) -> RepairToolMessage: ) # parent_design._update_design_inplace() message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) parent_design.update_from_tracker(response.result.complete_command_response) @@ -466,9 +466,9 @@ def fix(self) -> RepairToolMessage: ) # parent_design._update_design_inplace() message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) parent_design.update_from_tracker(response.result.complete_command_response) @@ -522,9 +522,9 @@ def fix(self) -> RepairToolMessage: ) # parent_design._update_design_inplace() message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) parent_design.update_from_tracker(response.result.complete_command_response) return message @@ -572,9 +572,9 @@ def fix(self) -> RepairToolMessage: ) # parent_design._update_design_inplace() message = RepairToolMessage( - response.result.success, - response.result.created_bodies_monikers, - response.result.modified_bodies_monikers, + success=response.result.success, + created_bodies=response.result.created_bodies_monikers, + modified_bodies=response.result.modified_bodies_monikers, ) parent_design.update_from_tracker(response.result.complete_command_response) return message From 75f2be0dd7b98778854730f446cf859ca6ef3f8a Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Mon, 21 Apr 2025 16:26:53 -0500 Subject: [PATCH 17/25] Update repair_tools.py --- src/ansys/geometry/core/tools/repair_tools.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ansys/geometry/core/tools/repair_tools.py b/src/ansys/geometry/core/tools/repair_tools.py index 22a419a4a8..cb76e3d58e 100644 --- a/src/ansys/geometry/core/tools/repair_tools.py +++ b/src/ansys/geometry/core/tools/repair_tools.py @@ -511,13 +511,13 @@ def find_and_fix_short_edges( parent_design = get_design_from_body(bodies[0]) # parent_design._update_design_inplace() message = RepairToolMessage( - response.success, - response.created_bodies_monikers, - response.modified_bodies_monikers, - response.found, - response.repaired, + success = response.success, + created_bodies = response.created_bodies_monikers, + modified_bodies = response.modified_bodies_monikers, + found = response.found, + repaired = response.repaired, ) - parent_design.update_from_tracker(response.result.complete_command_response) + parent_design.update_from_tracker(response.complete_command_response) return message @protect_grpc @@ -630,11 +630,11 @@ def find_and_fix_split_edges( parent_design = get_design_from_body(bodies[0]) # parent_design._update_design_inplace() message = RepairToolMessage( - response.success, - response.created_bodies_monikers, - response.modified_bodies_monikers, - response.found, - response.repaired, + success = response.success, + created_bodies = response.created_bodies_monikers, + modified_bodies = response.modified_bodies_monikers, + found = response.found, + repaired = response.repaired, ) parent_design.update_from_tracker(response.result.complete_command_response) From 4495fdf2064dfc98f5607057c6d976e94e2b9aac Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Mon, 21 Apr 2025 16:29:12 -0500 Subject: [PATCH 18/25] fixing function arguments order more --- src/ansys/geometry/core/tools/repair_tools.py | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/ansys/geometry/core/tools/repair_tools.py b/src/ansys/geometry/core/tools/repair_tools.py index cb76e3d58e..f1102f3888 100644 --- a/src/ansys/geometry/core/tools/repair_tools.py +++ b/src/ansys/geometry/core/tools/repair_tools.py @@ -511,11 +511,11 @@ def find_and_fix_short_edges( parent_design = get_design_from_body(bodies[0]) # parent_design._update_design_inplace() message = RepairToolMessage( - success = response.success, - created_bodies = response.created_bodies_monikers, - modified_bodies = response.modified_bodies_monikers, - found = response.found, - repaired = response.repaired, + success=response.success, + created_bodies=response.created_bodies_monikers, + modified_bodies=response.modified_bodies_monikers, + found=response.found, + repaired=response.repaired, ) parent_design.update_from_tracker(response.complete_command_response) return message @@ -563,11 +563,11 @@ def find_and_fix_extra_edges( parent_design = get_design_from_body(bodies[0]) # parent_design._update_design_inplace() message = RepairToolMessage( - response.success, - response.created_bodies_monikers, - response.modified_bodies_monikers, - response.found, - response.repaired, + success=response.success, + created_bodies=response.created_bodies_monikers, + modified_bodies=response.modified_bodies_monikers, + found=response.found, + repaired=response.repaired, ) parent_design.update_from_tracker(response.result.complete_command_response) return message @@ -630,11 +630,11 @@ def find_and_fix_split_edges( parent_design = get_design_from_body(bodies[0]) # parent_design._update_design_inplace() message = RepairToolMessage( - success = response.success, - created_bodies = response.created_bodies_monikers, - modified_bodies = response.modified_bodies_monikers, - found = response.found, - repaired = response.repaired, + success=response.success, + created_bodies=response.created_bodies_monikers, + modified_bodies=response.modified_bodies_monikers, + found=response.found, + repaired=response.repaired, ) parent_design.update_from_tracker(response.result.complete_command_response) @@ -681,11 +681,11 @@ def find_and_fix_simplify( parent_design = get_design_from_body(bodies[0]) # parent_design._update_design_inplace() message = RepairToolMessage( - response.success, - response.created_bodies_monikers, - response.modified_bodies_monikers, - response.found, - response.repaired, + success=response.success, + created_bodies=response.created_bodies_monikers, + modified_bodies=response.modified_bodies_monikers, + found=response.found, + repaired=response.repaired, ) parent_design.update_from_tracker(response.result.complete_command_response) return message From 32a042c8c615a40807e2073c9720d73c0318af1a Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Mon, 21 Apr 2025 16:45:35 -0500 Subject: [PATCH 19/25] remove result --- src/ansys/geometry/core/tools/repair_tools.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansys/geometry/core/tools/repair_tools.py b/src/ansys/geometry/core/tools/repair_tools.py index f1102f3888..d5336591ab 100644 --- a/src/ansys/geometry/core/tools/repair_tools.py +++ b/src/ansys/geometry/core/tools/repair_tools.py @@ -569,7 +569,7 @@ def find_and_fix_extra_edges( found=response.found, repaired=response.repaired, ) - parent_design.update_from_tracker(response.result.complete_command_response) + parent_design.update_from_tracker(response.complete_command_response) return message @protect_grpc @@ -636,7 +636,7 @@ def find_and_fix_split_edges( found=response.found, repaired=response.repaired, ) - parent_design.update_from_tracker(response.result.complete_command_response) + parent_design.update_from_tracker(response.complete_command_response) return message @@ -687,7 +687,7 @@ def find_and_fix_simplify( found=response.found, repaired=response.repaired, ) - parent_design.update_from_tracker(response.result.complete_command_response) + parent_design.update_from_tracker(response.complete_command_response) return message @protect_grpc From 065921a5484ef9a6e37225f1f4a378710e592904 Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Mon, 21 Apr 2025 17:23:31 -0500 Subject: [PATCH 20/25] test update --- tests/integration/test_repair_tools.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/test_repair_tools.py b/tests/integration/test_repair_tools.py index 4317691149..0798cdea03 100644 --- a/tests/integration/test_repair_tools.py +++ b/tests/integration/test_repair_tools.py @@ -179,6 +179,7 @@ def test_fix_duplicate_face(modeler: Modeler): design = modeler.open_file(FILES_DIR / "DuplicateFacesDesignBefore.scdocx") problem_areas = modeler.repair_tools.find_duplicate_faces(design.bodies) assert problem_areas[0].fix().success is True + design.close() def test_find_small_faces(modeler: Modeler): @@ -294,6 +295,7 @@ def test_find_and_fix_duplicate_faces(modeler: Modeler): for area in areas: area.fix() assert len(design.bodies) == 1 + design.close() def test_find_and_fix_extra_edges_problem_areas(modeler: Modeler): From 2d3ec4a730d8b621a252a8c3dfa433967c81b32c Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Wed, 7 May 2025 08:04:00 -0500 Subject: [PATCH 21/25] closing design after tests --- tests/integration/test_repair_tools.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration/test_repair_tools.py b/tests/integration/test_repair_tools.py index 0798cdea03..63ca9adbc9 100644 --- a/tests/integration/test_repair_tools.py +++ b/tests/integration/test_repair_tools.py @@ -154,6 +154,7 @@ def test_find_duplicate_faces(modeler: Modeler): design = modeler.open_file(FILES_DIR / "DuplicateFacesDesignBefore.scdocx") problem_areas = modeler.repair_tools.find_duplicate_faces(design.bodies) assert len(problem_areas) == 1 + design.close() def test_duplicate_face_id(modeler: Modeler): @@ -161,6 +162,7 @@ def test_duplicate_face_id(modeler: Modeler): design = modeler.open_file(FILES_DIR / "DuplicateFacesDesignBefore.scdocx") problem_areas = modeler.repair_tools.find_duplicate_faces(design.bodies) assert problem_areas[0].id != "0" + design.close() def test_duplicate_face_faces(modeler: Modeler): @@ -170,6 +172,8 @@ def test_duplicate_face_faces(modeler: Modeler): design = modeler.open_file(FILES_DIR / "DuplicateFacesDesignBefore.scdocx") problem_areas = modeler.repair_tools.find_duplicate_faces(design.bodies) assert len(problem_areas[0].faces) > 0 + design.close() + def test_fix_duplicate_face(modeler: Modeler): From 4b0b124ebc7f63cae9503cf089111b0dce8dfdb4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 13:06:08 +0000 Subject: [PATCH 22/25] chore: auto fixes from pre-commit hooks --- tests/integration/test_repair_tools.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/test_repair_tools.py b/tests/integration/test_repair_tools.py index 63ca9adbc9..4ce84e5730 100644 --- a/tests/integration/test_repair_tools.py +++ b/tests/integration/test_repair_tools.py @@ -175,7 +175,6 @@ def test_duplicate_face_faces(modeler: Modeler): design.close() - def test_fix_duplicate_face(modeler: Modeler): """Test to read geometry and find and fix it's duplicate face problem areas. From 9974c3e0a08ce5bc7772d55229d264ea84020aaa Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Wed, 7 May 2025 08:52:33 -0500 Subject: [PATCH 23/25] Update design.py --- src/ansys/geometry/core/designer/design.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/geometry/core/designer/design.py b/src/ansys/geometry/core/designer/design.py index 2113ffe6b3..256b9ea9be 100644 --- a/src/ansys/geometry/core/designer/design.py +++ b/src/ansys/geometry/core/designer/design.py @@ -1287,7 +1287,7 @@ def update_body(existing_body, body_info): # Function to find and add bodies within components recursively def find_and_add_body(body_info, component): - for component in components: + for component in component: if component.id == body_info["parent_id"]: new_body = MasterBody( body_info["id"], From 35ab917de6ab7693a1bca52a8cacd6a85f869e53 Mon Sep 17 00:00:00 2001 From: Umut Soysal Date: Tue, 13 May 2025 17:10:51 -0500 Subject: [PATCH 24/25] adding missing mapping for new response fields. --- src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py index 5b7000e990..ecc2053278 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -258,6 +258,7 @@ def find_and_fix_simplify(self, **kwargs) -> dict: # noqa: D102 "repaired": response.repaired, "created_bodies_monikers": [], "modified_bodies_monikers": [], + "complete_command_response": response.complete_command_response, } @protect_grpc @@ -333,6 +334,7 @@ def find_and_fix_short_edges(self, **kwargs): # noqa: D102 "repaired": response.repaired, "created_bodies_monikers": [], "modified_bodies_monikers": [], + "complete_command_response": response.complete_command_response, } @protect_grpc @@ -353,6 +355,7 @@ def find_and_fix_extra_edges(self, **kwargs) -> dict: # noqa: D102 "repaired": response.repaired, "created_bodies_monikers": response.created_bodies_monikers, "modified_bodies_monikers": response.modified_bodies_monikers, + "complete_command_response": response.complete_command_response, } @protect_grpc @@ -378,6 +381,8 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102 "repaired": response.repaired, "created_bodies_monikers": [], "modified_bodies_monikers": [], + "complete_command_response": response.complete_command_response, + } @staticmethod From 378240765c9a116e31c63a8e930db4b06b172790 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 13 May 2025 22:11:37 +0000 Subject: [PATCH 25/25] chore: auto fixes from pre-commit hooks --- src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py index ecc2053278..e75e2cf37f 100644 --- a/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py +++ b/src/ansys/geometry/core/_grpc/_services/v0/repair_tools.py @@ -382,7 +382,6 @@ def find_and_fix_split_edges(self, **kwargs) -> dict: # noqa: D102 "created_bodies_monikers": [], "modified_bodies_monikers": [], "complete_command_response": response.complete_command_response, - } @staticmethod