public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; doc = uidoc.Document; sel = uidoc.Selection; Databubble = new BubbleEnds(); CEG_Grids = (from x in new FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(BuiltInCategory.OST_Grids).OfClass(typeof(Grid)).Cast <Grid>() select new CEG_Grid(doc.ActiveView, x)).ToList(); CEG_Levels = (from x in new FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(BuiltInCategory.OST_Levels).OfClass(typeof(Level)).Cast <Level>() select new CEG_level(doc.ActiveView, x)).ToList(); using (var form = new FrmGridandlevelbuble(this, doc)) { if (form.ShowDialog() != null) { Gridandlevelbuble.Instance.Doing(doc, doc.ActiveView, Databubble, CEG_Grids); if (CEG_Levels.Count != 0) { Gridandlevelbuble.Instance.Doinglevel(doc, doc.ActiveView, Databubble, CEG_Levels); } } } return(Result.Succeeded); }
public void Doinglevel(Document doc, View view, BubbleEnds bubbleEnds, List <CEG_level> list) { using (Transaction tran = new Transaction(doc, "Ivention Tool: Show/ Hide Bubbles")) { tran.Start(); foreach (var gridBb in list) { if (gridBb.Direction == Direction.Horizontal) { if (bubbleEnds.Left == true) { gridBb.RLevel.ShowBubbleInView(gridBb.Left, view); } if (bubbleEnds.Left == false) { gridBb.RLevel.HideBubbleInView(gridBb.Left, view); } if (bubbleEnds.Right == true) { gridBb.RLevel.ShowBubbleInView(gridBb.Right, view); } if (bubbleEnds.Right == false) { gridBb.RLevel.HideBubbleInView(gridBb.Right, view); } } } tran.Commit(); } }