This code snippet will help you to export lines and meshes from Grasshopper to a *.dxf file. The restriction to lines and meshes is intentional and you can tweak the script to export other types of geometric objects as well.
The purpose of this setup is to export a file that contains structural elements that can be loaded by FEM software. Here, only lines and meshes are allowed and thus this restriction makes us aware of any wrong geometry types before we export. You can download the file at the bottom of this page and look at the code if you like. Now, we see how to use it.
The first inputs on the main component let you set a directory (by default it’s
your desktop) and a filename. At input S you could provide the name of an
R12 Lines & Arcs.
Your lines and meshes go into the smaller components. You can also set the layer name for each line or mesh. Your layer name will typically also be transferred to the software that reads the DXF file and you can pass some valuable information this way. If you are, for example, using Dlubal RStab, the name of the layer will become the name of the cross section.
Behind the scenes, these components will bake your geometry to Rhino, then export a DXF file through the Rhino interface and remove the geometry from Rhino. If your computer is slow and you are exporting a large amount of data, you might need to increase the timer.