Grasshopper Workflow - Which Libraries / Modules to use?

@arpastrana Thank you for looking at the code!

Note: I’m using COMPAS 1.1.0

  1. I have tested what you suggest for the geometry. I used the “ghdoc” object input so that the component creates a GUID. All the other 'from_geometry" and “from_selection” and “from_object” didn’t work for me. Both the Rhino and Grasshopper files need to be downloaded from Wetransfer

Note: The POINT functionality works no problem.
Note: The POLYLINE functionality does NOT work. There is an error in the RhinoCurve.to_compas() that breaks the code. I cannot tell why.

  1. The to_data() and to_json() will not work with custom attributes as far as I can tell. It works fine for decoding/encoding the geometry, but nothing more. I really hope that the COMPAS team responds. Otherwise, we will override the function.
__author__ = "Darrel Ronald"
__version__ = "2021.04.09"


import compas
import compas_ghpython.utilities
#import compas_ghpython.artists
from compas_rhino.geometry import * #BaseRhinoGeometry, RhinoCurve, RhinoPoint
from compas_rhino.artists import *
from compas_rhino.utilities import *
from compas.geometry import *
from compas.datastructures import *
from compas.utilities import *

# Output Artists
points = []
polylines = []



# INPUT == gh_points
# Convert Grasshopper Referenced Geometry
# 1. Convert to compas_rhino with compas_rhino.geometry
# 2. Convert to compas geometry with compas.geometry
# 3. Convert to rhino geometry with compas_rhino.artists

for i in gh_points:
    print "type i in gh_points";  print type(i)
    # Create COMPAS RhinoPoint wrapper from GUID
    rh_point = RhinoPoint.from_guid(i)
    
    # Cast RhinoPoint to COMPAS.geometry.Point
    c_point = rh_point.to_compas()
    print "type: c_point:"; print type(c_point)
    
    # Create COMPAS artists to return to Rhino Geometry
    # PointArtist returns a LIST for some reason here
    artist = PointArtist(c_point).draw()
    print "artist:"; print type(artist)
    for a in artist:
        points.append(a)

for point in points:
    print "item in points list:"; print type(point)




# INPUT == rh_polylines
# Convert Rhino Referenced Geometry
# 1. Convert to compas_rhino with compas_rhino.geometry
# 2. Convert to compas geometry with compas.geometry
# 3. Convert to rhino geometry with compas_rhino.artists

for i in rh_polylines:
    print "type i in polylines:"; print type(i)
    
    # compas rhino wrapper
    rh_pline = RhinoCurve.from_guid(i)
    print "type rh_pline:"; print type(rh_pline)
    
    c_pline = rh_pline.to_compas()
    print "c_pline"; print type(c_pline)
    
    # compas geometry
    if rh_pline.is_polyline():
        isinstance(c_pline, comas.geometry.Polyline)
        print "it is a polyline"
    elif rh_pline.is_line():
        isinstance(c_pline, compas.geometry.Line)
        print "it is a line"
        
    
    # rhino artist
    artist = PolylineArtist(c_pline).draw()
    print "pline artist:"; print type(artist)
    for a in artist:
        polylines.append(a)
    
    #polylines.append(CurveArtist(c_pline).draw())
    #CurveArtist(c_pline).draw()



"""
Note Darrel: This is the COMPAS example of casting a RhinoCurve to COMPAS Curve. I follow it but it doesn't work for me.


Wrapper for Rhino curve objects.

Parameters
----------`Preformatted text`
None

Attributes
----------
start (read-only) : Rhino.Geometry.Point3d
    The start point of the curve.
end (read-only) : Rhino.Geometry.Point3d
    The end point of the curve.
points (read-only) : list of RhinoGeometry.Point3d
    List of points between start and end, defining the geometry of the curve.

Examples
--------
>>> rhinocurve = RhinoCurve.from_guid(guid)
>>> curve = rhinocurve.to_compas()
>>> if rhinocurve.is_line():
...     isinstance(curve, compas.geometry.Line)
...
True
>>> if rhinocurve.is_polyline():
...     isinstance(curve, compas.geometry.Polyline)
...
True
"""