Export from GH to DWG with template

Hello!

I’m trying to export geometry generated in Grasshopper to a DWG file, but I need the exported DWG to follow an existing DWG template.

The output should be a new DWG based on the template, with the Grasshopper geometry placed on the specified layers and inheriting the styles already defined in the template.

I would prefer to do this directly from Grasshopper without having to bake the geometry first.

Is there any plug-in or does anyone have a solution for that?

Via c# scripts (or python scripts).

You can load your existing .dwg file into a headless rhino document instance.
Then, iteratively add all your new geometries (each with its own attributes like layer id or custom color/linetype) to the headless instance.
Finally, save the headless instance into another .dwg path.

You can split this into 2 c# scripts:

  • 1st c# script to read your dwg template, so you can actually see its contents (as grasshopper preview) , and extract all the layers table and layers IDs.
  • in grasshopper manage all your geometries and match them with an equal amount of layer IDs and/or custom attributes
  • 2nd c# script, re-read your dwg template into an headless again and append your geometries and finally save your dwg

No idea if plugins for this exists… if anybody know, please comment so.