コード例 #1
0
        public Result ExecuteSteerSuite(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            // Determine elements to export

            FilteredElementCollector collector = null;

            // Access current selection


            // If nothing was preselected, export
            // all model elements to OBJ

            collector = new FilteredElementCollector(doc);


            collector.WhereElementIsNotElementType()
            .WhereElementIsViewIndependent();

            if (null == _export_folder_name)
            {
                _export_folder_name = Path.GetTempPath();
            }

            string filename = null;

            if (!FileSelect(_export_folder_name,
                            out filename))
            {
                return(Result.Cancelled);
            }

            _export_folder_name
                = Path.GetDirectoryName(filename);

            ObjExporter exporter = new ObjExporter();

            Options opt = app.Create.NewGeometryOptions();

            ExportElements(exporter, collector, opt);

            //exporter.ExportTo(filename);
            exporter.ExportToSteerSuite();
            return(Result.Succeeded);
        }
コード例 #2
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            // Determine elements to export

            FilteredElementCollector collector = null;

            // Access current selection

            //SelElementSet set = uidoc.Selection.Elements;

            //int n = set.Size;
            int n = 0;

            if (0 < n)
            {
                // If any elements were preselected,
                // export those to OBJ

                //ICollection<ElementId> ids = set
                //  .Cast<Element>()
                //  .Select<Element, ElementId>( e => e.Id )
                //  .ToArray<ElementId>();

                //collector = new FilteredElementCollector( doc, ids );
            }
            else
            {
                // If nothing was preselected, export
                // all model elements to OBJ

                //collector = new FilteredElementCollector(doc);
                collector = new FilteredElementCollector(doc, doc.ActiveView.Id);
            }

            //collector.WhereElementIsNotElementType()
            //    .WhereElementIsViewIndependent();

            if (null == _export_folder_name)
            {
                _export_folder_name = Path.GetTempPath();
            }


            if (!FileSelect(_export_folder_name, out string filename))
            {
                return(Result.Cancelled);
            }

            _export_folder_name = Path.GetDirectoryName(filename);

            var     exporter = new ObjExporter();
            Options opt      = app.Create.NewGeometryOptions();

            opt.DetailLevel = ViewDetailLevel.Coarse;

            ExportElements(exporter, collector, opt);

            exporter.ExportTo(filename);

            //var levelOfDetail = 1.0;
            //SolidOrShellTessellationControls solidOrShellTessellationControls = new SolidOrShellTessellationControls();
            //solidOrShellTessellationControls.LevelOfDetail = (double)levelOfDetail / 30.0;
            //solidOrShellTessellationControls.Accuracy = 0.1;
            //solidOrShellTessellationControls.MinAngleInTriangle = 0.0001;
            //solidOrShellTessellationControls.MinExternalAngleBetweenTriangles = 1.0;

            //TriangulatedSolidOrShell triangulatedSolidOrShell =
            //    SolidUtils.TessellateSolidOrShell(solid, solidOrShellTessellationControls);


            return(Result.Succeeded);
        }
コード例 #3
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            // Determine elements to export

            FilteredElementCollector collector = null;

            // Access current selection

            SelElementSet set = uidoc.Selection.Elements;

            int n = set.Size;

            if (0 < n)
            {
                // If any elements were preselected,
                // export those to OBJ

                ICollection <ElementId> ids = set
                                              .Cast <Element>()
                                              .Select <Element, ElementId>(e => e.Id)
                                              .ToArray <ElementId>();

                collector = new FilteredElementCollector(doc, ids);
            }
            else
            {
                // If nothing was preselected, export
                // all model elements to OBJ

                collector = new FilteredElementCollector(doc);
            }

            collector.WhereElementIsNotElementType()
            .WhereElementIsViewIndependent();

            if (null == _export_folder_name)
            {
                _export_folder_name = Path.GetTempPath();
            }

            string filename = null;

            if (!FileSelect(_export_folder_name,
                            out filename))
            {
                return(Result.Cancelled);
            }

            _export_folder_name
                = Path.GetDirectoryName(filename);

            ObjExporter exporter = new ObjExporter();

            Options opt = app.Create.NewGeometryOptions();

            ExportElements(exporter, collector, opt);

            exporter.ExportTo(filename);

            return(Result.Succeeded);
        }