Пример #1
0
        /// <summary>
        ///   Metodo che riempie le liste con i CODICI TIPOLOGIA
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="uiapp">L'oggetto Applicazione di Revit</param>m>
        ///
        private void GetListPTI(UIApplication uiapp, List <Element> elements)
        {
            List <string[]> stringsList = new List <string[]>();
            List <string>   tempPTI     = new List <string>();
            List <string>   newPTI      = new List <string>();
            List <string>   listColors  = ColorsDrawing.GetColors();

            var listTemp = new List <string[]>();

            foreach (Element el in elements)
            {
                ElementId   eTypeId = el.GetTypeId();
                ElementType eType   = uiapp.ActiveUIDocument.Document.GetElement(eTypeId) as ElementType;

                //string pti = PickPanelTypeIdentifier(uiapp, el);
                string pti = PickCodeTypologie(uiapp, el);

                if (pti != null && !pti.Contains("xx") && eType != null)
                {
                    tempPTI.Add(pti);
                }
            }

            // Li ordina in modo ascendente
            tempPTI.OrderBy(x => x);

            // Li raggruppa
            var group = tempPTI.GroupBy(pti => pti);


            // Assegna il colore e assegna i valori alla lista di stringhe[]
            int i = 0;

            foreach (var item in group)
            {
                for (int j = 2000; j < listColors.Count; j++)
                {
                    if (i == (j - 2000))
                    {
                        stringsList.Add(new[] { item.Key, Convert.ToString(item.Count()), listColors[j] });
                    }
                }
                i++;
            }

            _listPTI = stringsList;
        }
Пример #2
0
        /// <summary>
        ///   Metodo che riempie le liste con i CODICI POSIZIONALI
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="uiapp">L'oggetto Applicazione di Revit</param>m>
        ///
        private void GetListUTI(UIApplication uiapp, List <Element> elements)
        {
            List <string[]> stringsList = new List <string[]>();
            List <string>   tempUTI     = new List <string>();
            List <string>   newUTI      = new List <string>();
            List <string>   listColors  = ColorsDrawing.GetColors();

            foreach (Element el in elements)
            {
                ElementId   eTypeId = el.GetTypeId();
                ElementType eType   = uiapp.ActiveUIDocument.Document.GetElement(eTypeId) as ElementType;

                string uti = PickUnitTypeIdentifier(uiapp, el);

                if (!uti.Contains("xx") && eType != null)
                {
                    tempUTI.Add(uti);
                }
            }
            // Rimuove i duplicati
            newUTI = RemoveDuplicates(tempUTI);
            // Li ordina in modo ascendente
            newUTI.OrderBy(x => x);

            // Riempie la stringlist con i valori corrispondenti
            for (int i = 0; i < newUTI.Count; i++)
            {
                for (int j = 0; j < listColors.Count; j++)
                {
                    if (i == j)
                    {
                        stringsList.Add(new[] { newUTI[i], listColors[j] });
                    }
                }
            }

            _listUTI = stringsList;
        }