Note: This is mainly a Grasshopper question, but there is no category “compas_ghpython”. And as a new user I cannot put in the necessary links and images. I will post them below this first post.
I’m trying to understand the best way to implement COMPAS on my grasshopper/rhino workflow that is explained in the image. I’m struggling to understand the principles of COMPAS and how best to use it. I’ve already watched the OSArch intro by Gonzalo on Youtube. And I’ve been reading through the tutorials + API reference. I’m still struggling though.
Within Grasshopper: I especially need to convert GH (Grasshopper) and RH (Rhino referenced) geometry INTO compas geometry, but I cannot find the way to do this within GH. As I understand from the gh_python docs, the “artists” and “utilities” convert compas geometry to GH (artists) or Rhino (utilities). All I need to do is (#s are aligned to the image):
Convert Rhino referenced geometry (ex. it has a Rhino GUID) to COMPAS geometry. Question: what modules to use?
Convert Grasshopper referenced geometry (ex. only a geometry in the GH interface with no link to Rhino or a GUID) to COMPAS geometry. Question: what modules to use?
Send this geometry to be processed in a remote procedure, either locally or cloud. As I understand I can use the RPC Module, but I haven’t yet tested. No questions here yet.
Bring back both the COMPAS geometry + new custom attributes on that geometry into GH. Where do we store the custom attributes on the geometry class? Question: Can we store custom attributes on the self.data or will that conflict with the “self.to_data” or “self.to_json” methods?
Question: What is the correct methods to use to deserialize both the COMPAS geometry + custom attributes into one object to send to a DB or full JSON file?
General Question: Do you have anywhere the geometry schemas for all the COMPAS objects, especially geometry and datastructures? This is an example that applies to the GeoJSON geometry types. I want to have a set of schemas when serializing and deserializing geometry. I cannot find it in the documentation or the API reference.
Thank you for answering all these long questions.
Here is an example of the code that works for me. But this only works in GH to convert a COMPAS point to the compas_ghpython “Artist”
from compas.geometry import Point from compas_ghpython import artists from compas_ghpython import utilities # GH output of artists output_artists =  # to generate unique X, Y values for points values = range(0,range_limit) # artists will convert COMPAS geometry to the software for v in values: p = Point(v,v,0) output_artists.append(artists.PointArtist(p).draw())
In this next example, the compas_rhino modules don’t work in the GH environment to convert a rhino geometry to a COMPAS geometry. Question: what should we use in Grasshopper to achieve this functionality?
# Inputs # rh_polylines - type hint == guid # rh_points - type hint == point3d # Output Artists polylines =  points =  for guid in rh_polylines: rh_pline = RhinoCurve.from_guid(guid) c_pline = rh_pline.to_compas() print type(c_pline) for point in gh_points: p = RhinoPoint.from_geometry(point) points.append(PointArtist(p).draw())