Saving OBJ using c# API (FileObj.Write)

When writing an obj I am being prompted on the Rhino command line for PolygonDensity.
I have asked it not to show dialogs, but it still asks for this. How do I stop it from asking anything and just write the obj file? Thanks!

    public bool writeObjFile(string filename)
        RhinoDoc doc = RhinoDoc.ActiveDoc;
        Rhino.FileIO.FileWriteOptions writeOptions =
            new Rhino.FileIO.FileWriteOptions()
            SuppressDialogBoxes      = true,
            WriteSelectedObjectsOnly = true

        Rhino.Geometry.MeshingParameters meshingParameters = 

        Rhino.FileIO.FileObjWriteOptions objWriteOptions =
            new Rhino.FileIO.FileObjWriteOptions(writeOptions)
            CreateNgons                    = false,
            CullUnnecessaryVertexesInNgons = true,
            ExportNormals                  = true,
            ExportOpenMeshes           = true,
            ExportTcs                      = true,
            ExportVcs                      = true,
            MeshParameters                 = meshingParameters,
            MeshType = Rhino.FileIO.FileObjWriteOptions.VertexWelding.Welded,
            UnderbarMaterialNames          = true,
            ExportMaterialDefinitions      = false,
            ObjectType = Rhino.FileIO.FileObjWriteOptions.GeometryType.Mesh,
            UseSimpleDialog                = false,
            WrapLongLines                  = false,


        bool rc = false;

            var res = Rhino.FileIO.FileObj.Write(filename, doc,
            rc = (res == Rhino.PlugIns.WriteFileResult.Success);

        } catch (Exception e) {
            if (e is System.IO.IOException) {

                RhinoApp.WriteLine("Write OBJ IO error: {0}",
            return false;

        return rc;

Hi Ian,

If you’re using V5, then your only option is to script the Export command.

If you’re using V6, in order to get absolutely no UI, you will need to mesh the objects first (and add them to the document). See Rhino.DocObjects.RhinoObject.MeshObjects, “uiStyle”. Then select those meshes and run your code. This will keep the meshing dialog or command options from appearing. Later you’ll have to go back and delete the temp meshes you added.

In V7, there’s is a new property on Rhino.FileIO.FileWriteOptions called SuppressAllInput that obj export pays attention to. If you add that to your code, and run it in V7, you can get what you want.

Rhino.FileIO.FileWriteOptions writeOptions = new Rhino.FileIO.FileWriteOptions() { SuppressDialogBoxes = true, SuppressAllInput = true, WriteSelectedObjectsOnly = true };


Thanks Tim – I have everything working well on Rhino 6, but now we find out that our client has Rhino 5, not 6. I’ve found the example code to get ETO forms to work in R5. My question is; we have several floating licences for R6, but how can I run R5 for just a few weeks to get this working?

Hi @ian4,

Is this what you need?

– Dale

I’ve got it running in trial mode for 90 days – that should be enough time to see if I can get an ETO dockable panel working in Rhino 5. I have the SampleCsETO you put together – hopefully I can get that working and put in my UI code and see what happens…