How to bake all GH geometry objects simultaneously with ghPython

Hi - I am writing a python component to bake a lot of objects (~4000 meshes, say) to Rhino. I have found various examples which effectively use something like:

sc.doc.Objects.Add(geometry,attributes)

Trouble is, this adds each of my meshes one at a time, so it takes maybe 30-60 seconds.

If I bake the same objects using right click > bake it clearly adds all objects simultaneously. [Elefront also works ~ instantaneously but I want to avoid a plugin dependency.]

I feel like there is something simple I’m missing (or Elefront is doing something insanely clever!). Is there any way to replicate this in a python command?

Thanks!

Try one of the more specific Objects.Add* commands in the API, especially the Objects.AddMesh ones.

https://developer.rhino3d.com/api/rhinocommon/rhino.docobjects.tables.objecttable

1 Like

Thanks for the reply James, I’d been banging my head against a brick wall there!

I definitely tested using AddMesh before and it had the same/similar problem - BUT I think I actually had 2 things slowing it down - the other one was that I was using rs.ObjectLayer to change the layers after the elements had been added.

So, solution was to use Objects.AddMesh, and also to set the layer index(es) within the attributes passed to the AddMesh method.

Thanks again.

1 Like