コード例 #1
0
        protected Level GetNewWallLevel(Autodesk.Revit.UI.UIApplication app)
        {
            //RibbonPanel myPanel = app.GetRibbonPanels()[0];
            RibbonPanel myPanel = app.GetRibbonPanels(Define.RevitToolRibbonTab)[0];

            if (!(GetRibbonItemByName(myPanel, "LevelsSelector") is Autodesk.Revit.UI.ComboBox 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);
        }
コード例 #2
0
        protected WallType GetNewWallType(Autodesk.Revit.UI.UIApplication app)
        {
            //RibbonPanel myPanel = app.GetRibbonPanels()[0];
            RibbonPanel myPanel = app.GetRibbonPanels(Define.RevitToolRibbonTab)[0];

            if (!(GetRibbonItemByName(myPanel, "WallTypeSelector") is RadioButtonGroup 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);
        }
コード例 #3
0
        protected List <Curve> GetNewWallShape(Autodesk.Revit.UI.UIApplication app)
        {
            //RibbonPanel myPanel = app.GetRibbonPanels()[0];
            RibbonPanel myPanel = app.GetRibbonPanels(Define.RevitToolRibbonTab)[0];

            if (!(GetRibbonItemByName(myPanel, "WallShapeComboBox") is Autodesk.Revit.UI.ComboBox 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));
            }
        }
コード例 #4
0
ファイル: AddInCommand.cs プロジェクト: nterranova-fsb/revit
        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));
            }
        }
コード例 #5
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);
        }