//FUNCTION FOR FLOOR
        public void FloorSelector(string activityDescription)
        {
            Nw.ModelItem       modelParent            = modelItem.Parent;
            List <ElementData> TempListofSafetyIssues = new List <ElementData>();
            ElementData        eachElementData        = new ElementData();

            eachElementData.EleStartDate  = new DateTime();
            eachElementData.EleEndDate    = new DateTime();
            eachElementData.ProtStartDate = new DateTime();
            eachElementData.ProtEndDate   = new DateTime();

            Nw.PropertyCategoryCollection innerpropCatCollection = modelParent.PropertyCategories;

            eachElementData.ActivityName = activityDescription;
            eachElementData.ElementType  = "Floor";
            eachElementData.Hazard       = "Working at height";
            eachElementData.Protection   = "See general guidelines for Construction of Floors at height";

            //get element level and elevation
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Level" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Elevation") &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Name"))
                {
                    //elevation is returned in feet and not as double
                    elevation = innerpropCat.Properties.FindPropertyByDisplayName("Elevation").Value.ToDoubleLength();
                    elevation = elevation * (double)0.3048;

                    eachElementData.Elevation = elevation;
                    eachElementData.Level     = innerpropCat.Properties.FindPropertyByDisplayName("Name").Value.ToString();
                    eachElementData.Level     = eachElementData.Level.Substring(eachElementData.Level.IndexOf(":") + 1);
                    break;
                }
            }

            //get element start date and end date
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "TimeLiner" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Contained in Task Start (Planned):1") &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Contained in Task End (Planned):1"))
                {
                    eachElementData.EleStartDate = (DateTime)innerpropCat.Properties
                                                   .FindPropertyByDisplayName("Contained in Task Start (Planned):1").Value.ToDateTime();
                    eachElementData.EleEndDate = (DateTime)innerpropCat.Properties
                                                 .FindPropertyByDisplayName("Contained in Task End (Planned):1").Value.ToDateTime();
                    break;
                }
            }
            eachElementData.ProtStartDate = eachElementData.EleStartDate;
            eachElementData.ProtEndDate   = eachElementData.EleEndDate;

            TempListofSafetyIssues.Add(eachElementData);

            Result.ListofSafetyIssues.AddRange(TempListofSafetyIssues);
        }
Example #2
0
        //code for window
        public DateTime WallOperations(string elementID)
        {
            List <DateTime> ListWindowStartDate = new List <DateTime>();
            string          caTegory, elementInfo = null;
            DateTime        StartDate       = new DateTime();
            DateTime        returnStartDate = new DateTime();

            //open the active document and get model items
            foreach (Nw.ModelItem modelItem in Nw.Application.ActiveDocument.Models.RootItemDescendantsAndSelf)
            {
                //loop through the ancestors of the element to find properties in case of family element
                foreach (Nw.ModelItem modelAncestors in modelItem.Ancestors)
                {
                    if (modelItem.HasGeometry)
                    {
                        //select all the property categories of the parent element
                        Nw.PropertyCategoryCollection propCatCollection = modelAncestors.PropertyCategories;

                        //check for the element type to be windows by iterating through property categories
                        foreach (Nw.PropertyCategory propCat in propCatCollection)
                        {
                            if (propCat.DisplayName.ToString() == "Element" && null != propCat.Properties.FindPropertyByDisplayName("Category"))
                            {
                                caTegory = propCat.Properties.FindPropertyByDisplayName("Category").Value.ToString();
                                caTegory = caTegory.Substring(caTegory.IndexOf(":") + 1);

                                if (caTegory == "Windows")
                                {
                                    Nw.PropertyCategoryCollection innerpropCatCollection = modelAncestors.PropertyCategories;

                                    // for windows found check for the Shared parameter input from revit
                                    foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
                                    {
                                        if (innerpropCat.DisplayName.ToString() == "Element" &&
                                            null != innerpropCat.Properties.FindPropertyByDisplayName("ElementInfo"))
                                        {
                                            elementInfo = innerpropCat.Properties.FindPropertyByDisplayName("ElementInfo").Value.ToString();
                                            elementInfo = elementInfo.Substring(elementInfo.IndexOf(":") + 1);

                                            //code for side protection type based on the shared parameter
                                            if (elementInfo == elementID)
                                            {
                                                Nw.PropertyCategoryCollection innermostpropCatCollection = modelAncestors.PropertyCategories;

                                                //get the start date of the window elements and save it to a list
                                                foreach (Nw.PropertyCategory innermostpropCat in innermostpropCatCollection)
                                                {
                                                    if (innermostpropCat.DisplayName.ToString() == "TimeLiner" &&
                                                        null != innermostpropCat.Properties.FindPropertyByDisplayName("Contained in Task Start (Planned):1"))
                                                    {
                                                        StartDate = (DateTime)innermostpropCat.Properties
                                                                    .FindPropertyByDisplayName("Contained in Task Start (Planned):1").Value.ToDateTime();
                                                        ListWindowStartDate.Add(StartDate);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // find the largest of the start dates and return it
            if (ListWindowStartDate.Count != 0)
            {
                ListWindowStartDate.Sort();
                returnStartDate = ListWindowStartDate.Last();
                ListWindowStartDate.Clear();
            }
            return(returnStartDate);
        }
Example #3
0
        //Code for walls
        public SlabResult RoofOperations(string elementID)
        {
            List <DateTime> ListWallEdgeStartDate = new List <DateTime>();
            List <DateTime> ListWallOpeningStartDate = new List <DateTime>();
            List <DateTime> ListWallStairStartDate = new List <DateTime>();
            string          caTegory, protectionInfo = null, elementInfo = null;
            DateTime        StartDate = new DateTime();
            SlabResult      roofwallResult = new SlabResult();

            roofwallResult.elementCategory = null;

            //open the active document and get model items
            foreach (Nw.ModelItem modelItem in Nw.Application.ActiveDocument.Models.RootItemDescendantsAndSelf)
            {
                Nw.ModelItem modelParent = modelItem.Parent;

                if (modelItem.HasGeometry)
                {
                    //select all the property categories of the parent element
                    Nw.PropertyCategoryCollection propCatCollection = modelParent.PropertyCategories;

                    foreach (Nw.PropertyCategory propCat in propCatCollection)
                    {
                        //check for the element type to be wall by iterating through property categories
                        if (propCat.DisplayName.ToString() == "Element" && null != propCat.Properties.FindPropertyByDisplayName("Category"))
                        {
                            caTegory = propCat.Properties.FindPropertyByDisplayName("Category").Value.ToString();
                            caTegory = caTegory.Substring(caTegory.IndexOf(":") + 1);

                            if (caTegory == "Walls")
                            {
                                roofwallResult.elementCategory = "Walls";
                                Nw.PropertyCategoryCollection innerpropCatCollection = modelParent.PropertyCategories;

                                // for walls found check for the ehared parameter input from revit
                                foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
                                {
                                    if (innerpropCat.DisplayName.ToString() == "Element" &&
                                        null != innerpropCat.Properties.FindPropertyByDisplayName("ElementInfo") &&
                                        null != innerpropCat.Properties.FindPropertyByDisplayName("ProtectionInfo"))
                                    {
                                        elementInfo    = innerpropCat.Properties.FindPropertyByDisplayName("ElementInfo").Value.ToString();
                                        protectionInfo = innerpropCat.Properties.FindPropertyByDisplayName("ProtectionInfo").Value.ToString();
                                        elementInfo    = elementInfo.Substring(elementInfo.IndexOf(":") + 1);
                                        protectionInfo = protectionInfo.Substring(protectionInfo.IndexOf(":") + 1);

                                        //code for side protection type based on the shared parameter
                                        if (elementInfo == elementID && protectionInfo == "ExteriorWall")
                                        {
                                            Nw.PropertyCategoryCollection innermostpropCatCollection = modelParent.PropertyCategories;

                                            //get the start date of the wall elements and save it to a list
                                            foreach (Nw.PropertyCategory innermostpropCat in innermostpropCatCollection)
                                            {
                                                if (innermostpropCat.DisplayName.ToString() == "TimeLiner" &&
                                                    null != innermostpropCat.Properties.FindPropertyByDisplayName("Attached to Task Start (Planned):1"))
                                                {
                                                    StartDate = (DateTime)innermostpropCat.Properties
                                                                .FindPropertyByDisplayName("Attached to Task Start (Planned):1").Value.ToDateTime();
                                                    ListWallEdgeStartDate.Add(StartDate);
                                                }
                                            }
                                        }

                                        //code for opening protection
                                        if (elementInfo == elementID && protectionInfo == "Opening")
                                        {
                                            Nw.PropertyCategoryCollection innermostpropCatCollection = modelParent.PropertyCategories;

                                            //get the start date of the wall elements and save it to a list
                                            foreach (Nw.PropertyCategory innermostpropCat in innermostpropCatCollection)
                                            {
                                                if (innermostpropCat.DisplayName.ToString() == "TimeLiner" &&
                                                    null != innermostpropCat.Properties.FindPropertyByDisplayName("Attached to Task Start (Planned):1"))
                                                {
                                                    StartDate = (DateTime)innermostpropCat.Properties
                                                                .FindPropertyByDisplayName("Attached to Task Start (Planned):1").Value.ToDateTime();
                                                    ListWallOpeningStartDate.Add(StartDate);
                                                }
                                            }
                                        }

                                        //code for stair side protection
                                        if (elementInfo == elementID && protectionInfo == "Stair")
                                        {
                                            Nw.PropertyCategoryCollection innermostpropCatCollection = modelParent.PropertyCategories;

                                            //get the start date of the wall elements and save it to a list
                                            foreach (Nw.PropertyCategory innermostpropCat in innermostpropCatCollection)
                                            {
                                                if (innermostpropCat.DisplayName.ToString() == "TimeLiner" &&
                                                    null != innermostpropCat.Properties.FindPropertyByDisplayName("Attached to Task Start (Planned):1"))
                                                {
                                                    StartDate = (DateTime)innermostpropCat.Properties
                                                                .FindPropertyByDisplayName("Attached to Task Start (Planned):1").Value.ToDateTime();
                                                    ListWallStairStartDate.Add(StartDate);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // find the largest of the start dates and return it
            if (ListWallEdgeStartDate.Count != 0)
            {
                ListWallEdgeStartDate.Sort();
                roofwallResult.edgestartDate = new DateTime();
                roofwallResult.edgestartDate = ListWallEdgeStartDate.Last();
                ListWallEdgeStartDate.Clear();
            }
            if (ListWallOpeningStartDate.Count != 0)
            {
                ListWallOpeningStartDate.Sort();
                roofwallResult.openingstartDate = new DateTime();
                roofwallResult.openingstartDate = ListWallOpeningStartDate.Last();
                ListWallOpeningStartDate.Clear();
            }
            if (ListWallStairStartDate.Count != 0)
            {
                ListWallStairStartDate.Sort();
                roofwallResult.stairstartDate = new DateTime();
                roofwallResult.stairstartDate = ListWallStairStartDate.Last();
                ListWallStairStartDate.Clear();
            }
            return(roofwallResult);
        }
        //FUNCTION FOR RAILING
        public void RailingSelector(string activityDescription)
        {
            List <ElementData> TempListofSafetyIssues = new List <ElementData>();
            ElementData        eachElementData        = new ElementData();
            string             caTegory = null;

            eachElementData.EleStartDate  = new DateTime();
            eachElementData.EleEndDate    = new DateTime();
            eachElementData.ProtStartDate = new DateTime();
            eachElementData.ProtEndDate   = new DateTime();

            foreach (Nw.ModelItem modelAncestors in modelItem.AncestorsAndSelf)
            {
                Nw.PropertyCategoryCollection familypropCatCollection = modelAncestors.PropertyCategories;
                foreach (Nw.PropertyCategory familypropCat in familypropCatCollection)
                {
                    if (familypropCat.DisplayName.ToString() == "Element" &&
                        null != familypropCat.Properties.FindPropertyByDisplayName("Category"))
                    {
                        caTegory = familypropCat.Properties.FindPropertyByDisplayName("Category").Value.ToString();
                        caTegory = caTegory.Substring(caTegory.IndexOf(":") + 1);

                        //if element is stair
                        if (caTegory == "Railings")
                        {
                            foreach (Nw.PropertyCategory innerpropCat in familypropCatCollection)
                            {
                                if (innerpropCat.DisplayName.ToString() == "Element" && null != innerpropCat.Properties
                                    .FindPropertyByDisplayName("ElementInfo"))
                                {
                                    eachElementData.ActivityName = activityDescription;
                                    eachElementData.ElementType  = "Railing";
                                    eachElementData.Hazard       = "Proximity to opening/slab edge";
                                    eachElementData.Protection   = "See general guidelines working at height";

                                    //get element level and elevation
                                    foreach (Nw.PropertyCategory innermostpropCat in familypropCatCollection)
                                    {
                                        if (innermostpropCat.DisplayName.ToString() == "Base Level" &&
                                            null != innermostpropCat.Properties.FindPropertyByDisplayName("Elevation") &&
                                            null != innermostpropCat.Properties.FindPropertyByDisplayName("Name"))
                                        {
                                            //elevation is returned in feet and not as double
                                            elevation = innermostpropCat.Properties.FindPropertyByDisplayName("Elevation").Value.ToDoubleLength();
                                            elevation = elevation * (double)0.3048;
                                            eachElementData.Elevation = elevation;

                                            eachElementData.Level = innermostpropCat.Properties.FindPropertyByDisplayName("Name").Value.ToString();
                                            eachElementData.Level = eachElementData.Level.Substring(eachElementData.Level.IndexOf(":") + 1);
                                            break;
                                        }
                                    }

                                    //get element start date and end date
                                    foreach (Nw.PropertyCategory innermostpropCat in familypropCatCollection)
                                    {
                                        if (innermostpropCat.DisplayName.ToString() == "TimeLiner" &&
                                            null != innermostpropCat.Properties.FindPropertyByDisplayName("Contained in Task Start (Planned):1") &&
                                            null != innermostpropCat.Properties.FindPropertyByDisplayName("Contained in Task End (Planned):1"))
                                        {
                                            eachElementData.EleStartDate = (DateTime)innermostpropCat.Properties
                                                                           .FindPropertyByDisplayName("Contained in Task Start (Planned):1").Value.ToDateTime();
                                            eachElementData.EleEndDate = (DateTime)innermostpropCat.Properties
                                                                         .FindPropertyByDisplayName("Contained in Task End (Planned):1").Value.ToDateTime();
                                            break;
                                        }
                                    }
                                    eachElementData.ProtStartDate = eachElementData.EleStartDate;
                                    eachElementData.ProtEndDate   = eachElementData.EleEndDate;

                                    TempListofSafetyIssues.Add(eachElementData);
                                }
                            }
                        }
                    }
                }
            }

            Result.ListofSafetyIssues.AddRange(TempListofSafetyIssues);
        }
        //FUNCTION FOR STAIR
        public void StairSelector(string activityDescription)
        {
            string             caTegory;
            List <ElementData> TempListofSafetyIssues = new List <ElementData>();
            ElementData        eachElementData        = new ElementData();
            Operate            elementOperate         = new Operate();
            string             elementID;

            DateTime tempDateTime = new DateTime();

            eachElementData.EleStartDate  = new DateTime();
            eachElementData.EleEndDate    = new DateTime();
            eachElementData.ProtStartDate = new DateTime();
            eachElementData.ProtEndDate   = new DateTime();

            SlabResult stairwallResult    = new SlabResult();
            SlabResult stairrailingResult = new SlabResult();

            foreach (Nw.ModelItem modelAncestors in modelItem.AncestorsAndSelf)
            {
                Nw.PropertyCategoryCollection familypropCatCollection = modelAncestors.PropertyCategories;
                foreach (Nw.PropertyCategory familypropCat in familypropCatCollection)
                {
                    if (familypropCat.DisplayName.ToString() == "Element" &&
                        null != familypropCat.Properties.FindPropertyByDisplayName("Category"))
                    {
                        caTegory = familypropCat.Properties.FindPropertyByDisplayName("Category").Value.ToString();
                        caTegory = caTegory.Substring(caTegory.IndexOf(":") + 1);

                        //if element is stair
                        if (caTegory == "Stairs")
                        {
                            //get start date of edge walls and railings
                            foreach (Nw.PropertyCategory innerpropCat in familypropCatCollection)
                            {
                                if (innerpropCat.DisplayName.ToString() == "Element ID" &&
                                    null != innerpropCat.Properties.FindPropertyByDisplayName("Value"))
                                {
                                    elementID          = innerpropCat.Properties.FindPropertyByDisplayName("Value").Value.ToString();
                                    elementID          = elementID.Substring(elementID.IndexOf(":") + 1);
                                    stairwallResult    = elementOperate.RoofOperations(elementID);
                                    stairrailingResult = elementOperate.RailingOperations(elementID);
                                    break;
                                }
                            }

                            //get element start date and end date
                            foreach (Nw.PropertyCategory innerpropCat in familypropCatCollection)
                            {
                                if (innerpropCat.DisplayName.ToString() == "TimeLiner" &&
                                    null != innerpropCat.Properties.FindPropertyByDisplayName("Contained in Task Start (Planned):1") &&
                                    null != innerpropCat.Properties.FindPropertyByDisplayName("Contained in Task End (Planned):1"))
                                {
                                    tempDateTime = (DateTime)innerpropCat.Properties
                                                   .FindPropertyByDisplayName("Contained in Task Start (Planned):1").Value.ToDateTime();
                                    eachElementData.ProtStartDate = (DateTime)innerpropCat.Properties
                                                                    .FindPropertyByDisplayName("Contained in Task End (Planned):1").Value.ToDateTime();
                                    break;
                                }
                            }

                            //get element level and elevation
                            foreach (Nw.PropertyCategory innerpropCat in familypropCatCollection)
                            {
                                if (innerpropCat.DisplayName.ToString() == "Top Level" &&
                                    null != innerpropCat.Properties.FindPropertyByDisplayName("Elevation") &&
                                    null != innerpropCat.Properties.FindPropertyByDisplayName("Name"))
                                {
                                    //elevation is returned in feet and not as double
                                    elevation = innerpropCat.Properties.FindPropertyByDisplayName("Elevation").Value.ToDoubleLength();
                                    elevation = elevation * (double)0.3048;

                                    eachElementData.Elevation = elevation;
                                    eachElementData.Level     = innerpropCat.Properties.FindPropertyByDisplayName("Name").Value.ToString();
                                    eachElementData.Level     = eachElementData.Level.Substring(eachElementData.Level.IndexOf(":") + 1);
                                    break;
                                }
                            }

                            //in case of walls along the stair edges
                            if (stairwallResult.stairstartDate.ToShortDateString() != "01-01-0001")
                            {
                                eachElementData.ProtEndDate = stairwallResult.stairstartDate;
                                eachElementData.Hazard      = "Unprotected Stairs";
                                eachElementData.Protection  = "Provide edge protection along the stair walls are to be built";
                                TempListofSafetyIssues.Add(eachElementData);
                            }

                            //in case of railings along the stair edges
                            if (stairrailingResult.stairstartDate.ToShortDateString() != "01-01-0001")
                            {
                                eachElementData.ProtEndDate = stairrailingResult.stairstartDate;
                                eachElementData.Hazard      = "Unprotected Stairs";
                                eachElementData.Protection  = "Provide edge protection along the stair where railings are to be built";
                                TempListofSafetyIssues.Add(eachElementData);
                            }
                            eachElementData.EleStartDate  = tempDateTime;
                            eachElementData.EleEndDate    = eachElementData.ProtStartDate;
                            eachElementData.ProtStartDate = eachElementData.EleEndDate;
                            eachElementData.ProtEndDate   = eachElementData.EleEndDate;
                            eachElementData.ActivityName  = activityDescription;
                            eachElementData.ElementType   = "Stair";
                            eachElementData.Hazard        = "Working at height";
                            eachElementData.Protection    = "See general guidelines for Construction of stairs";
                            TempListofSafetyIssues.Add(eachElementData);

                            Result.ListofSafetyIssues.AddRange(TempListofSafetyIssues);
                        }
                    }
                }
            }
        }
        //Function with switch case to select the operations on an element
        public void ElementSelector(string activityDescription)
        {
            Nw.ModelItem modelParent = modelItem.Parent;

            string caTegory;

            if (modelItem.HasGeometry)
            {
                Nw.PropertyCategoryCollection propCatCollection = modelParent.PropertyCategories;
                foreach (Nw.PropertyCategory propCat in propCatCollection)
                {
                    if (propCat.DisplayName.ToString() == "Revit Type" &&
                        null != propCat.Properties.FindPropertyByDisplayName("Category").Value)
                    {
                        caTegory = propCat.Properties.FindPropertyByDisplayName("Category").Value.ToString();
                        caTegory = caTegory.Substring(caTegory.IndexOf(":") + 1);

                        //if element is a roof
                        if (caTegory == "Roofs")
                        {
                            RoofSelector(activityDescription);
                        }

                        //if element is a wall
                        if (caTegory == "Walls")
                        {
                            WallSelector(activityDescription);
                        }

                        //if element is column
                        else if (caTegory == "Columns")
                        {
                            ColumnSelector(activityDescription);
                        }

                        //if element is beam
                        if (caTegory == "Structural Framing")
                        {
                            BeamSelector(activityDescription);
                        }

                        //if element is Foundation
                        else if (caTegory == "Structural Foundations")
                        {
                            FoundationSelector(activityDescription);
                        }
                        //if element is Floor
                        else if (caTegory == "Floors")
                        {
                            FloorSelector(activityDescription);
                        }
                    }
                }

                //for families iterate through the ancestors to get the model item type
                foreach (Nw.ModelItem modelAncestors in modelItem.AncestorsAndSelf)
                {
                    Nw.PropertyCategoryCollection familypropCatCollection = modelAncestors.PropertyCategories;
                    foreach (Nw.PropertyCategory familypropCat in familypropCatCollection)
                    {
                        if (familypropCat.DisplayName.ToString() == "Element" &&
                            null != familypropCat.Properties.FindPropertyByDisplayName("Category"))
                        {
                            caTegory = familypropCat.Properties.FindPropertyByDisplayName("Category").Value.ToString();
                            caTegory = caTegory.Substring(caTegory.IndexOf(":") + 1);

                            //if element is window
                            if (caTegory == "Windows")
                            {
                                WindowSelector(activityDescription);
                            }

                            //if element is stairs
                            else if (caTegory == "Stairs")
                            {
                                StairSelector(activityDescription);
                            }

                            //if element is railing
                            else if (caTegory == "Railings")
                            {
                                RailingSelector(activityDescription);
                            }
                        }
                    }
                }
            }
            return;
        }
        //FUNCTION FOR WALL
        public void WallSelector(string activityDescription)
        {
            Nw.ModelItem       modelParent    = modelItem.Parent;
            Operate            elementOperate = new Operate();
            string             elementID;
            List <ElementData> TempListofSafetyIssues = new List <ElementData>();
            ElementData        eachElementData        = new ElementData();

            DateTime tempDateTime = new DateTime();

            eachElementData.EleStartDate  = new DateTime();
            eachElementData.EleEndDate    = new DateTime();
            eachElementData.ProtStartDate = new DateTime();
            eachElementData.ProtEndDate   = new DateTime();

            Nw.PropertyCategoryCollection innerpropCatCollection = modelParent.PropertyCategories;
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Element ID" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Value"))
                {
                    elementID = innerpropCat.Properties.FindPropertyByDisplayName("Value").Value.ToString();
                    elementID = elementID.Substring(elementID.IndexOf(":") + 1);
                    eachElementData.ProtEndDate = elementOperate.WallOperations(elementID);
                    break;
                }
            }

            //get element start date and end date
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "TimeLiner" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Attached to Task Start (Planned):1") &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Attached to Task End (Planned):1"))
                {
                    tempDateTime = (DateTime)innerpropCat.Properties
                                   .FindPropertyByDisplayName("Attached to Task Start (Planned):1").Value.ToDateTime();
                    eachElementData.ProtStartDate = (DateTime)innerpropCat
                                                    .Properties.FindPropertyByDisplayName("Attached to Task End (Planned):1").Value.ToDateTime();
                    break;
                }
            }

            //get element level
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Base Constraint" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Name"))
                {
                    eachElementData.Level = innerpropCat.Properties.FindPropertyByDisplayName("Name").Value.ToString();
                    eachElementData.Level = eachElementData.Level.Substring(eachElementData.Level.IndexOf(":") + 1);
                    break;
                }
            }

            //get element top elevation
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Top Constraint" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Elevation"))
                {
                    //elevation is returned in feet and not as double
                    elevation = innerpropCat.Properties.FindPropertyByDisplayName("Elevation").Value.ToDoubleLength();
                    elevation = elevation * (double)0.3048;

                    eachElementData.Elevation = elevation;
                    break;
                }
            }

            //in case of walls along the boundaries
            if (eachElementData.ProtEndDate.ToShortDateString() != "01-01-0001")
            {
                eachElementData.Hazard     = "Window Openings along slab edges";
                eachElementData.Protection = "Close openings using grills";
                TempListofSafetyIssues.Add(eachElementData);
            }

            eachElementData.EleStartDate  = tempDateTime;
            eachElementData.EleEndDate    = eachElementData.ProtStartDate;
            eachElementData.ProtStartDate = eachElementData.EleEndDate;
            eachElementData.ProtEndDate   = eachElementData.EleEndDate;
            eachElementData.ActivityName  = activityDescription;
            eachElementData.ElementType   = "Wall";
            eachElementData.Hazard        = "Working at height";
            eachElementData.Protection    = "See general guidelines for Construction of walls at height";
            TempListofSafetyIssues.Add(eachElementData);

            Result.ListofSafetyIssues.AddRange(TempListofSafetyIssues);
        }
        //FUNCTION FOR ROOF
        public void RoofSelector(string activityDescription)
        {
            Nw.ModelItem       modelParent    = modelItem.Parent;
            Operate            elementOperate = new Operate();
            string             elementID;
            List <ElementData> TempListofSafetyIssues = new List <ElementData>();
            ElementData        eachElementData        = new ElementData();

            DateTime tempDateTime = new DateTime();

            eachElementData.EleStartDate  = new DateTime();
            eachElementData.EleEndDate    = new DateTime();
            eachElementData.ProtStartDate = new DateTime();
            eachElementData.ProtEndDate   = new DateTime();

            SlabResult slabwallResult    = new SlabResult();
            SlabResult slabrailingResult = new SlabResult();

            Nw.PropertyCategoryCollection innerpropCatCollection = modelParent.PropertyCategories;

            //get element start date and end date
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "TimeLiner" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Attached to Task Start (Planned):1") &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Attached to Task End (Planned):1"))
                {
                    tempDateTime = (DateTime)innerpropCat.Properties
                                   .FindPropertyByDisplayName("Attached to Task Start (Planned):1").Value.ToDateTime();
                    eachElementData.ProtStartDate = (DateTime)innerpropCat.Properties
                                                    .FindPropertyByDisplayName("Attached to Task End (Planned):1").Value.ToDateTime();
                    break;
                }
            }


            //get element level and elevation
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Base Level" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Elevation") &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Name"))
                {
                    //elevation is returned in feet and not as double
                    elevation = innerpropCat.Properties.FindPropertyByDisplayName("Elevation").Value.ToDoubleLength();
                    elevation = elevation * (double)0.3048;

                    eachElementData.Elevation = elevation;
                    eachElementData.Level     = innerpropCat.Properties.FindPropertyByDisplayName("Name").Value.ToString();
                    eachElementData.Level     = eachElementData.Level.Substring(eachElementData.Level.IndexOf(":") + 1);
                    break;
                }
            }

            //get start date of edge walls and railings
            foreach (Nw.PropertyCategory innerpropCat in innerpropCatCollection)
            {
                if (innerpropCat.DisplayName.ToString() == "Element ID" &&
                    null != innerpropCat.Properties.FindPropertyByDisplayName("Value"))
                {
                    elementID         = innerpropCat.Properties.FindPropertyByDisplayName("Value").Value.ToString();
                    elementID         = elementID.Substring(elementID.IndexOf(":") + 1);
                    slabwallResult    = elementOperate.RoofOperations(elementID);
                    slabrailingResult = elementOperate.RailingOperations(elementID);
                    break;
                }
            }

            //in case of walls along the boundaries
            if (slabwallResult.edgestartDate.ToShortDateString() != "01-01-0001")
            {
                eachElementData.ProtEndDate = slabwallResult.edgestartDate;
                eachElementData.Hazard      = "Unprotected Slab Edges";
                eachElementData.Protection  = "Provide edge protection along the slab edges where exterior walls are to be built";
                TempListofSafetyIssues.Add(eachElementData);
            }

            //in case of railings along the boundaries
            if (slabrailingResult.edgestartDate.ToShortDateString() != "01-01-0001")
            {
                eachElementData.ProtEndDate = slabrailingResult.edgestartDate;
                eachElementData.Hazard      = "Unprotected Edges of Slab";
                eachElementData.Protection  = "Provide edge protection along the edges of the slab where railings are to be built";
                TempListofSafetyIssues.Add(eachElementData);
            }

            //in case of walls along openings
            if (slabwallResult.openingstartDate.ToShortDateString() != "01-01-0001")
            {
                eachElementData.ProtEndDate = slabwallResult.openingstartDate;
                eachElementData.Hazard      = "Unprotected Openings in slab";
                eachElementData.Protection  = "Provide edge protection along the opening edges where walls are to be built";
                TempListofSafetyIssues.Add(eachElementData);
            }

            //in case of railings along openings
            if (slabrailingResult.openingstartDate.ToShortDateString() != "01-01-0001")
            {
                eachElementData.ProtEndDate = slabrailingResult.openingstartDate;
                eachElementData.Hazard      = "Unprotected Openings in slab";
                eachElementData.Protection  = "Provide edge protection along the edges of openings where railings are to be built";
                TempListofSafetyIssues.Add(eachElementData);
            }


            eachElementData.EleStartDate  = tempDateTime;
            eachElementData.EleEndDate    = eachElementData.ProtStartDate;
            eachElementData.ProtStartDate = eachElementData.EleEndDate;
            eachElementData.ProtEndDate   = eachElementData.EleEndDate;
            eachElementData.ActivityName  = activityDescription;
            eachElementData.ElementType   = "Roof";
            eachElementData.Hazard        = "Unprotected Edges of Slab and slab openings";
            eachElementData.Protection    = "See general guidelines for Construction of slabs at height";
            TempListofSafetyIssues.Add(eachElementData);

            Result.ListofSafetyIssues.AddRange(TempListofSafetyIssues);
        }