Exemple #1
0
        protected WallType GetNewWallType(Autodesk.Revit.UI.UIApplication app)
        {
            RibbonPanel myPanel = app.GetRibbonPanels()[0];
            RadioButtonGroup radioGroupTypeSelector =
                GetRibbonItemByName(myPanel, "WallTypeSelector") as RadioButtonGroup;
             if (null == radioGroupTypeSelector) { throw new InvalidCastException("Cannot get Wall Type selector!"); }
             String wallTypeName = radioGroupTypeSelector.Current.ItemText;
             WallType newWallType = null;
             FilteredElementCollector collector = new FilteredElementCollector(app.ActiveUIDocument.Document);
             ICollection<Element> founds = collector.OfClass(typeof(WallType)).ToElements();
             foreach (Element elem in founds)
             {
                WallType wallType = elem as WallType;
                if (wallType.Name.StartsWith(wallTypeName))
                {
                   newWallType = wallType; break;
                }
             }

             return newWallType;
        }
Exemple #2
0
 protected String GetNewWallMark(Autodesk.Revit.UI.UIApplication app)
 {
     RibbonPanel myPanel = app.GetRibbonPanels()[0];
     Autodesk.Revit.UI.TextBox textBox =
         GetRibbonItemByName(myPanel, "WallMark") as Autodesk.Revit.UI.TextBox;
     if (null == textBox) { throw new InvalidCastException("Cannot get Wall Mark TextBox!"); }
     String newWallMark;
     int newWallIndex = 0;
     FilteredElementCollector collector = new FilteredElementCollector(app.ActiveUIDocument.Document);
     ICollection<Element> founds = collector.OfClass(typeof(Wall)).ToElements();
     foreach (Element elem in founds)
     {
         Wall wall = elem as Wall;
         string wallMark = wall.get_Parameter(BuiltInParameter.ALL_MODEL_MARK).AsString();
         if (wallMark.StartsWith(textBox.Value.ToString()) && wallMark.Contains('_'))
         {
             //get the index for new wall (wall_1, wall_2...)
             char[] chars = { '_' };
             string[] strings = wallMark.Split(chars);
             if (strings.Length >= 2)
             {
                 try
                 {
                     int index = Convert.ToInt32(strings[strings.Length - 1]);
                     if (index > newWallIndex) { newWallIndex = index; }
                 }
                 catch (System.Exception)
                 {
                     continue;
                 }
             }
         }
     }
     newWallMark = textBox.Value.ToString() + '_' + (newWallIndex + 1);
     return newWallMark;
 }
Exemple #3
0
 protected CurveArray GetNewWallShape(Autodesk.Revit.UI.UIApplication app)
 {
     RibbonPanel myPanel = app.GetRibbonPanels()[0];
     Autodesk.Revit.UI.ComboBox comboboxWallShape =
         GetRibbonItemByName(myPanel, "WallShapeComboBox") as Autodesk.Revit.UI.ComboBox;
     if (null == comboboxWallShape) { throw new InvalidCastException("Cannot get Wall Shape Gallery!"); }
     String wallShape = comboboxWallShape.Current.ItemText;
     if ("SquareWall" == wallShape) { return GetSquareWallShape(app.Application.Create); }
     else if ("CircleWall" == wallShape) { return GetCircleWallShape(app.Application.Create); }
     else if ("TriangleWall" == wallShape) { return GetTriangleWallShape(app.Application.Create); }
     else { return GetRectangleWallShape(app.Application.Create); }
 }
Exemple #4
0
        protected Level GetNewWallLevel(Autodesk.Revit.UI.UIApplication app)
        {
            RibbonPanel myPanel = app.GetRibbonPanels()[0];
            Autodesk.Revit.UI.ComboBox comboboxLevel =
                GetRibbonItemByName(myPanel, "LevelsSelector") as Autodesk.Revit.UI.ComboBox;
            if (null == comboboxLevel) { throw new InvalidCastException("Cannot get Level selector!"); }
            String wallLevel = comboboxLevel.Current.ItemText;
            //find wall type in document
            Level newWallLevel = null;
            FilteredElementCollector collector = new FilteredElementCollector(app.ActiveUIDocument.Document);
            ICollection<Element> founds = collector.OfClass(typeof(Level)).ToElements();
            foreach (Element elem in founds)
            {
               Level level = elem as Level;
               if (level.Name.StartsWith(wallLevel))
               {
                  newWallLevel = level; break;
               }
            }

            return newWallLevel;
        }