コード例 #1
0
        private Flat GetFlatBySectionAndFlatNumber(string sectionNumber, string flatNumber)
        {
            Flat flat = this.Flats.FirstOrDefault((Flat f) => f.SectionNumber == sectionNumber && f.FlatNumber == flatNumber);

            if (flat == null)
            {
            }
            return(flat);
        }
コード例 #2
0
        public bool ScanProject(Document document)
        {
            bool result = true;

            this.document = document;
            this.Flats.Clear();
            FilteredElementCollector filteredElementCollector = new FilteredElementCollector(document);
            RoomFilter roomFilter = new RoomFilter();

            filteredElementCollector.WherePasses(roomFilter);
            using (IEnumerator <Element> enumerator = filteredElementCollector.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Room      room      = (Room)enumerator.Current;
                    Parameter parameter = room.get_Parameter(new Guid(Converter.FlatNumber
                                                                      ));
                    Parameter parameter2 = room.get_Parameter(new Guid(Converter.SectionNumber
                                                                       ));
                    if (parameter.HasValue)
                    {
                        string flatNumber = parameter.AsString();
                        string text       = parameter2.HasValue ? parameter2.AsString() : "";
                        if (!this.Sections.Contains(text))
                        {
                            this.Sections.Add(text);
                        }
                        Flat flat = this.GetFlatBySectionAndFlatNumber(text, flatNumber);
                        if (flat == null)
                        {
                            Parameter parameter3 = room.get_Parameter(new Guid(Converter.FlatInd));
                            string    flatIndex  = parameter3.HasValue ? parameter3.AsString() : "";
                            Parameter parameter4 = room.get_Parameter(new Guid(Converter.FlatTypeIndex));
                            FlatType  type       = (FlatType)parameter4.AsInteger();
                            flat           = new Flat(document, flatNumber, text);
                            flat.FlatIndex = flatIndex;
                            flat.Type      = type;
                            this.Flats.Add(flat);
                        }
                        flat.AddRoom(room);
                    }
                }
            }
            using (Transaction transaction = new Transaction(document))
            {
                transaction.Start("Update flats");
                foreach (Flat current in this.Flats)
                {
                    if (current.FlatIndex == String.Empty && current.FlatNumber == String.Empty && current.SectionNumber == String.Empty)
                    {
                        continue;
                    }
                    current.FlatCalculate();
                }
                transaction.Commit();
            }
            //if (filteredElementCollector.Count<Element>() == 0)
            //{
            //    this.FlatsRefreshed(this, new FlatsRefreshedEventArg
            //    {
            //        Document = document,
            //        UpdatedFlats = this.Flats
            //    });
            //}

            return(result);
        }