Exemple #1
0
        /// <summary>
        /// Select elements in Revit to obtain the footprint roof lines.
        /// </summary>
        /// <returns>A curve array to hold the footprint roof lines.</returns>
        public CurveArray SelectFootPrint()
        {
            m_footPrint.Clear();
            while (true)
            {
                ElementSet es = new ElementSet();
                foreach (ElementId elementId in m_selection.GetElementIds())
                {
                    es.Insert(m_commandData.Application.ActiveUIDocument.Document.GetElement(elementId));
                }
                es.Clear();
                IList <Element> selectResult;
                try
                {
                    selectResult = m_selection.PickElementsByRectangle();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    break;
                }

                if (selectResult.Count != 0)
                {
                    foreach (Autodesk.Revit.DB.Element element in selectResult)
                    {
                        Wall wall = element as Wall;
                        if (wall != null)
                        {
                            LocationCurve wallCurve = wall.Location as LocationCurve;
                            m_footPrint.Append(wallCurve.Curve);
                            continue;
                        }

                        ModelCurve modelCurve = element as ModelCurve;
                        if (modelCurve != null)
                        {
                            m_footPrint.Append(modelCurve.GeometryCurve);
                        }
                    }
                    break;
                }
                else
                {
                    TaskDialogResult result = TaskDialog.Show("Warning", "You should select a curve loop, or a wall loop, or loops combination \r\nof walls and curves to create a footprint roof.", TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel);
                    if (result == TaskDialogResult.Cancel)
                    {
                        break;
                    }
                }
            }

            return(m_footPrint);
        }
Exemple #2
0
        /// <summary>
        /// Select elements in Revit to obtain the footprint roof lines.
        /// </summary>
        /// <returns>A curve array to hold the footprint roof lines.</returns>
        public CurveArray SelectFootPrint()
        {
            m_footPrint.Clear();
            while (true)
            {
                m_selection.Elements.Clear();
                IList <Element> selectResult;
                try
                {
                    selectResult = m_selection.PickElementsByRectangle();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    break;
                }

                if (selectResult.Count != 0)
                {
                    foreach (Autodesk.Revit.DB.Element element in selectResult)
                    {
                        Wall wall = element as Wall;
                        if (wall != null)
                        {
                            LocationCurve wallCurve = wall.Location as LocationCurve;
                            m_footPrint.Append(wallCurve.Curve);
                            continue;
                        }

                        ModelCurve modelCurve = element as ModelCurve;
                        if (modelCurve != null)
                        {
                            m_footPrint.Append(modelCurve.GeometryCurve);
                        }
                    }
                    break;
                }
                else
                {
                    DialogResult result = MessageBox.Show("You should select a curve loop, or a wall loop, or loops combination \r\nof walls and curves to create a footprint roof.", "Warning",
                                                          MessageBoxButtons.OKCancel);
                    if (result == DialogResult.Cancel)
                    {
                        break;
                    }
                }
            }

            return(m_footPrint);
        }
Exemple #3
0
 /// <summary>
 /// Select elements in Revit to obtain the extrusion profile lines.
 /// </summary>
 /// <returns>A curve array to hold the extrusion profile lines.</returns>
 public CurveArray SelectProfile()
 {
     m_profile.Clear();
     while (true)
     {
         m_selection.Elements.Clear();
         IList <Element> selectResult;
         try
         {
             selectResult = m_selection.PickElementsByRectangle();
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
             break;
         }
         if (selectResult.Count != 0)
         {
             foreach (Autodesk.Revit.DB.Element element in selectResult)
             {
                 ModelCurve modelCurve = element as ModelCurve;
                 if (modelCurve != null)
                 {
                     m_profile.Append(modelCurve.GeometryCurve);
                     continue;
                 }
             }
             break;
         }
         else
         {
             DialogResult result = MessageBox.Show("You should select a  connected lines or arcs, \r\nnot closed in a loop to create extrusion roof.", "Warning",
                                                   MessageBoxButtons.OKCancel);
             if (result == DialogResult.Cancel)
             {
                 break;
             }
         }
     }
     return(m_profile);
 }