Skip to content

Commit 2cbbf36

Browse files
authored
Merge pull request #294 from compas-dev/ghuser_components
Migrate to GHuser components
2 parents 74c2b91 + bcf0686 commit 2cbbf36

Some content is hidden

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

60 files changed

+978
-1216
lines changed

.bumpversion.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ replace = __version__ = '{new_version}'
2424
[bumpversion:file:CHANGELOG.rst]
2525
search = Unreleased
2626
replace = {new_version}
27+
28+
[bumpversion:glob:src/compas_fab/ghpython/components/**/code.py]
29+
search = v{current_version}
30+
replace = v{new_version}

.github/workflows/build.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ jobs:
5959
- uses: actions/checkout@v2
6060
- name: Install dependencies
6161
run: |
62+
curl -o compas.tar.gz -LJO https://pypi.debian.net/compas/latest
63+
curl -o roslibpy.tar.gz -LJO https://pypi.debian.net/roslibpy/latest
64+
curl -o ironpython-pytest.tar.gz -LJO https://pypi.debian.net/ironpython-pytest/latest
6265
choco install ironpython --version=2.7.8.1
6366
ipy -X:Frames -m ensurepip
64-
ipy -X:Frames -m pip install --no-deps compas roslibpy
65-
ipy -X:Frames -m pip install ironpython-pytest
67+
ipy -X:Frames -m pip install --no-deps compas.tar.gz
68+
ipy -X:Frames -m pip install --no-deps roslibpy.tar.gz
69+
ipy -X:Frames -m pip install --no-deps ironpython-pytest.tar.gz
6670
- name: Run tests
6771
env:
6872
IRONPYTHONPATH: ./src

.github/workflows/deploy-n-publish.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
jobs:
1414
build:
1515
name: build and deploy docs
16-
runs-on: ubuntu-latest
16+
runs-on: windows-latest
1717
steps:
1818
- uses: actions/checkout@v2
1919
- name: Set up Python 3.8
@@ -28,6 +28,14 @@ jobs:
2828
- name: 💎 Install
2929
run: |
3030
python -m pip install --no-cache-dir -r requirements-dev.txt
31+
- uses: NuGet/[email protected]
32+
- name: Install dependencies
33+
run: |
34+
choco install ironpython --version=2.7.8.1
35+
- uses: compas-dev/compas-actions.ghpython_components@v1
36+
with:
37+
source: src/compas_fab/ghpython/components
38+
target: src/compas_fab/ghpython/components
3139
- name: 📃 Generate docs
3240
if: success()
3341
run: |
@@ -53,6 +61,7 @@ jobs:
5361
5462
echo "Docs will be deployed to https://gramaziokohler.github.io/compas_fab/$BRANCH_OR_TAG"
5563
mkdir -p deploy/compas_fab/$BRANCH_OR_TAG && mv -T dist/docs deploy/compas_fab/$BRANCH_OR_TAG/
64+
shell: bash
5665
- name: 🚢 Deploy docs
5766
if: success()
5867
uses: crazy-max/ghaction-github-pages@v2

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,6 @@ docs/generated/
116116

117117
temp/**
118118
!temp/.gitkeep
119+
120+
# Grasshopper generated objects
121+
src/compas_fab/ghpython/components/*.ghuser

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Unreleased
1212

1313
**Added**
1414

15+
* Grasshopper components now also for Mac
1516
* Added support for MoveIt on ROS Noetic
1617
* Added support for Python 3.9
1718

CONTRIBUTING.rst

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,27 +103,40 @@ The best way to send feedback is to file an issue on
103103
* Explain in detail how it would work.
104104
* Keep the scope as narrow as possible, to make it easier to implement.
105105

106-
A Note on Architecture for Backend Clients
107-
------------------------------------------
106+
Grasshopper components
107+
----------------------
108108

109-
To maintain consistency from one backend client to another and to promote modularity,
110-
we make use of several interfaces. Please reference :ref:`Note on Architecture <architecture>`
111-
for more details on how to add or amend a backend client.
109+
Grasshopper user objects need to be built using `COMPAS Github Action componentizer <https://github.com/compas-dev/compas-actions.ghpython_components>`_.
112110

113-
A Note on GhPython Components
114-
-----------------------------
111+
1. Apply your changes to the component source code (``src/compas_fab/ghpython/components``).
112+
2. Rebuild them:
113+
114+
.. code-block:: bash
115+
116+
invoke build-ghuser-components <path_to_ghio.dll>
117+
118+
3. Install them on Rhino/Grasshopper as usual:
115119

116-
The Grasshopper components are made with the Python GHPY compiler based on the
117-
`Tutorial by Giulio Piacentino <https://discourse.mcneel.com/t/tutorial-creating-a-grasshopper-component-with-the-python-ghpy-compiler/38552>`_.
118-
If you make changes to the files in ``src/compas_fab/ghpython/components``, the components library has to be manually recompiled.
119-
This is done by executing ``src\compas_fab\ghpython\components\compile.py`` with Rhino's PythonScript Editor.
120-
Make sure to open Grasshopper before compiling, so that the assemblies are loaded.
120+
.. code-block:: bash
121121
122-
Once compilation is completed, the components (``.ghpy`` file) are installed using the same command
123-
that installs COMPAS on Rhino::
122+
python -m compas_rhino.install
124123
125-
python -m compas_rhino.install
124+
The install step does not copy them, but creates a symlink to the location in which they are built,
125+
so after the first installation, it is usually not required to reinstall them, only rebuild them (unless a new component is added).
126126

127+
.. note::
128+
129+
This step requires IronPython 2.7 to be available on the system, ie. `ipy` should be callable from the command line.
130+
The path to the GH_IO.dll is platform-specific, on Mac it is under the ``GrasshopperPlugin.rhp`` of the Rhino app
131+
and on Windows is in the ``Grasshopper`` folder within the Rhino folder in ``ProgramFiles``.
132+
133+
134+
A Note on Architecture for Backend Clients
135+
------------------------------------------
136+
137+
To maintain consistency from one backend client to another and to promote modularity,
138+
we make use of several interfaces. Please reference :ref:`Note on Architecture <architecture>`
139+
for more details on how to add or amend a backend client.
127140

128141
Design documents
129142
----------------
-201 KB
Binary file not shown.
-201 KB
Binary file not shown.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
Add an attached collision mesh to the robot.
3+
4+
COMPAS FAB v0.17.0
5+
"""
6+
from ghpythonlib.componentbase import executingcomponent as component
7+
8+
from compas_rhino.geometry import RhinoMesh
9+
from compas_fab.robots import AttachedCollisionMesh
10+
from compas_fab.robots import CollisionMesh
11+
12+
13+
class AttachedCollisionMeshComponent(component):
14+
def RunScript(self, scene, mesh, identifier, link_name, touch_links, add, remove):
15+
attached_collision_mesh = None
16+
if scene and mesh and identifier and link_name:
17+
compas_mesh = RhinoMesh.from_geometry(mesh).to_compas()
18+
collision_mesh = CollisionMesh(compas_mesh, identifier)
19+
attached_collision_mesh = AttachedCollisionMesh(collision_mesh, link_name, touch_links)
20+
if add:
21+
scene.add_attached_collision_mesh(attached_collision_mesh)
22+
if remove:
23+
scene.remove_attached_collision_mesh(identifier)
24+
scene.remove_collision_mesh(identifier)
25+
return attached_collision_mesh

0 commit comments

Comments
 (0)