Example #1
0
        public void fuckFace(Autodesk.Revit.UI.UIApplication revit)
        {
            m_Revit = revit;
            // Create data generator
            m_Generator = new DataGenerator(m_Revit.Application,
                                            m_Revit.ActiveUIDocument.Document,
                                            m_Revit.ActiveUIDocument.Document.ActiveView);
            FolderBrowserDialog folderDialog = new FolderBrowserDialog();

            // Set file name of exported stl
            string fileName;

            if (folderDialog.ShowDialog() == DialogResult.OK)
            {
                fileName = folderDialog.SelectedPath + "\\buildingPrint.stl";
            }
            else
            {
                return;
            }


            // Set binary save format
            SaveFormat saveFormat = SaveFormat.Binary;

            // Set export range
            ElementsExportRange exportRange = ElementsExportRange.OnlyVisibleOnes;

            // Include linked
            cbIncludeLinked = true;

            // Export in color
            cbExportColor = false;

            // Export in shared coordinates
            cbExportSharedCoordinates = false;

            // Set dup to 2 for millimeters
            dup = DisplayUnitType.DUT_MILLIMETERS;

            // scan for categories and add each of them to selectedCategories
            m_CategoryList = m_Generator.ScanCategories(true);
            List <Category> selectedCategories = m_CategoryList.Values.ToList();

            // create settings object to save setting information
            BIM.STLExport.Settings aSetting = new BIM.STLExport.Settings(saveFormat,
                                                                         exportRange,
                                                                         cbIncludeLinked,
                                                                         cbExportColor,
                                                                         cbExportSharedCoordinates,
                                                                         selectedCategories,
                                                                         dup);
            // save Revit document's triangular data in a temporary file
            m_Generator = new DataGenerator(m_Revit.Application,
                                            m_Revit.ActiveUIDocument.Document,
                                            m_Revit.ActiveUIDocument.Document.ActiveView);
            // Save STL file
            DataGenerator.GeneratorStatus succeed = m_Generator.SaveSTLFile(fileName, aSetting);
        }
Example #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="saveFormat">The file format.</param>
 /// <param name="exportRange">The export range.</param>
 public Settings(SaveFormat saveFormat, ElementsExportRange exportRange)
 {
     m_SaveFormat              = saveFormat;
     m_ExportRange             = exportRange;
     m_IncludeLinkedModels     = false;
     m_exportColor             = false;
     m_exportSharedCoordinates = false;
     m_SelectedCategories      = new List <Category>();
     m_Units = DisplayUnitType.DUT_UNDEFINED;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="saveFormat">The file format.</param>
 /// <param name="exportRange">The export range.</param>
 public Settings(SaveFormat saveFormat, ElementsExportRange exportRange)
 {
     m_SaveFormat = saveFormat;
     m_ExportRange = exportRange;
     m_IncludeLinkedModels = false;
     m_exportColor = false;
     m_exportSharedCoordinates = false;
     m_SelectedCategories = new List<Category>();
     m_Units = DisplayUnitType.DUT_UNDEFINED;
 }
Example #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="saveFormat">The file format.</param>
 /// <param name="exportRange">The export range.</param>
 /// <param name="includeLinkedModels">True to include linked models, false otherwise.</param>
 /// <param name="selectedCategories">The selected categories to be included.</param>
 public Settings(SaveFormat saveFormat, ElementsExportRange exportRange, bool includeLinkedModels, bool exportColor, bool exportSharedCoordinates,
                 List <Category> selectedCategories, DisplayUnitType units)
 {
     m_SaveFormat              = saveFormat;
     m_ExportRange             = exportRange;
     m_IncludeLinkedModels     = includeLinkedModels;
     m_exportColor             = exportColor;
     m_exportSharedCoordinates = exportSharedCoordinates;
     m_SelectedCategories      = selectedCategories;
     m_Units = units;
 }
Example #5
0
        /// <summary>
        /// Get every Element in all open documents.
        /// </summary>
        /// <param name="exportRange">
        /// The range of elements to be exported.
        /// </param>
        private void ScanElement(ElementsExportRange exportRange)
        {
            List <Document> documents = new List <Document>();

            // active document should be the first docuemnt in the list
            documents.Add(m_ActiveDocument);

            // figure out if we need to get linked models
            if (m_Settings.IncludeLinkedModels)
            {
                List <Document> linkedDocList = GetLinkedModels();
                documents.AddRange(linkedDocList);
            }

            foreach (Document doc in documents)
            {
                FilteredElementCollector collector = null;

                if (ElementsExportRange.OnlyVisibleOnes == exportRange)
                {
                    // find the view having the same name of ActiveView.Name in active and linked model documents.
                    ElementId viewId = FindView(doc, m_ActiveView.Name);

                    if (viewId != ElementId.InvalidElementId)
                    {
                        collector = new FilteredElementCollector(doc, viewId);
                    }
                    else
                    {
                        collector = new FilteredElementCollector(doc);
                    }
                }
                else
                {
                    collector = new FilteredElementCollector(doc);
                }

                collector.WhereElementIsNotElementType();

                FilteredElementIterator iterator = collector.GetElementIterator();

                while (iterator.MoveNext())
                {
                    System.Windows.Forms.Application.DoEvents();

                    if (m_StlExportCancel.CancelProcess == true)
                    {
                        return;
                    }

                    Element element = iterator.Current;

                    // check if element's category is in the list, if it is continue.
                    // if there are no selected categories, take anything.
                    if (m_Settings.SelectedCategories.Count > 0)
                    {
                        if (element.Category == null)
                        {
                            continue;
                        }
                        else
                        {
                            IEnumerable <Category> cats = from cat in m_Settings.SelectedCategories
                                                          where cat.Id == element.Category.Id
                                                          select cat;

                            if (cats.Count() == 0)
                            {
                                continue;
                            }
                        }
                    }

                    // get the GeometryElement of the element
                    GeometryElement geometry = null;
                    geometry = element.get_Geometry(m_ViewOptions);

                    if (null == geometry)
                    {
                        continue;
                    }

                    // get the solids in GeometryElement
                    ScanGeomElement(doc, geometry, null);
                }
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="saveFormat">The file format.</param>
 /// <param name="exportRange">The export range.</param>
 /// <param name="includeLinkedModels">True to include linked models, false otherwise.</param>
 /// <param name="selectedCategories">The selected categories to be included.</param>
 public Settings(SaveFormat saveFormat, ElementsExportRange exportRange, bool includeLinkedModels,bool exportColor,bool exportSharedCoordinates,
     List<Category> selectedCategories, DisplayUnitType units)
 {
     m_SaveFormat = saveFormat;
     m_ExportRange = exportRange;
     m_IncludeLinkedModels = includeLinkedModels;
     m_exportColor = exportColor;
     m_exportSharedCoordinates = exportSharedCoordinates;
     m_SelectedCategories = selectedCategories;
     m_Units = units;
 }
        /// <summary>
        /// Get every Element in all open documents.
        /// </summary>
        /// <param name="exportRange">
        /// The range of elements to be exported.
        /// </param>
        private void ScanElement(ElementsExportRange exportRange)
        {
            List<Document> documents = new List<Document>();

            // active document should be the first docuemnt in the list
            documents.Add(m_ActiveDocument);

            // figure out if we need to get linked models
            if (m_Settings.IncludeLinkedModels)
            {
                List<Document> linkedDocList = GetLinkedModels();
                documents.AddRange(linkedDocList);
            }

            foreach (Document doc in documents)
            {
                FilteredElementCollector collector = null;

                if (ElementsExportRange.OnlyVisibleOnes == exportRange)
                {
                    // find the view having the same name of ActiveView.Name in active and linked model documents.
                    ElementId viewId = FindView(doc, m_ActiveView.Name);

                    if (viewId != ElementId.InvalidElementId)
                        collector = new FilteredElementCollector(doc, viewId);
                    else
                        collector = new FilteredElementCollector(doc);
                }
                else
                {
                    collector = new FilteredElementCollector(doc);
                }

                collector.WhereElementIsNotElementType();

                FilteredElementIterator iterator = collector.GetElementIterator();

                while (iterator.MoveNext())
                {
                    System.Windows.Forms.Application.DoEvents();

                    if (m_StlExportCancel.CancelProcess == true)
                        return;

                    Element element = iterator.Current;

                    // check if element's category is in the list, if it is continue.
                    // if there are no selected categories, take anything.
                    if (m_Settings.SelectedCategories.Count > 0)
                    {
                        if (element.Category == null)
                        {
                            continue;
                        }
                        else
                        {
                            IEnumerable<Category> cats = from cat in m_Settings.SelectedCategories
                                                         where cat.Id == element.Category.Id
                                                         select cat;

                            if (cats.Count() == 0)
                            {
                                continue;
                            }
                        }
                    }

                    // get the GeometryElement of the element
                    GeometryElement geometry = null;
                    geometry = element.get_Geometry(m_ViewOptions);

                    if (null == geometry)
                    {
                        continue;
                    }

                    // get the solids in GeometryElement
                    ScanGeomElement(doc,geometry, null);
                }
            }
        }