Rhino > Revit inside Compute Environment

I am trying to send some rhino meshes and converting them to Revit topography via grasshopper but in a compute environment. I am fully aware that the Revit speckle components do not work in a headless environment. But I tried sending a mesh through and even though it returned with 500 error during the post and also showed an error in the logs, the actual mesh got sent. I want to note this was only possible when I manually opened up the compute.geometry in my ec2 instance, and it would not work when I just tried to run it.

I was wondering if there is a trick to this, where I wouldn’t have to manually open up the compute.geometry instance to get this working. I’ll attach the python code where I read a rhino file and send the geometry and also the ghx for compute.

rhFile = rh.File3dm.Read('./test.3dm')
layers = rhFile.Layers

topo = []
for obj in rhFile.Objects:
    layer_index = obj.Attributes.LayerIndex
    if layers[layer_index].Name == "Topography":
        topo.append(obj)

topo_meshes = [obj.Geometry for obj in topo]

topo_to_send = [{"ParamName": "Mesh", "InnerTree": {}}]

for i, mesh in enumerate(topo_meshes):
    serialized_mesh = json.dumps(mesh, cls=__Rhino3dmEncoder)
    key = f"{{{i};0}}"
    value = [
        {
            "type": "Rhino.Geometry.Mesh",
            "data": serialized_mesh
        }
    ]
    topo_to_send[0]["InnerTree"][key] = value


gh_decoded = encode_ghx_file('./test.ghx')

geo_payload = {
    "algo": gh_decoded,
    "pointer": None,
    "values": topo_to_send
}

res = requests.post(compute_url + "grasshopper", json=geo_payload, headers=headers)

test.ghx (37.3 KB)

Hi @Rivindu_Bandara!

Thanks for reporting this. While I look into your GH file, could you share with us the error that you get in your compute server when you run this?

Just checked your file and it seems to run fine on my end.

We don’t have an actual Rhino.Compute instance so I tested this with Hops (which runs a local rhino.compute for you in the background).

And the resulting commit Speckle

So I think I’m going to need some more detail on how you’re running things and what’s going wrong to figure this one out :wink:

1 Like

Hi @AlanRynne,

Ok noob mistake from my end, I forgot a context print or RH_OUT. Now there is no errors but its still the same problem. It runs fine when I send a post request and I have compute.geometry in my EC2 instance manually opened up, but doesn’t run when I want to send a post request normally.

Also, I can see the topography comes out different when I run it through compute vs through grasshopper.


The goal basically is to get native Revit topography from Rhino through compute.

Thanks

What do you mean by “doesn’t run”? Does your compute instance not get the post request at all? Does it fail to start running the Grasshopper file, or does it fail during the run?

How is your EC2 instance authenticated in Speckle? Did you add an account in the EC2 instance with access to that stream?

Screenshots of your Rhino.Compute console would be helpful.

This is a scaling issue. Do take into account that Grasshopper is a unit-less modelling program. Meaning, the numbers you use for modelling only make sense in the context of a Rhino document (which does have modelling units, and are the ones assumed by Grasshopper)

i.e if your Rhino doc is in inches, a sphere of radius 1 in Grasshopper would have 1in radius. Change your modelling units to meters, and that same GH file now outputs a sphere of 1m radius.

This is what you’re experiencing in those screenshots. I’m guessing the original mesh was in meters, but your default unit in Compute is mm

You can now what units Speckle nodes will be using because they’re printed into the console every time a component fetches the doc (a bit overkill… I know)

Screenshot 2023-08-02 at 11.07.08

If you need to specify the modelling units in a Grasshopper Compute run, we suggest either:

  • Changing the default units of your EC2 Rhino instance so that it matches your defaults.
  • Use a python/c# script to create a new headless doc and assign it to rhino’s ActiveDoc. You can modify the doc’s units based on a fixed desired unit or an input.

Here’s how it would look in python

my_doc = Rhino.RhinoDoc.CreateHeadless(None)
# Modify doc units here!   
Rhino.RhinoDoc.ActiveDoc = my_doc

This should be done before any speckle node’s run, so ideally right after the inputs would be the best place.

1 Like

Hi @AlanRynne

Thanks for the reply, I fixed the scaling issues by creating a headless doc.

I have logged into the manager on my ec2 instance with the same account.

I just tried with the get stream component


But still there is not luck, the console outputs a 200 request but the mesh doesn’t get sent as a commit.

Here is the output of the console.

Thanks

Hey Rivindu,

Jumping in to ask some more questions.

Is the commit created but empty or there is no commit at all? If a commit is created, can you share it with us?

I see some 401 errors, do you know what components are throwing them?

1 Like

Hi @teocomi,

So no, a commit does not get created. I output the string of the stream in the grasshopper script but when I print it, its empty meaning it never actually creates a commit.

Also, the 401 errors might relate to the speckle components, I suspect it is most likely an authentication error with speckle. There arent any other grasshopper components besides the speckle ones.

Thanks

Then I’ll refer to my previous questions:

Hi @AlanRynne,

So, I’ve downloaded and logged into the manager on the EC2 instance with my account.

Thats about it, is there anything else I need to do?

Thanks

Hi @AlanRynne, @teocomi,

I figured out what was going wrong, somehow even though I had downloaded speckle on the ec2 instance, the grasshopper components were not there, this was causing a missing components error. I redownloaded the manager + the connectors and restarted my instance, that worked.

Thanks again for all your help.

4 Likes

Glad it’s solved!

Would love to know more about what you’re building, if it’s something you can showcase :star_struck:

3 Likes