Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 8532

Saving OBJ using c# API (FileObj.Write)

$
0
0

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.Geometry.MeshingParameters.QualityRenderMesh;

        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,
                                                 objWriteOptions);
            rc = (res == Rhino.PlugIns.WriteFileResult.Success);

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

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

        return rc;
    }

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 8532

Trending Articles