# Exporting grasshopper geometry to rhino file without baking it

**URL:** <https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137>\
**Category:** Grasshopper\
**Tags:** windows, export, baking\
**Created:** [April 14, 2022, 8:43pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137 "2022-04-14T20:43:36Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikforsberg95](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/erikforsberg95/32/482403_2.png) [@erikforsberg95](https://discourse.mcneel.com/u/erikforsberg95)\
**Post date:** [April 14, 2022, 8:43pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/1 "2022-04-14T20:43:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tay.othman](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/tay.othman/32/766134_2.png) [@tay.othman](https://discourse.mcneel.com/u/tay.othman)\
**Post date:** [April 14, 2022, 8:54pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/2 "2022-04-14T20:54:15Z")

</div>

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

Option 1) automatic baking / referencing using elefront.

> **[eleFront](https://www.food4rhino.com/en/app/elefront)**
>
> Bake geometry, annotations and blocks with user defined attributes and or Rhino attributes. Reference and filter all Rhino objects into GH.

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

> **[Pancake](https://www.food4rhino.com/en/app/pancake)**
>
> Easily exchange files across versions, teams, and devices. Import/export JSON, XML, STL, and any Rhino-supported format—plus much more!

---

<div class="post-metadata">

**Author:** ![elevelle](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/elevelle/32/729148_2.png) [@elevelle](https://discourse.mcneel.com/u/elevelle)\
**Post date:** [April 15, 2022, 8:56am UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/3 "2022-04-15T08:56:41Z")

</div>

@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.

> **[Working with External Files](https://docs.elefront.io/new-features-in-elefront-5.x/new-features/working-with-external-files)**

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

---

<div class="post-metadata">

**Author:** ![Willem](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/willem/32/773637_2.png) [@Willem](https://discourse.mcneel.com/u/Willem)\
**Post date:** [April 15, 2022, 12:35pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/4 "2022-04-15T12:35:21Z")

</div>

Hi Erik,

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

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/6/c/b/6cb25ef32e298e48adf817ec751174907a37d3ca.png)  
[export\_breps.gh](https://discourse.mcneel.com/uploads/short-url/1R6eeCLsdEvWbYL0djlJAle7SMC.gh) (5.6 KB)

code in block:

```python
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)

```

---

<div class="post-metadata">

**Author:** ![erikforsberg95](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/erikforsberg95/32/482403_2.png) [@erikforsberg95](https://discourse.mcneel.com/u/erikforsberg95)\
**Post date:** [April 16, 2022, 2:05pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/5 "2022-04-16T14:05:15Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![Carlo\_Mancari](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/carlo_mancari/32/398589_2.png) [@Carlo\_Mancari](https://discourse.mcneel.com/u/Carlo_Mancari)\
**Post date:** [August 17, 2022, 3:28pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/6 "2022-08-17T15:28:56Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Willem](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/willem/32/773637_2.png) [@Willem](https://discourse.mcneel.com/u/Willem)\
**Post date:** [August 18, 2022, 12:16pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/7 "2022-08-18T12:16:07Z")

</div>

Hi

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

```python
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

---

<div class="post-metadata">

**Author:** ![erikforsberg95](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/erikforsberg95/32/482403_2.png) [@erikforsberg95](https://discourse.mcneel.com/u/erikforsberg95)\
**Post date:** [August 30, 2022, 7:28am UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/8 "2022-08-30T07:28:09Z")

</div>

Hi Willem,

thanks a lot for all the help with this!

Best,  
Erik

---

<div class="post-metadata">

**Author:** ![andyloat](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andyloat/32/376153_2.png) [@andyloat](https://discourse.mcneel.com/u/andyloat)\
**Post date:** [October 14, 2022, 11:31am UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/9 "2022-10-14T11:31:33Z")

</div>

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

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/5/9/2/592e568ef449cca72ad51010500baf772fa0854f.png)

Thanks

Andy

---

<div class="post-metadata">

**Author:** ![Willem](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/willem/32/773637_2.png) [@Willem](https://discourse.mcneel.com/u/Willem)\
**Post date:** [October 17, 2022, 1:45pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/10 "2022-10-17T13:45:53Z")

</div>

Hi Andy

Hard to tell without actual code to test.

Did you get is fixed already?  
-Willem

---

<div class="post-metadata">

**Author:** ![Giada](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/giada/32/450041_2.png) [@Giada](https://discourse.mcneel.com/u/Giada)\
**Post date:** [March 16, 2023, 5:20pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/11 "2023-03-16T17:20:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Willem](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/willem/32/773637_2.png) [@Willem](https://discourse.mcneel.com/u/Willem)\
**Post date:** [March 17, 2023, 12:02pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/12 "2023-03-17T12:02:04Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Giada](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/giada/32/450041_2.png) [@Giada](https://discourse.mcneel.com/u/Giada)\
**Post date:** [March 17, 2023, 12:37pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/13 "2023-03-17T12:37:57Z")

</div>

[NURBS BSPLINE - Copy.gh](https://discourse.mcneel.com/uploads/short-url/pnhHaEFVu2jVv7zAVdT8EA2TMqi.gh) (12.0 KB)  
[idealcurvecoordinates.csv](https://discourse.mcneel.com/uploads/short-url/vvTprW1IB6kWOLiVJykM49gTRga.csv) (109 Bytes)  
[NURBS BSPLINE 16 03 203.3dm](https://discourse.mcneel.com/uploads/short-url/jCE6BjLNzOKjrlRrKNGK8ZGeL65.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.

---

<div class="post-metadata">

**Author:** ![Willem](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/willem/32/773637_2.png) [@Willem](https://discourse.mcneel.com/u/Willem)\
**Post date:** [March 20, 2023, 9:27am UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/14 "2023-03-20T09:27:55Z")

</div>

Hi Giada,

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

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/f/c/4/fc4d08b5de26b0b6c7cc2dcad5e7e41bee0f467e.png)

Does that help?

---

<div class="post-metadata">

**Author:** ![Giada](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/giada/32/450041_2.png) [@Giada](https://discourse.mcneel.com/u/Giada)\
**Post date:** [March 20, 2023, 3:22pm UTC](https://discourse.mcneel.com/t/exporting-grasshopper-geometry-to-rhino-file-without-baking-it/141137/15 "2023-03-20T15:22:06Z")

</div>

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