Writing a Rhino 3dm file from a GH c# script

Hi
I was looking at the rhinoCommon sdk for a solution but unable to find it.
Here is what I need to do :
From grasshopper component make a document fill it with geometry data
and write it to disk .
I was used to the OpenNurbs c++ where there was a ON_Model to achieve this.

thanks
Gerry

Check out the Rhino.File.IO namespace, specifically, the File3dm class.

if you component is VB Based, the exact code to do that is :

  Dim options As New Rhino.FileIO.FileWriteOptions()
  A = doc.writefile(path & ".3dm", options)

Cheers

Hi Xavier
I am not trying to write the current rhino document
but making a new document fill it and then write to disk.
Using C#

Hi Luis
Thanks, that worked fine,
Another problem I am not able to get the current Rhino Document
Rhino.App has no method to get current document , I have gone trough all sdk files
but did not find anything. I need to read doc properties like units and other stuff

Take a look at RhinoDoc.ActiveDoc: http://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_RhinoDoc_ActiveDoc.htm