Skip to content

Commit

Permalink
Merge pull request #1019 from compas-dev/new-ghcomponent-draw
Browse files Browse the repository at this point in the history
new: add GH component to draw any COMPAS object
  • Loading branch information
gonzalocasas authored Mar 28, 2022
2 parents eae6565 + 36c72b0 commit 47d938e
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 55 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Added optional `triangulated` flag to `Mesh.to_vertices_and_faces`.
* Added geometry information of active meshes to the serialization/deserialization of robot model's `MeshDescriptor`.
* Added Grasshopper component to draw any COMPAS object.
* Added new icons to Grasshopper components and default to icon style.

### Changed

Expand Down
20 changes: 0 additions & 20 deletions src/compas_ghpython/components/Compas_Frame/code.py

This file was deleted.

Binary file removed src/compas_ghpython/components/Compas_Frame/icon.png
Binary file not shown.
24 changes: 0 additions & 24 deletions src/compas_ghpython/components/Compas_Frame/metadata.json

This file was deleted.

3 changes: 3 additions & 0 deletions src/compas_ghpython/components/Compas_FromJson/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

class CompasInfo(component):
def RunScript(self, json):
if not json:
return None

try:
return compas.json_load(json)
except: # noqa: E722
Expand Down
Binary file modified src/compas_ghpython/components/Compas_FromJson/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

"ghpython": {
"isAdvancedMode": true,
"iconDisplay": 2,
"inputParameters": [
{
"name": "json",
Expand Down
Binary file modified src/compas_ghpython/components/Compas_Info/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/compas_ghpython/components/Compas_Info/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

"ghpython": {
"isAdvancedMode": true,
"iconDisplay": 2,
"inputParameters": [
],
"outputParameters": [
Expand Down
Binary file modified src/compas_ghpython/components/Compas_ToJson/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/compas_ghpython/components/Compas_ToJson/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

"ghpython": {
"isAdvancedMode": true,
"iconDisplay": 2,
"inputParameters": [
{
"name": "data",
Expand Down
14 changes: 14 additions & 0 deletions src/compas_ghpython/components/Compas_ToRhinoGeometry/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
Draws COMPAS geometry in Grasshopper.
"""
from ghpythonlib.componentbase import executingcomponent as component

from compas.artists import Artist


class CompasToRhinoGeometry(component):
def RunScript(self, cg):
if not cg:
return None

return Artist(cg).draw()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "Draw",
"nickname": "Draw",
"category": "COMPAS",
"subcategory": "Display",
"description": "Draws COMPAS geometry",
"exposure": 2,

"ghpython": {
"isAdvancedMode": true,
"iconDisplay": 2,
"inputParameters": [
{
"name": "cg",
"description": "The COMPAS geometry or datastructure to be drawn."
}
],
"outputParameters": [
{
"name": "rg",
"description": "The Rhino geometry object."
}
]
}
}
11 changes: 0 additions & 11 deletions src/compas_ghpython/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,6 @@
import compas_rhino


def coerce_frame(plane):
import Rhino
from compas.geometry import Frame
if isinstance(plane, Rhino.Geometry.Plane):
return Frame(plane.Origin, plane.XAxis, plane.YAxis)
elif isinstance(plane, Frame):
return plane
else:
return Frame(*plane)


def get_version_from_args():
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--version', choices=compas_rhino.SUPPORTED_VERSIONS, default=compas_rhino.DEFAULT_VERSION)
Expand Down

0 comments on commit 47d938e

Please sign in to comment.