Skip to content

Commit 075361e

Browse files
authored
Merge branch 'compas-dev:main' into main
2 parents da1bf92 + ea17a24 commit 075361e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2982
-268
lines changed

.github/workflows/publish_yak.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: publish_yak
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
environment:
7+
description: "Choose deployment environment"
8+
required: true
9+
type: choice
10+
options:
11+
- test
12+
- prod
13+
14+
jobs:
15+
16+
publish_test_yak:
17+
runs-on: windows-latest
18+
19+
steps:
20+
21+
- name: Set test flag based on input
22+
shell: pwsh
23+
run: |
24+
if ("${{ github.event.inputs.environment }}" -eq "test") {
25+
echo "TEST_FLAG=--test-server" | Out-File -FilePath $env:GITHUB_ENV -Append
26+
}
27+
else {
28+
echo "TEST_FLAG=" | Out-File -FilePath $env:GITHUB_ENV -Append
29+
}
30+
31+
- name: Checkout repo
32+
uses: actions/checkout@v4
33+
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install .[dev]
38+
39+
- name: Create CPython Grasshopper user objects
40+
run: |
41+
invoke build-cpython-ghuser-components
42+
43+
- name: Create IronPython Grasshopper user objects
44+
run: |
45+
choco install ironpython --version=2.7.8.1
46+
invoke clean
47+
invoke build-ghuser-components
48+
49+
- name: Create Rhino7 Yak package
50+
shell: pwsh
51+
run: |
52+
invoke yakerize -m $Env:YAK_TEMPLATE\manifest.yml -l $Env:YAK_TEMPLATE\icon.png -g $Env:USER_OBJECTS -t rh7
53+
env:
54+
USER_OBJECTS: src\compas_ghpython\components\ghuser
55+
YAK_TEMPLATE: src\compas_ghpython\yak_template
56+
57+
- name: Publish to Yak server (Rhino 7)
58+
shell: pwsh
59+
run: |
60+
$test_flag = if ($Env:TEST_FLAG) { $Env:TEST_FLAG } else { "" }
61+
$file = Get-ChildItem -Path dist\yak_package\*rh7*.yak -File | Select-Object -ExpandProperty Name
62+
$command = "invoke publish-yak -y dist\yak_package\$file $test_flag".Trim()
63+
Invoke-Expression $command
64+
env:
65+
YAK_TOKEN: ${{ secrets.YAK_DF_TOKEN }}
66+
67+
- name: Create Rhino8 Yak package
68+
shell: pwsh
69+
run: |
70+
invoke yakerize -m $Env:YAK_TEMPLATE\manifest.yml -l $Env:YAK_TEMPLATE\icon.png -g $Env:USER_OBJECTS -t rh8
71+
env:
72+
USER_OBJECTS: src\compas_ghpython\components_cpython\ghuser
73+
YAK_TEMPLATE: src\compas_ghpython\yak_template
74+
75+
- name: Publish to Yak server (Rhino 8)
76+
shell: pwsh
77+
run: |
78+
$test_flag = if ($Env:TEST_FLAG) { $Env:TEST_FLAG } else { "" }
79+
$file = Get-ChildItem -Path dist\yak_package\*rh8*.yak -File | Select-Object -ExpandProperty Name
80+
$command = "invoke publish-yak -y dist\yak_package\$file $test_flag".Trim()
81+
Invoke-Expression $command
82+
env:
83+
YAK_TOKEN: ${{ secrets.YAK_DF_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ data/ctralie
139139

140140
# Grasshopper generated objects
141141
src/compas_ghpython/components/**/*.ghuser
142+
src/compas_ghpython/components_cpython/**/*.ghuser
142143

143144
dev
144145

@@ -149,4 +150,4 @@ docs/reference/__old/
149150

150151
scripts/
151152

152-
.ruff_cache
153+
.ruff_cache

CHANGELOG.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,72 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
* Added `Group` to `compas.scene`.
13+
* Added `compas.geometry.Brep.cap_planar_holes`.
14+
* Added `compas_rhino.geometry.RhinoBrep.cap_planar_holes`.
15+
16+
### Changed
17+
18+
* Changed `SceneObject.frame` to read-only result of `Frame.from_transformation(SceneObject.worldtransformation)`, representing the local coordinate system of the scene object in world coordinates.
19+
* Changed `SceneObject.worldtransformation` to the multiplication of all transformations from the scene object to the root of the scene tree, there will no longer be an additional transformation in relation to the object's frame.
20+
* Fixed call to `astar_shortest_path` in `Graph.shortest_path`.
21+
22+
### Removed
23+
24+
25+
## [2.10.0] 2025-03-03
26+
27+
### Added
28+
29+
* Added `flip` to `compas.geometry.Brep`.
30+
* Added implementation of `flip` to `compas_rhino.geometry.RhinoBrep`.
31+
32+
### Changed
33+
34+
* Fixed unexpected behavior for method `Plane.is_parallel` for opposite normals.
35+
36+
### Removed
37+
38+
39+
## [2.9.1] 2025-02-06
40+
41+
### Added
42+
43+
* Added method `frame_at` to `compas.geometry.BrepFace`.
44+
* Added method `frame_at` to `compas_rhino.geometry.RhinoBrepFace`.
45+
* Added property `is_reversed` to `compas.geometry.BrepFace`.
46+
* Added property `is_reversed` to `compas_rhino.geometry.RhinoBrepFace`.
47+
48+
### Changed
49+
50+
* Fixed publish to YAK via CI workflow.
51+
* Added selector for `test` and `prod` to CI workflow.
52+
* Fixed `AttributeError` in `compas.data.DataEncoder.default` due to `np.float_` no longer being available in `numpy>=2`.
53+
54+
### Removed
55+
56+
57+
## [2.9.0] 2025-02-04
58+
59+
### Added
60+
61+
* Added `DevTools` with support for automatic reloading of local python modules.
62+
* Added implementation for `compas_rhino.geometry.RhinoBrep.from_step`.
63+
* Added CPython implementations of GH components for Rhino8.
64+
* Added import to new `yakerize` task from `compas_invocations2`.
65+
* Added import to new `publish_yak` task from `compas_invocations2`.
66+
1267
### Changed
1368

69+
* Moved `unload_modules` to be a static method of `DevTools`. The `unload_modules` function is an alias to this.
70+
* Fixed unexpected behavior in `compas.geometry.bbox_numpy.minimum_area_rectangle_xy`.
71+
* Changed `requirements.txt` to allow `numpy>=2`.
72+
* Fixed bug in `compas.geometry.Polygon.points` setter by removing duplicate points if they exist.
73+
* Fixed bug in `compas.geometry.Polygon.plane` by aligning the normal of the bestfit plane with the approximate normal of the polygon faces.
74+
* Changed the order of face vertices in `compas.geometry.Surface.to_vertices_and_faces` to a counter clockwise cycling direction and outward facing normals for curved surfaces.
75+
* Deprecated the `-v8.0` flag in `compas_rhino.install`. Install to Rhino8 by following: https://compas.dev/compas/latest/userguide/cad.rhino8.html.
76+
* Fixed `Info` Grasshopper component for cpython to handle non-bootstrapped environments.
77+
1478
### Removed
1579

1680

docs/userguide/cad.grasshopper.rst

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ Reloading changed libraries
4949
If you change a Python library during a running Rhino application, which is
5050
imported in a GhPython component (e.g. via ``import compas_fab``),
5151
it is necessary to reload the library so that the GhPython interpreter
52-
recognizes the changes. To avoid restarting Rhino, you can use the function
53-
``unload_modules``. The following example reloads the library ``compas_fab``.
52+
recognizes the changes. To avoid restarting Rhino, you can use the method
53+
``unload_modules`` of ``DevTools``. The following example reloads the library ``compas_fab``.
5454

5555
.. code-block:: python
5656
57-
from compas_ghpython import unload_modules
57+
from compas_rhino import DevTools
5858
59-
unload_modules('compas_fab')
59+
DevTools.unload_modules('compas_fab')
6060
6161
.. note::
6262

@@ -65,3 +65,50 @@ recognizes the changes. To avoid restarting Rhino, you can use the function
6565
in COMPAS not being able to find a `SceneObject` as well as other issues
6666
related to a mid-workflow re-definition of Python types.
6767

68+
69+
Python Scripting Outside Rhino/Grasshopper with Auto-Reloading
70+
==============================================================
71+
72+
Developing Python scripts outside of Rhino/Grasshopper allows you to take advantage of
73+
modern code editors. However, this workflow requires two key steps: ensuring the Python
74+
interpreter can access your script's location and enabling automatic reloading of the
75+
script when changes are made in your external editor.
76+
If the scripts or modules you are working on are located in the same folder as the Rhino/Grasshopper file you are editing, the ``DevTools`` class can be used to make them importable and reload them automatically when modified.
77+
78+
This approach provides a seamless workflow for developing Python scripts in modern IDEs,
79+
such as Visual Studio Code, while running and testing the code inside Rhino/Grasshopper
80+
with minimal interruptions.
81+
82+
Enabling Auto-Reloading
83+
-----------------------
84+
85+
To enable this feature, use the ``enable_reloader`` method of the ``DevTools`` class.
86+
This makes all Python scripts in the same folder as the Grasshopper file importable
87+
and ensures they automatically reload when changes are applied.
88+
89+
.. code-block:: python
90+
91+
from compas_rhino import DevTools
92+
DevTools.enable_reloader()
93+
94+
.. note::
95+
96+
Call this method early in your script to start the monitoring service immediately.
97+
98+
Importing Local Modules
99+
-----------------------
100+
101+
Once auto-reloading is enabled, any script component that needs to use local modules can include the following at the top of the script:
102+
103+
.. code-block:: python
104+
105+
from compas_rhino import DevTools
106+
DevTools.ensure_path()
107+
108+
This ensures local modules are accessible. For instance, if a file named ``my_module.py`` is in
109+
the same folder as your Grasshopper file, you can import it in a script component like this:
110+
111+
.. code-block:: python
112+
113+
import my_module
114+

docs/userguide/cad.rhino8.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ you can now simply add the packages as requirements in a comment.
3636
3737
More information is available here: <https://developer.rhino3d.com/guides/scripting/scripting-command>
3838

39+
.. note::
40+
41+
This also works in the Python 3 Script node in Grasshopper.
3942

4043
Alternative Method
4144
==================

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ doctest_optionflags = [
8484
# ============================================================================
8585

8686
[tool.bumpversion]
87-
current_version = "2.8.1"
87+
current_version = "2.10.0"
8888
message = "Bump version to {new_version}"
8989
commit = true
9090
tag = true

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ ruff
88
sphinx_compas2_theme
99
twine
1010
wheel
11+
pythonnet

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# flake8: noqa
22
jsonschema
33
networkx >= 3.0
4-
numpy >= 1.15.4, < 2
4+
numpy >= 1.15.4
55
scipy >= 1.1
66
watchdog; sys_platform != 'emscripten'

src/compas/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
__copyright__ = "Copyright 2014-2022 - ETH Zurich, Copyright 2023 - COMPAS Association"
2121
__license__ = "MIT License"
2222
__email__ = "[email protected]"
23-
__version__ = "2.8.1"
23+
__version__ = "2.10.0"
2424

2525

2626
HERE = compas._os.realpath(os.path.dirname(__file__))

src/compas/data/encoders.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
try:
3131
import numpy as np
3232

33+
try:
34+
np_float = np.float_
35+
except AttributeError:
36+
np_float = np.float64
37+
3338
numpy_support = True
3439
except (ImportError, SyntaxError):
3540
numpy_support = False
@@ -143,7 +148,7 @@ def default(self, o):
143148
), # type: ignore
144149
):
145150
return int(o)
146-
if isinstance(o, (np.float_, np.float16, np.float32, np.float64)): # type: ignore
151+
if isinstance(o, (np_float, np.float16, np.float32, np.float64)): # type: ignore
147152
return float(o)
148153
if isinstance(o, np.bool_):
149154
return bool(o)

0 commit comments

Comments
 (0)