Esempio n. 1
0
        /// <summary>
        /// Reset prefix values on all elements visible on current view
        /// </summary>
        public static void reset()
        {
            List <BuiltInCategory> allBuiltinCategories = FabCategories.listCat();

            LogicalOrFilter logicalOrFilter = new LogicalOrFilter(MEPCategories.listCat());

            var collector = new FilteredElementCollector(tools.doc, tools.doc.ActiveView.Id).WherePasses(
                logicalOrFilter).WhereElementIsNotElementType();

            using (Transaction ResetView = new Transaction(tools.uidoc.Document, "Reset view"))
            {
                ResetView.Start();
                OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings();
                Guid   guid         = new Guid("460e0a79-a970-4b03-95f1-ac395c070beb");
                string blankPrtnmbr = "";
                foreach (var item in collector.ToElements())
                {
                    item.get_Parameter(guid).Set(blankPrtnmbr);
                    Category        category     = item.Category;
                    BuiltInCategory enumCategory = (BuiltInCategory)category.Id.IntegerValue;
                    if (allBuiltinCategories.Contains(enumCategory))
                    {
                        item.get_Parameter(BuiltInParameter.FABRICATION_PART_ITEM_NUMBER).Set(blankPrtnmbr);
                    }
                }

                ResetView.Commit();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Override colors in view by prefix
        /// </summary>
        public static void ColorInView()
        {
            using (Transaction ResetView = new Transaction(tools.uidoc.Document, "Reset view"))
            {
                ResetView.Start();
                OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings();

                LogicalOrFilter logicalOrFilter = new LogicalOrFilter(MEPCategories.listCat());

                var collector = new FilteredElementCollector(tools.doc, tools.doc.ActiveView.Id).WherePasses(
                    logicalOrFilter).WhereElementIsNotElementType();

                Dictionary <Element, string> elemtNPrefix = new Dictionary <Element, string>();
                Dictionary <string, Color>   colorNPrefix = new Dictionary <string, Color>();

                //Create a Dictionary with Elements and its prefixes
                foreach (var item in collector.ToElements())
                {
                    var number     = tools.getNumber(item);
                    var itemNumber = tools.GetNumberAndPrexif(number);
                    if (itemNumber != null)
                    {
                        elemtNPrefix.Add(item, itemNumber.Item1);
                    }
                }

                //Create a unique prefixes and an assigned color
                foreach (var prefix in elemtNPrefix.Values.Distinct())
                {
                    //Chanchada
                    System.Threading.Thread.Sleep(50);
                    Random randonGen   = new Random();
                    Color  randomColor = Color.FromArgb(1, randonGen.Next(255), randonGen.Next(255), randonGen.Next(255));
                    colorNPrefix.Add(prefix, randomColor);
                }

                //Override colors following the already created schema of colors
                foreach (var item in elemtNPrefix)
                {
                    #if REVIT2020 || REVIT2019
                    OverrideElemtColor.Graphics20192020(tools.uidoc.Document, ref overrideGraphicSettings, colorNPrefix[item.Value].R, colorNPrefix[item.Value].G, colorNPrefix[item.Value].B);
                    #else
                    OverrideElemtColor.Graphics20172020(tools.uidoc.Document, ref overrideGraphicSettings, colorNPrefix[item.Value].R, colorNPrefix[item.Value].G, colorNPrefix[item.Value].B);
                    #endif

                    tools.doc.ActiveView.SetElementOverrides(item.Key.Id, overrideGraphicSettings);
                }

                ResetView.Commit();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Reset prefix values on all elements visible on current view
        /// </summary>
        public static void reset()
        {
            var            selection = tools.uidoc.Selection.GetElementIds();
            List <Element> collector = new List <Element>();

            if (selection != null && selection.Count > 0)
            {
                foreach (var item in selection)
                {
                    collector.Add(tools.uidoc.Document.GetElement(item));
                }
            }
            else
            {
                LogicalOrFilter logicalOrFilter = new LogicalOrFilter(MEPCategories.listCat());
                collector = new FilteredElementCollector(tools.doc, tools.doc.ActiveView.Id).WherePasses(
                    logicalOrFilter).WhereElementIsNotElementType().ToElements().ToList();
            }

            using (Transaction ResetView = new Transaction(tools.uidoc.Document, "Reset view"))
            {
                ResetView.Start();
                OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings();
                Guid   guid         = new Guid("460e0a79-a970-4b03-95f1-ac395c070beb");
                string blankPrtnmbr = "";
                foreach (var item in collector)
                {
                    Parameter param = item.get_Parameter(guid);
                    if (param is null)
                    {
                        param = item.get_Parameter(BuiltInParameter.FABRICATION_PART_ITEM_NUMBER);
                    }
                    param.Set(blankPrtnmbr);
                }

                ResetView.Commit();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Resets override on all elements in current view
        /// </summary>
        public static void reset()
        {
            using (Transaction ResetView = new Transaction(tools.uidoc.Document, "Reset view"))
            {
                ResetView.Start();
                OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings();

                LogicalOrFilter logicalOrFilter = new LogicalOrFilter(MEPCategories.listCat());

                var collector = new FilteredElementCollector(tools.doc, tools.doc.ActiveView.Id).WherePasses(
                    logicalOrFilter).WhereElementIsNotElementType();

                foreach (var item in collector.ToElements())
                {
                    if (item.IsValidObject && tools.doc.GetElement(item.Id) != null)
                    {
                        tools.doc.ActiveView.SetElementOverrides(item.Id, overrideGraphicSettings);
                    }
                }

                ResetView.Commit();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Resets override on all elements in current view
        /// </summary>
        public static void reset()
        {
            using (Transaction ResetView = new Transaction(tools.uidoc.Document, "Reset view"))
            {
                ResetView.Start();
                OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings();

                var selection = tools.uidoc.Selection.GetElementIds();
                List <ElementId> collector = new List <ElementId>();
                if (selection != null && selection.Count > 0)
                {
                    foreach (var item in selection)
                    {
                        collector.Add(item);
                    }
                }

                else
                {
                    LogicalOrFilter logicalOrFilter = new LogicalOrFilter(MEPCategories.listCat());
                    collector = new FilteredElementCollector(tools.doc, tools.doc.ActiveView.Id).WherePasses(
                        logicalOrFilter).WhereElementIsNotElementType().ToElementIds().ToList();
                }


                foreach (var item in collector)
                {
                    if (tools.doc.GetElement(item) != null)
                    {
                        tools.doc.ActiveView.SetElementOverrides(item, overrideGraphicSettings);
                    }
                }

                ResetView.Commit();
            }
        }