Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Mar 28, 2022
2 parents 7565fab + 47d938e commit 8ef596c
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 55 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

* 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
3 changes: 3 additions & 0 deletions src/compas/robots/model/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,15 @@ def data(self):
'filename': self.filename,
'scale': self.scale,
'attr': _attr_to_data(self.attr),
'meshes': [m.data for m in self.meshes],
}

@data.setter
def data(self, data):
self.filename = data['filename']
self.scale = data['scale']
self.attr = _attr_from_data(data['attr']) if 'attr' in data else {}
self.meshes = [Mesh.from_data(md) for md in data['meshes']] if 'meshes' in data else []

@classmethod
def from_data(cls, data):
Expand Down Expand Up @@ -364,6 +366,7 @@ def get_color(self):
('point', 'radius'): compas.geometry.Sphere,
('line', 'radius'): compas.geometry.Capsule,
('attr', 'filename', 'scale'): MeshDescriptor,
('attr', 'filename', 'meshes', 'scale'): MeshDescriptor,
}


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 8ef596c

Please sign in to comment.