コード例 #1
0
        /// <summary>
        /// Assing number to element
        /// </summary>
        /// <param name="element"></param>
        /// <param name="partNumber"></param>
        public static void AssingPartNumber(Element element, string partNumber)
        {
            Category               category             = element.Category;
            BuiltInCategory        enumCategory         = (BuiltInCategory)category.Id.IntegerValue;
            List <BuiltInCategory> allBuiltinCategories = FabricationCategories();

            if (allBuiltinCategories.Contains(enumCategory))
            {
                try
                {
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_ITEM_NUMBER).Set(partNumber);
                    ListOfElements.Add(element);
                    ActualCounter = partNumber;
                    uidoc.RefreshActiveView();
                    uidoc.Selection.SetElementIds(new List <ElementId>()
                    {
                        element.Id
                    });
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
            }

            else
            {
                Guid guid = new Guid("460e0a79-a970-4b03-95f1-ac395c070beb");
                element.get_Parameter(guid).Set(partNumber);
                ListOfElements.Add(element);
                uidoc.Selection.SetElementIds(new List <ElementId>()
                {
                    element.Id
                });
            }
        }
コード例 #2
0
    public ListOfElements Clone()
    {
        var clone = new ListOfElements();

        clone.AddRange(this);
        return(clone);
    }
コード例 #3
0
        //sortowanie elementów po cena / waga
        public void bubblesort(ListOfElements list)
        {
            
            bool koniec = false;
            ListOfElements pivot = new ListOfElements();
            pivot.Add(new Element(0, 0));

            for (int i = 0; i < list.Count; i++)
            {
                koniec = true;
                for (int j = 1; j < list.Count; j++)
                {
                    if (list[j - 1].price / list[j - 1].weight < list[j].price / list[j].weight)
                    {
                        pivot[0].price = list[j].price;
                        pivot[0].weight = list[j].weight;

                        list[j].price = list[j - 1].price;
                        list[j].weight = list[j - 1].weight;

                        list[j - 1].price = pivot[0].price;
                        list[j - 1].weight = pivot[0].weight;

                        koniec = false;
                    }
                }

                if (koniec == true)
                    break;
            }
                        
            LOE = list;
        }
コード例 #4
0
        public static void filterParam(Element elementEx, Autodesk.Revit.DB.BuiltInCategory Cat, BuiltInParameter param01, BuiltInParameter param02,
                                       BuiltInParameter param03, BuiltInParameter param04, BuiltInParameter param05)
        {
            string elemParam01 = elementEx.get_Parameter(param01).AsValueString();
            string elemParam02 = elementEx.get_Parameter(param02).AsValueString();
            string elemParam03 = elementEx.get_Parameter(param03).AsValueString();
            string elemParam04 = elementEx.get_Parameter(param04).AsValueString();
            string elemParam05 = elementEx.get_Parameter(param05).AsValueString();

            FilteredElementCollector viewCollector = new FilteredElementCollector(doc, uidoc.ActiveView.Id);
            List <Element>           ducts         = new FilteredElementCollector(doc, uidoc.ActiveView.Id)
                                                     .OfCategory(Cat)
                                                     .Where(a => a.get_Parameter(param01).AsValueString() == elemParam01)
                                                     .Where(a => a.get_Parameter(param02).AsValueString() == elemParam02)
                                                     .Where(a => a.get_Parameter(param03).AsValueString() == elemParam03)
                                                     .Where(a => a.get_Parameter(param04).AsValueString() == elemParam04)
                                                     .Where(a => a.get_Parameter(param05).AsValueString() == elemParam05)
                                                     .ToList();

            foreach (Element x in ducts)
            {
                selectedElements.Add(x);
                ListOfElements.Add(x);
            }
        }
コード例 #5
0
        public static void UseFilesAndFoldersHelper_GetMultipleFiles_action(string pRootFolder, string pOutputResult)
        {
            ListOfElements <string> loes =
                ListOfElements <string> .CreateListOfElements <string>((x) => x, (x) => x);

            FileAndFolderService ffs  = new FileAndFolderService();
            List <IFileOrFolder> list = ffs.GetListOfFilesAndFolders(pRootFolder,
                                                                     ElementSelection.file);

            list.Sort(fafh.File.CompareByNameAndDirectory);

            int countDuplicates = 0;

            for (int i = 1; i < list.Count; i++)
            {
                if (Path.GetFileName(list[i - 1].FullName) == Path.GetFileName(list[i].FullName))
                {
                    loes.TheList.Add(list[i - 1].FullName);
                    loes.TheList.Add(list[i].FullName);
                    countDuplicates++;
                }
            }

            Console.WriteLine(countDuplicates);
            loes.WriteToFile(pOutputResult);
        }
コード例 #6
0
        //sortuje po cenie, od najdrożyszej do najtańszej
        public ListOfElements bubblesort_max_price(ListOfElements list)
        {
            bool koniec = false;
            ListOfElements pivot = new ListOfElements();
            pivot.Add(new Element(0, 0));

            for (int i = 0; i < list.Count; i++)
            {
                koniec = true;
                for (int j = 1; j < list.Count; j++)
                {
                    if (list[j - 1].price < list[j].price)
                    {
                        pivot[0] = list[j - 1];

                        list[j - 1] = list[j];

                        list[j] = pivot[0];
                        koniec = false;
                    }
                }
                if (koniec == true)
                    break;

            }
            return list;
        }
コード例 #7
0
        public static void ReadWriteList()
        {
            ListOfElements <string> loe =
                ListOfElements <string> .CreateListOfElements <string>((x) => x, (x) => x);

            loe.ReadFromFile(@"E:\Temp\ToDelete\file1.txt");
            loe.TheList.Add("tititi");
            loe.WriteToFile(@"E:\Temp\ToDelete\file11.txt");
        }
コード例 #8
0
 ///<summary> algorytm zachłanny zwracający załadowany plecak przez elementy od najlżejszych </summary>
 public void n_element_min_weight()
 {
     LOE = this.bubblesort_min_weight(LOE);
     for(int i = 0; i < LOE.Count; i++)
     {
         while (backpack_space_left(LOE[i]) == true)
         {
             BP.Add(LOE[i]);
             backpackSpaceLeft -= LOE[i].weight;
         }
         if (backpackSpaceLeft == 0)
             break;
     }
 }
コード例 #9
0
 /// <summary>
 /// algorytm zachłanny po cenie max,
 /// odejmuje elementy z listy
 /// </summary>
 public void r_element_max_price()
 {
     LOE = this.bubblesort_max_price(LOE);
     for (int i = 0; i < LOE.Count; i++)
     {
         while (backpack_space_left(LOE[i]) == true || LOE[i].elementCount > 0)
         {
             BP.Add(LOE[i]);
             backpackSpaceLeft -= LOE[i].weight;
             LOE[i].elementCount--;
         }
         if (backpackSpaceLeft <= 0)
             break;
     }
 }
コード例 #10
0
        /// <summary>
        /// Save an element on a temporary list and override its color
        /// </summary>
        public static void AddToSelection(bool duplicated)
        {
            selectedElements.Clear();

            var filterS = new SelectionFilter();

            var refElement = uidoc.Selection.PickObject(ObjectType.Element, new SelectionFilter());

            if (refElement != null)
            {
                var element = uidoc.Document.GetElement(refElement);

                if (duplicated)
                {
                    selectedElements.AddRange(GetallElementsDuplicated(element));
                }
                selectedElements.Add(element);

                //TODO: check if element is from the right category
                OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings();
                Color colorSelect = MainForm.ColorSelected;

                //Split coloSelect in R,G,B to be transformed to a Revit color later
                byte r = colorSelect.R;
                byte g = colorSelect.G;
                byte b = colorSelect.B;


                #if REVIT2020
                OverrideElemtColor.Graphics20192020(doc, ref overrideGraphicSettings, r, g, b);
                #elif REVIT2019
                OverrideElemtColor.Graphics20172020(doc, ref overrideGraphicSettings, r, g, b);
                #endif


                foreach (Element x in selectedElements)
                {
                    //Override color of element
                    doc.ActiveView.SetElementOverrides(x.Id, overrideGraphicSettings);
                }

                selectedElement = element;

                //Add element to the temporary list of selected elemenents
                ListOfElements.Add(element);
            }
        }
コード例 #11
0
        /// <summary>
        /// Sequential call of methods to transform and calculate the result of an expression.
        /// </summary>
        /// <param name="expression">Expression to evaluate.</param>
        private void ParseExpression(string expression)
        {
            var mathExpression = new MathExpression(expression);

            if (!mathExpression.IsValid)
            {
                return;
            }

            var listOfElements          = new ListOfElements(mathExpression);
            var rpnExpression           = new RpnExpression(listOfElements);
            var rpnCalculationAlgorithm = new RpnCalculationAlgorithm(rpnExpression);

            if (rpnCalculationAlgorithm.IsValid)
            {
                _result = rpnCalculationAlgorithm.Result;
            }
        }
コード例 #12
0
        /// <summary>
        /// Save an element on a temporary list and override its color
        /// </summary>
        public static void AddToSelection()
        {
            selectedElements.Clear();

            var filterS = new SelectionFilter();

            var refElement = uidoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, new SelectionFilter());

            if (refElement != null)
            {
                var element = uidoc.Document.GetElement(refElement);

                Category        category     = element.Category;
                BuiltInCategory enumCategory = (BuiltInCategory)category.Id.IntegerValue;


                //Check for other rectangular ducts with the same parameters
                if (enumCategory.ToString() == "OST_DuctCurves" &&
                    element.get_Parameter(BuiltInParameter.RBS_CURVE_DIAMETER_PARAM)?.AsValueString() == null)
                {
                    filterParam(element, Autodesk.Revit.DB.BuiltInCategory.OST_DuctCurves, BuiltInParameter.RBS_DUCT_SYSTEM_TYPE_PARAM, BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM, BuiltInParameter.CURVE_ELEM_LENGTH,
                                BuiltInParameter.RBS_CURVE_WIDTH_PARAM, BuiltInParameter.RBS_CURVE_HEIGHT_PARAM);
                }

                //Check for other ducts fittings with the same parameters
                if (enumCategory.ToString() == "OST_DuctFitting" &&
                    element.get_Parameter(BuiltInParameter.RBS_CURVE_DIAMETER_PARAM)?.AsValueString() == null)
                {
                    string elemParam01 = element.get_Parameter(BuiltInParameter.RBS_SYSTEM_CLASSIFICATION_PARAM).AsValueString();
                    string elemParam02 = element.get_Parameter(BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM).AsValueString();
                    string elemParam03 = element.get_Parameter(BuiltInParameter.RBS_REFERENCE_FREESIZE).AsString();
                    string elemParam04 = element.get_Parameter(BuiltInParameter.RBS_REFERENCE_OVERALLSIZE).AsString();
                    string elemParam05 = element.get_Parameter(BuiltInParameter.RBS_CALCULATED_SIZE).AsString();

                    FilteredElementCollector viewCollector = new FilteredElementCollector(doc, uidoc.ActiveView.Id);
                    List <Element>           ducts         = new FilteredElementCollector(doc, uidoc.ActiveView.Id)
                                                             .OfCategory(Autodesk.Revit.DB.BuiltInCategory.OST_DuctFitting)
                                                             .Where(a => a.get_Parameter(BuiltInParameter.RBS_SYSTEM_CLASSIFICATION_PARAM).AsValueString() == elemParam01)
                                                             .Where(a => a.get_Parameter(BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM).AsValueString() == elemParam02)
                                                             .Where(a => a.get_Parameter(BuiltInParameter.RBS_REFERENCE_FREESIZE).AsString() == elemParam03)
                                                             .Where(a => a.get_Parameter(BuiltInParameter.RBS_REFERENCE_OVERALLSIZE).AsString() == elemParam04)
                                                             .Where(a => a.get_Parameter(BuiltInParameter.RBS_CALCULATED_SIZE).AsString() == elemParam05)
                                                             .ToList();

                    foreach (Element x in ducts)
                    {
                        selectedElements.Add(x);
                        ListOfElements.Add(x);
                    }
                }


                bool boolTest = false;

                var familyTypee = element.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString();
                if (familyTypee.Contains("Bend"))
                {
                    boolTest = true;
                }


                bool TapTest = false;

                var familyTapType = element.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString();
                if (familyTapType.Contains("Tap"))
                {
                    TapTest = true;
                }


                //Check for other round ducts with the same parameters
                if (enumCategory.ToString() == "OST_DuctCurves" &&
                    element.get_Parameter(BuiltInParameter.RBS_CURVE_DIAMETER_PARAM)?.AsValueString() != null &&
                    TapTest != true)
                {
                    filterParam(element, Autodesk.Revit.DB.BuiltInCategory.OST_DuctCurves, BuiltInParameter.RBS_DUCT_SYSTEM_TYPE_PARAM, BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM, BuiltInParameter.CURVE_ELEM_LENGTH,
                                BuiltInParameter.RBS_CURVE_SURFACE_AREA, BuiltInParameter.RBS_CURVE_DIAMETER_PARAM);
                }

                //Check for other rectangular fab ducts with the same parameters
                if (enumCategory.ToString() == "OST_FabricationDuctwork" &&
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_ANGLE)?.AsValueString() == null &&
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_DIAMETER_IN)?.AsValueString() == null &&
                    element.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM)?.AsValueString() != "Generic Square Bend" &&
                    TapTest != true)
                {
                    filterParam(element, Autodesk.Revit.DB.BuiltInCategory.OST_FabricationDuctwork, BuiltInParameter.ELEM_FAMILY_PARAM, BuiltInParameter.FABRICATION_PART_LENGTH, BuiltInParameter.FABRICATION_PART_DEPTH_IN,
                                BuiltInParameter.FABRICATION_PART_WIDTH_IN, BuiltInParameter.FABRICATION_SERVICE_PARAM);
                }


                //Check for other rectangular fab ducts fittings of angle 90 with the same parameters
                //if (enumCategory.ToString() == "OST_FabricationDuctwork"
                //    && element.get_Parameter(BuiltInParameter.FABRICATION_PART_ANGLE)?.AsValueString() == null
                //    && element.get_Parameter(BuiltInParameter.FABRICATION_PART_DIAMETER_IN)?.AsValueString() == null
                //    && element.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM)?.AsValueString() == "Generic Square Bend"
                //    )

                //{
                //    filterParam(element, Autodesk.Revit.DB.BuiltInCategory.OST_FabricationDuctwork, BuiltInParameter.ELEM_FAMILY_PARAM, BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM, BuiltInParameter.FABRICATION_PART_DEPTH_IN,
                //      BuiltInParameter.FABRICATION_PART_WIDTH_IN, BuiltInParameter.FABRICATION_SERVICE_PARAM);
                //}



                //Check for other rectangular fab ducts fittings of angle 90 with the same parameters
                if (enumCategory.ToString() == "OST_FabricationDuctwork" &&
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_ANGLE)?.AsValueString() == null &&
                    boolTest == true &&
                    TapTest != true
                    )
                {
                    filterParam(element, Autodesk.Revit.DB.BuiltInCategory.OST_FabricationDuctwork, BuiltInParameter.ELEM_FAMILY_PARAM, BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM, BuiltInParameter.FABRICATION_PART_DEPTH_IN,
                                BuiltInParameter.FABRICATION_PART_WIDTH_IN, BuiltInParameter.FABRICATION_SERVICE_PARAM);
                }


                //Check for other rectangular fab ducts fittings with the same parameters
                if (enumCategory.ToString() == "OST_FabricationDuctwork" &&
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_ANGLE)?.AsValueString() != null &&
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_DIAMETER_IN)?.AsValueString() == null
                    )
                {
                    filterParam(element, Autodesk.Revit.DB.BuiltInCategory.OST_FabricationDuctwork, BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM, BuiltInParameter.FABRICATION_PART_ANGLE, BuiltInParameter.FABRICATION_SERVICE_PARAM,
                                BuiltInParameter.FABRICATION_PART_DEPTH_IN, BuiltInParameter.FABRICATION_PART_WIDTH_IN);
                }

                //Check for other rectangular fab ducts fittings with the same parameters
                if (enumCategory.ToString() == "OST_FabricationDuctwork" &&
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_ANGLE)?.AsValueString() != null &&
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_DIAMETER_IN)?.AsValueString() != null
                    )
                {
                    filterParam(element, Autodesk.Revit.DB.BuiltInCategory.OST_FabricationDuctwork, BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM, BuiltInParameter.FABRICATION_PART_ANGLE, BuiltInParameter.FABRICATION_SERVICE_PARAM,
                                BuiltInParameter.FABRICATION_PART_DIAMETER_IN, BuiltInParameter.RBS_REFERENCE_OVERALLSIZE);
                }

                //Check for other round fab ducts with the same parameters
                if (enumCategory.ToString() == "OST_FabricationDuctwork" &&
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_ANGLE)?.AsValueString() == null &&
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_DIAMETER_IN)?.AsValueString() != null &&
                    TapTest != true
                    )
                {
                    filterParam(element, Autodesk.Revit.DB.BuiltInCategory.OST_FabricationDuctwork, BuiltInParameter.ELEM_FAMILY_PARAM, BuiltInParameter.FABRICATION_PART_LENGTH, BuiltInParameter.FABRICATION_PART_DIAMETER_IN,
                                BuiltInParameter.FABRICATION_PART_SHEETMETAL_AREA, BuiltInParameter.FABRICATION_SERVICE_PARAM);
                }


                //Check for other round fab ducts with the same parameters
                if (enumCategory.ToString() == "OST_FabricationDuctwork" &&
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_ANGLE)?.AsValueString() == null &&
                    element.get_Parameter(BuiltInParameter.FABRICATION_PART_DIAMETER_IN)?.AsValueString() != null &&
                    TapTest == true
                    )
                {
                    filterParam(element, Autodesk.Revit.DB.BuiltInCategory.OST_FabricationDuctwork, BuiltInParameter.ELEM_FAMILY_PARAM, BuiltInParameter.FABRICATION_PART_LENGTH, BuiltInParameter.FABRICATION_PART_DIAMETER_IN,
                                BuiltInParameter.RBS_REFERENCE_OVERALLSIZE, BuiltInParameter.FABRICATION_SERVICE_PARAM);
                }

                selectedElements.Add(element);

                //TODO: check if element is from the right category
                OverrideGraphicSettings overrideGraphicSettings = new OverrideGraphicSettings();
                Color colorSelect = MainForm.ColorSelected;

                //Split coloSelect in R,G,B to be transformed to a Revit color later
                byte r = colorSelect.R;
                byte b = colorSelect.B;
                byte g = colorSelect.G;

                //Set override properties to fill and line colors
                overrideGraphicSettings.SetProjectionFillColor(new Autodesk.Revit.DB.Color(r, g, b));
                overrideGraphicSettings.SetProjectionLineColor(new Autodesk.Revit.DB.Color(r, g, b));

                foreach (Element x in selectedElements)
                {
                    //Override color of element
                    doc.ActiveView.SetElementOverrides(x.Id, overrideGraphicSettings);
                }

                selectedElement = element;

                //Add element to the temporary list of selected elemenents
                ListOfElements.Add(element);
            }
        }
コード例 #13
0
 public void OnSelected()
 {
     ListOfElements.OnSelectedObject(this);
     ButtonCommand.Execute(Text);
 }
コード例 #14
0
 public void OnSelected(T selected)
 {
     ListOfElements.OnSelectedObject(selected);
 }
コード例 #15
0
 public Thief(ListOfElements list, int backpackSize)
 {
     LOE = list;
     this.backpackSize = backpackSize;
     backpackSpaceLeft = backpackSize;
 }