Esempio n. 1
0
        //========================================================================================================================
        // Implement IPhotoRenderContext interface methods called at times of drawing geometry as if executing the Render command.
        // Only actual geometry suitable to appear in a rendered view will be processed and output.

        // Start is called at the very start of the export process, still before the first entity of the model was send out.
        public bool Start()
        {
            // Retrieve the list of extra search paths for Revit texture files.
            RetrieveExtraTexturePaths();

            // Set the coordinate system type of the world geometries and transforms.
            // Revit uses a right-handed Z-up coordinate system.
            FDatasmithFacadeElement.SetCoordinateSystemType(FDatasmithFacadeElement.ECoordinateSystemType.RightHandedZup);

            // Set the scale factor from Revit world units to Datasmith centimeters.
            // Revit uses foot as internal system unit for all 3D coordinates.
            FDatasmithFacadeElement.SetWorldUnitScale(CENTIMETERS_PER_FOOT);

            // We are ready to proceed with the export.
            return(true);
        }
        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);
        }