# Creating gcode

**URL:** <https://discourse.mcneel.com/t/creating-gcode/175424>\
**Category:** Grasshopper\
**Tags:** windows, 3d-printing\
**Created:** [February 12, 2024, 6:15am UTC](https://discourse.mcneel.com/t/creating-gcode/175424 "2024-02-12T06:15:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![freesheida1984](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/freesheida1984/32/766379_2.png) [@freesheida1984](https://discourse.mcneel.com/u/freesheida1984)\
**Post date:** [February 12, 2024, 6:15am UTC](https://discourse.mcneel.com/t/creating-gcode/175424/1 "2024-02-12T06:15:14Z")

</div>

hello, I am very new in creating gcode for 3d-printing. I have a geometry and I want to make it with 3d-printer but I don’t know how can I create Gcode for it, I would be appreciated if anyone can help me.  
[spiral tower.gh](https://discourse.mcneel.com/uploads/short-url/kBfhJ8jSUltwE6FwHzkCDokoiVt.gh) (14.0 KB)

---

<div class="post-metadata">

**Author:** ![ftzuk](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ftzuk/32/689170_2.png) [@ftzuk](https://discourse.mcneel.com/u/ftzuk)\
**Post date:** [February 12, 2024, 12:52pm UTC](https://discourse.mcneel.com/t/creating-gcode/175424/2 "2024-02-12T12:52:44Z")

</div>

Particular reason you don’t just bake the geometry and use a slicer (Cura etc.)?

---

<div class="post-metadata">

**Author:** ![freesheida1984](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/freesheida1984/32/766379_2.png) [@freesheida1984](https://discourse.mcneel.com/u/freesheida1984)\
**Post date:** [February 12, 2024, 3:33pm UTC](https://discourse.mcneel.com/t/creating-gcode/175424/3 "2024-02-12T15:33:20Z")

</div>

you mean I only need to bake the geometry and use Cura software to print it? if I want to create gcode in grasshopper is it possible?

---

<div class="post-metadata">

**Author:** ![inno](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/inno/32/544036_2.png) [@inno](https://discourse.mcneel.com/u/inno)\
**Post date:** [February 12, 2024, 8:26pm UTC](https://discourse.mcneel.com/t/creating-gcode/175424/4 "2024-02-12T20:26:20Z")

</div>

well, you can for sure extrapolate data from a geometry, and use those as bricks to create gcode

for instance (this is taken from Marlin) a G1 command accepts the following parameters

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/1/b/8/1b8008ee00ea8acd652fae26321b2467f0646f48.png) [Linear Move | Marlin Firmware](https://marlinfw.org/docs/gcode/G000-G001.html)

from your drawing you can get an ordered list of vertexes, and use those to start the creation of G1 linear movements like this:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/b/1/4/b144d3c723040ed40847e4f79a16a105ac1b7875.png)

depending on what you are doing, E might be a function of the length of the segment you just moved along, and you can continue composing your commands as text by concatenating (or `Text Join`)

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/2/6/f/26fddb749e6dca6c355bef8ca8a5eecba35fe657.png)

[spiral tower\_inno.gh](https://discourse.mcneel.com/uploads/short-url/sYmqaAYCJOmyjP53Adl5QPjAtXq.gh) (17.9 KB)

---

<div class="post-metadata">

**Author:** ![Birk\_Binnard](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/birk_binnard/32/691796_2.png) [@Birk\_Binnard](https://discourse.mcneel.com/u/Birk_Binnard)\
**Post date:** [February 12, 2024, 9:49pm UTC](https://discourse.mcneel.com/t/creating-gcode/175424/5 "2024-02-12T21:49:17Z")

</div>

It depends on what your objective is. If you want to print things you’ve designed in GH then do what Ftzuk said - finish your design, bake it to an STL file, and send that to a slicer program.

But if you want to learn more about GH and how to write scripts and Python/C code, try making your own Gcode.

Note that it is fairly easy to write nice looking Gcode, but it is far more difficult to write Gcode that actually works.

---

<div class="post-metadata">

**Author:** ![freesheida1984](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/freesheida1984/32/766379_2.png) [@freesheida1984](https://discourse.mcneel.com/u/freesheida1984)\
**Post date:** [February 13, 2024, 3:13am UTC](https://discourse.mcneel.com/t/creating-gcode/175424/6 "2024-02-13T03:13:14Z")

</div>

thank you for your great help, can I use this code to print my model after I convert it into txt file?  
also I have a question about the linear movement in this code, the starting point for print is 0 and also this is the point that printer goes to next surface?

---

<div class="post-metadata">

**Author:** ![guido](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/guido/32/761602_2.png) [@guido](https://discourse.mcneel.com/u/guido)\
**Post date:** [February 13, 2024, 4:36am UTC](https://discourse.mcneel.com/t/creating-gcode/175424/7 "2024-02-13T04:36:19Z")

</div>

did you have a look at this?

> **[Droid - 3d Print Slicer and Path Plotter](https://www.food4rhino.com/en/app/droid-3d-print-slicer-and-path-plotter)**
>
> 3D printing related Library including model Slicing, Custom paths and G-code generation from desktop machines to 6 DOF Robots using FFF Technology.

looks promising

---

<div class="post-metadata">

**Author:** ![inno](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/inno/32/544036_2.png) [@inno](https://discourse.mcneel.com/u/inno)\
**Post date:** [February 13, 2024, 11:17am UTC](https://discourse.mcneel.com/t/creating-gcode/175424/8 "2024-02-13T11:17:37Z")

</div>

I have no idea what material you are printing and what kind/size of machine you are using, but before diving into gcode creation and similar in GH I would first build a solid blackbone and understanding of all the key principles and methods involved

I guess relying on external slicers like Cura, as suggested, would be the best approach

---

<div class="post-metadata">

**Author:** ![ftzuk](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ftzuk/32/689170_2.png) [@ftzuk](https://discourse.mcneel.com/u/ftzuk)\
**Post date:** [February 13, 2024, 11:48am UTC](https://discourse.mcneel.com/t/creating-gcode/175424/9 "2024-02-13T11:48:53Z")

</div>

Ask yourself why you want to create g-code by hand? I understand that some people enjoy the process and find it interesting, but for me my time is limited and I’d rather spend time working on designs and let slicers handle the g-code for the 3d printer.

In the end grasshopper is a process of creating geometry. Geometry can be baked & exported as an STL file for the slicer to handle.
