Exporting grasshopper geometry to rhino file without baking it

Hi all,

I’m looking for an efficient way of exporting multiple grasshopper geometries to a .3dm file without baking it first. The reason to why I don’t want to bake the geometry is that I want to do it for many different geometries, so I want to be able to script the whole thing and not have to add or delete anything from the open rhino instance. This is a step by step of what I want to do:

  1. select the number of alternatives an create an array of seeds this long
  2. create a set of (simple) geometries based on the seed
  3. save the geometries to a .3dm with layers to a specific folder on my machine
  4. do the same thing for the next seed

I think the whole geometry creation is so simple (basically boxes) so it could easily be done within a python or C# component, so I just need a toolkit or vanilla grasshopper function to reference that can do the saving part for me without having to bake the geometry first.

Please let me know if you have ideas!
Best,
Erik

There are many ways. Can be done mostly with plugins.

Option 1) automatic baking / referencing using elefront.

Option 2) export the geometry directly to an external 3DM using pancake.

2 Likes

@erikforsberg95

The v5 version of eleFront for R7 should do a lot of what you want, including some optimizations for network saving if that happens to be part of your workflow.

It is in beta right now, but we should be wrapping up everything relative soon. Love to have your feedback.

5 Likes

Hi Erik,

I made this basic setup that might help get you going:


export_breps.gh (5.6 KB)

code in block:

import Rhino
import System

new_file = Rhino.FileIO.File3dm()
layers = new_file.AllLayers
layer_index = layers.AddLayer(target_layer, System.Drawing.Color.Aqua)

new_attributes = Rhino.DocObjects.ObjectAttributes()
new_attributes.LayerIndex = layer_index

for brep in breps:  
    new_file.Objects.AddBrep(brep, new_attributes)

print new_file.Write(file_path, 0)

3 Likes

@tay.othman @elevelle @Willem

Wow, thanks guys! I didn’t expect to get so many great answers to this so quickly. I’ll try it all out as soon as I’m back after Easter. Really appreciate it!

Best,
Erik

1 Like

Hi @Willem , looks neat, how would that change to make it work with meshes? I’m trying on my own but I can’t make it work. Thanks :slight_smile:

Hi

For mashes to work, the code in the python block should read:

import Rhino
import System

new_file = Rhino.FileIO.File3dm()
layers = new_file.AllLayers
layer_index = layers.AddLayer(target_layer, System.Drawing.Color.Aqua)

new_attributes = Rhino.DocObjects.ObjectAttributes()
new_attributes.LayerIndex = layer_index

for mesh in meshes:  
    new_file.Objects.AddMesh(mesh, new_attributes)

print new_file.Write(file_path, 0)

The block should have ‘breps’ input name changed to ‘meshes’

Does this help?

-Willem

1 Like

Hi Willem,

thanks a lot for all the help with this!

Best,
Erik

1 Like

Hi, why do I get this error when downloading your script?

Thanks

Andy

Hi Andy

Hard to tell without actual code to test.

Did you get is fixed already?
-Willem

Hi Willem, I found your previous answers very useful, so thank you! I am having the same problem Andy has (Runtime error…MissingMemberException…). Do you have any clue to solve it? Thanks, Giada

Hi Giada,

I’m unable to repeat that error, so I don’t have a solution for you.

Maybe it is related to other components?

NURBS BSPLINE - Copy.gh (12.0 KB)
idealcurvecoordinates.csv (109 Bytes)
NURBS BSPLINE 16 03 203.3dm (25.6 KB)
Hi Willem, I should have uploaded all the files to repeat the error. I’m sorry if the code is not clean; I’m very new to Grasshopper and trying to do what I want by collecting information from different sources.

Hi Giada,

The component expects a list but gets a single item.
try to set the brep input to list access.

Does that help?

Thank you Willem! Unfortunately, it still returns the same error. Anyway, I managed to export my geometry by using Pancake plugin :slight_smile:

1 Like