예제 #1
0
        /// <summary>
        /// Gives possibility to read data from Revit data base and puts them into user element's objects and into user section's objects and into user common parameters.
        /// </summary>
        /// <param name="listElementData">List of user element objects.</param>
        /// <param name="parameters">User common parameters.</param>
        /// <param name="data">Acces to cref="ServiceData".</param>
        public void ReadFromRevitDB(List <ObjectDataBase> listElementData, CommonParametersBase parameters, Autodesk.Revit.DB.CodeChecking.ServiceData data)
        {
            // read additional information from Revit data and store them in user objects derived from ElementDataBase and listed in listElementData

            Autodesk.Revit.DB.CodeChecking.NotificationService.ProgressStart(Resources.ResourceManager.GetString("ReadingGeometry"), listElementData.Count);
            ElementAnalyser elementAnalyser = new ElementAnalyser(GetInputDataUnitSystem());

            int step = 0;

            foreach (ObjectDataBase elemData in listElementData)
            {
                Element element = data.Document.GetElement(elemData.ElementId);
                if (element != null)
                {
                    switch (elemData.Category)
                    {
                    default:
                        break;

                    case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical:
                    {
                        ColumnElement elem = elemData as ColumnElement;
                        if (elem != null && !elem.Status.IsError())
                        {
                            elem.Info = elementAnalyser.Analyse(element);
                            if (elem.Info.Material.Characteristics.YoungModulus.X < Double.Epsilon)
                            {
                                elem.Status.AddError(Resources.ResourceManager.GetString("ErrYoungModulus"));
                            }

                            MaterialConcreteCharacteristics concrete = (MaterialConcreteCharacteristics)elem.Info.Material.Characteristics.Specific;
                            if (concrete == null || concrete.Compression < Double.Epsilon)
                            {
                                elem.Status.AddError(Resources.ResourceManager.GetString("ErrConcreteCompression"));
                            }

                            foreach (SectionDataBase sectionDataBase in elem.ListSectionData)
                            {
                                ColumnSection sec = sectionDataBase as ColumnSection;
                                if (sec != null)
                                {
                                    sec.Info = elem.Info;
                                }
                            }
                        }
                        break;
                    }

                    case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical:
                    {
                        BeamElement elem = elemData as BeamElement;
                        if (elem != null && !elem.Status.IsError())
                        {
                            elementAnalyser.TSectionAnalysis = false;
                            LabelBeam labelBeam = elem.Label as LabelBeam;
                            if (labelBeam != null)
                            {
                                elementAnalyser.TSectionAnalysis = (labelBeam.SlabBeamInteraction == BeamSectionType.WithSlabBeamInteraction);
                            }

                            elem.Info = elementAnalyser.Analyse(element);
                            if (elem.Info.Material.Characteristics.YoungModulus.X < Double.Epsilon)
                            {
                                elem.Status.AddError(Resources.ResourceManager.GetString("ErrYoungModulus"));
                            }

                            MaterialConcreteCharacteristics concrete = (MaterialConcreteCharacteristics)elem.Info.Material.Characteristics.Specific;
                            if (concrete == null || concrete.Compression < Double.Epsilon)
                            {
                                elem.Status.AddError(Resources.ResourceManager.GetString("ErrConcreteCompression"));
                            }

                            foreach (SectionDataBase sectionDataBase in elem.ListSectionData)
                            {
                                BeamSection sec = sectionDataBase as BeamSection;
                                if (sec != null)
                                {
                                    sec.Info = elem.Info;
                                }
                            }
                        }
                        break;
                    }


                    /// <structural_toolkit_2015>


                    case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical:


                    case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical:

                    {
                        FloorElement slab = elemData as FloorElement;
                        if (slab != null)
                        {
                            slab.Info = elementAnalyser.Analyse(element);

                            foreach (SectionDataBase secData in slab.ListSectionData)
                            {
                                FloorSection sec = secData as FloorSection;
                                if (sec != null)
                                {
                                    sec.Info = slab.Info;
                                }
                            }
                        }
                    }
                    break;

                    case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical:
                    {
                        WallElement wall = elemData as WallElement;
                        if (wall != null)
                        {
                            wall.Info = elementAnalyser.Analyse(element);

                            foreach (SectionDataBase secData in wall.ListSectionData)
                            {
                                WallSection sec = secData as WallSection;
                                if (sec != null)
                                {
                                    sec.Info = wall.Info;
                                }
                            }
                        }
                    }
                    break;

                        /// </structural_toolkit_2015>
                    }
                }
                Autodesk.Revit.DB.CodeChecking.NotificationService.ProgressStep(string.Format("{0:d}%", ++step * 100 / listElementData.Count));
                if (NotificationService.ProgressBreakInvoked())
                {
                    break;
                }
            }
        }