Esempio n. 1
0
        public ElementPropertiesWrapper(Document revitDoc)
        {
            // Get single timestamp to apply to all elements this query
            DateTime datestampUtc = DateTime.UtcNow;

            // Get all elements:
            IEnumerable<Element> allElements = new FilteredElementCollector(revitDoc)
                .WhereElementIsNotElementType()
                .ToElements()
                .Where(e => e.Name != string.Empty);

            // Project Info

            foreach (Element e in allElements)
            {
                ElementProps props = new ElementProps(e);
                props.RevitFileTimeStampUtc = datestampUtc;                
                
                // Collect the element:
                m_model_elements.Add(props);
            }



        }
        //public long CadImportCount { get; private  set; }
        //public long CadLinkCount { get; private set; }

        //Constructor
        public ElementPropertiesWrapper(Document revitDoc)
        {
            // Get single timestamp to apply to all elements this query
            RevitFileTimeStampUtc = DateTime.UtcNow;
            FileTimeStampCounter  = UtcDateTimeToUnix(RevitFileTimeStampUtc);

            RevitFilePath = revitDoc.PathName;

            IsBim360Model = revitDoc.IsModelInCloud;
            ProjectNumber = revitDoc.ProjectInformation.Number;
            ProjectName   = revitDoc.ProjectInformation.Name;
            FileVersion   = revitDoc.Application.VersionNumber;

            if (!IsBim360Model)
            {
                FileInfo fi = new FileInfo(revitDoc.PathName);
                FileSize = fi.Length / 1024;
            }
            else
            {
                FileSize = null;
            }

            try
            {
                if (IsBim360Model)
                {
                    ModelPath mp = revitDoc.GetCloudModelPath();
                    ModelGuid         = mp.GetModelGUID();
                    ProjectGuid       = mp.GetProjectGUID();
                    CentralServerPath = mp.CentralServerPath;
                    CloudPath         = mp.CloudPath;
                    ServerPath        = mp.ServerPath;
                }
            }
            catch (Exception ex)
            {
                CentralServerPath = null;
                CloudPath         = false;
                ServerPath        = false;
            }

            WarningsCount = revitDoc.GetWarnings().Count;

            // Get ALL elements:
            IEnumerable <Element> allElements = new FilteredElementCollector(revitDoc)
                                                .WhereElementIsNotElementType()
                                                .ToElements()
                                                .Where(e => e.Name != string.Empty)
                                                .Where(c => null != c.Category)
                                                .Where(c => !c.Category.Name.Contains("Sketch"));


            this.ElementCount = allElements.Count();


            foreach (Element e in allElements)
            {
                ElementProps props = new ElementProps(e);

                // Collect the element:
                m_model_elements.Add(props);
            }

            // ROOMS
            List <SpatialElement> rms = new FilteredElementCollector(revitDoc)
                                        .OfClass(typeof(SpatialElement))
                                        .Cast <SpatialElement>()
                                        .ToList <SpatialElement>();

            if (rms.Count > 0)
            {
                foreach (SpatialElement se in rms)
                {
                    Room r = se as Room;
                    if (null != r)
                    {
                        m_model_rooms.Add(new RevitRoom(r));
                    }
                }
            }
            this.RoomCount = m_model_rooms.Count;

            // VIEWS
            List <View> vws = new FilteredElementCollector(revitDoc)
                              .OfClass(typeof(View))
                              .Cast <View>()
                              .ToList <View>();

            foreach (View v in vws)
            {
                m_model_views.Add(new RevitView(v));
            }
        }