Esempio n. 1
0
        public override void InnerExecute(UpdaterData data)
        {
            var modified = data.GetModifiedElementIds();
            var added    = data.GetAddedElementIds();
            var deleted  = data.GetDeletedElementIds();

            foreach (ElementId id in modified.Concat(added))
            {
                try
                {
                    Element el = Document.GetElement(id);
                    if (el is Room)
                    {
                        FinishingData.Calculate(el as Room);
                        FinishingData.AggregateFloors(el);
                    }
                    else
                    {
                        if (el != null)
                        {
                            List <Room> rooms = FinishingData.GetCollidedRooms(el);
                            foreach (Room r in rooms)
                            {
                                FinishingData.Calculate(r);
                            }
                        }
                        else
                        {
                            foreach (Room r in new FilteredElementCollector(Document, Document.ActiveView.Id).OfCategory(BuiltInCategory.OST_Rooms).Cast <Room>())
                            {
                                FinishingData.Calculate(r);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                    Debug.WriteLine("Addition/Modification error: id " + id.IntegerValue.ToString());
                }
            }
            if (deleted.Count > 0)
            {
                try
                {
                    foreach (Room r in new FilteredElementCollector(Document, Document.ActiveView.Id).OfCategory(BuiltInCategory.OST_Rooms).Cast <Room>())
                    {
                        FinishingData.Calculate(r);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                    Debug.WriteLine("Deletion error");
                }
            }
        }
Esempio n. 2
0
 public override void GlobalExecute(Document doc)
 {
     foreach (Room r in new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).Cast <Room>())
     {
         FinishingData.Calculate(r);
         FinishingData.AggregateFloors(r);
     }
 }