public static Rhino.PlugIns.WriteFileResult Export(string Filename, RhinoDoc RhinoDocument, Rhino.FileIO.FileWriteOptions Options)
        {
            string RhinoAppName = Rhino.RhinoApp.Name;
            string RhinoVersion = Rhino.RhinoApp.ExeVersion.ToString();

            FDatasmithFacadeElement.SetCoordinateSystemType(FDatasmithFacadeElement.ECoordinateSystemType.RightHandedZup);
            FDatasmithFacadeElement.SetWorldUnitScale((float)Rhino.RhinoMath.UnitScale(RhinoDocument.ModelUnitSystem, UnitSystem.Centimeters));
            FDatasmithFacadeScene DatasmithScene = new FDatasmithFacadeScene("Rhino", "Robert McNeel & Associates", "Rhino3D", RhinoVersion);

            DatasmithScene.PreExport();

            try
            {
                RhinoApp.WriteLine(string.Format("Exporting to {0}.", System.IO.Path.GetFileName(Filename)));
                RhinoApp.WriteLine("Press Esc key to cancel...");

                FDatasmithRhinoProgressManager.Instance.StartMainTaskProgress("Parsing Document", 0.1f);
                DatasmithRhinoSceneParser SceneParser = new DatasmithRhinoSceneParser(RhinoDocument, Options);
                SceneParser.ParseDocument();

                if (ExportScene(SceneParser, DatasmithScene) == Rhino.Commands.Result.Success)
                {
                    string SceneName = System.IO.Path.GetFileName(Filename);

                    FDatasmithRhinoProgressManager.Instance.StartMainTaskProgress("Writing to files..", 1);
                    DatasmithScene.ExportScene(Filename);
                }
            }
            catch (DatasmithExportCancelledException)
            {
                return(Rhino.PlugIns.WriteFileResult.Cancel);
            }
            catch (Exception e)
            {
                RhinoApp.WriteLine("An unexpected error has occured:");
                RhinoApp.WriteLine(e.ToString());
                return(Rhino.PlugIns.WriteFileResult.Failure);
            }
            finally
            {
                FDatasmithRhinoProgressManager.Instance.StopProgress();
            }

            return(Rhino.PlugIns.WriteFileResult.Success);
        }
Esempio n. 2
0
        // OnViewEnd marks the end of a 3D view being exported.
        // This method is invoked even for 3D views that were skipped.
        public void OnViewEnd(
            ElementId InElementId             // exported 3D view ID
            )
        {
            // Forget the active Revit document being exported.
            PopDocument();

            // Check if this is regular file export.
            if (DirectLink == null)
            {
                // Build and export the Datasmith scene instance and its scene element assets.
                DatasmithScene.ExportScene(CurrentDatasmithFilePath);

                // Dispose of the Datasmith scene.
                DatasmithScene = null;
            }
            else
            {
                DirectLink.OnEndExport();
            }

            // Forget the 3D view world transform.
            WorldTransformStack.Pop();
        }