Exemple #1
0
        public static bool DoExport(string fileName, glTFExportOptions opts, IEnumerable <Rhino.DocObjects.RhinoObject> rhinoObjects, Rhino.Render.LinearWorkflow workflow)
        {
            try
            {
                RhinoDocGltfConverter  converter = new RhinoDocGltfConverter(opts, rhinoObjects, workflow);
                glTFLoader.Schema.Gltf gltf      = converter.ConvertToGltf();

                if (opts.UseBinary)
                {
                    byte[] bytes = converter.GetBinaryBuffer();
                    glTFLoader.Interface.SaveBinaryModel(gltf, bytes.Length == 0 ? null : bytes, fileName);
                }
                else
                {
                    glTFLoader.Interface.SaveModel(gltf, fileName);
                }

                RhinoApp.WriteLine("Successfully exported selected geometry to glTF(Binary).");
                return(true);
            }
            catch (Exception e)
            {
                RhinoApp.WriteLine("ERROR: Failed exporting selected geometry to file.");
                System.Diagnostics.Debug.WriteLine(e.Message);
                return(false);
            }
        }
        public static bool DoExport(string fileName, glTFExportOptions options, bool binary, RhinoDoc doc, IEnumerable <Rhino.DocObjects.RhinoObject> rhinoObjects, Rhino.Render.LinearWorkflow workflow)
        {
            RhinoDocGltfConverter converter = new RhinoDocGltfConverter(options, binary, doc, rhinoObjects, workflow);

            glTFLoader.Schema.Gltf gltf = converter.ConvertToGltf();

            if (binary)
            {
                byte[] bytes = converter.GetBinaryBuffer();
                glTFLoader.Interface.SaveBinaryModel(gltf, bytes.Length == 0 ? null : bytes, fileName);
            }
            else
            {
                glTFLoader.Interface.SaveModel(gltf, fileName);
            }

            RhinoApp.WriteLine("Successfully exported selected geometry to glTF(Binary).");
            return(true);
        }