Esempio n. 1
0
        /// <summary>
        /// Reads from Revit selected elements identificators and collect in the list only that which has apprppriate label, material and category.
        /// </summary>
        /// <param name="server">Acces to cref="Server".</param>
        /// <param name="data">Acces to cref="ServiceData".</param>
        /// <returns>List identyficators of elements with result status.</returns>
        protected List <Tuple <ElementId, ResultStatus> > ReadListElementIdWithStatus(Server.Server server, Autodesk.Revit.DB.CodeChecking.ServiceData data)
        {
            Autodesk.Revit.DB.CodeChecking.Storage.StorageService  service         = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService();
            Autodesk.Revit.DB.CodeChecking.Storage.StorageDocument storageDocument = service.GetStorageDocument(data.Document);
            Guid activePackageId = storageDocument.CalculationParamsManager.CalculationParams.GetInputResultPackageId(server.GetServerId());

            List <Tuple <ElementId, ResultStatus> > listElementId = new List <Tuple <ElementId, ResultStatus> >();

            foreach (Element element in data.Selection)
            {
                Autodesk.Revit.DB.CodeChecking.Storage.Label ccLabel = storageDocument.LabelsManager.GetLabel(element);
                if (ccLabel != null)
                {
                    Autodesk.Revit.DB.BuiltInCategory category = (Autodesk.Revit.DB.BuiltInCategory)element.Category.Id.IntegerValue;
                    StructuralAssetClass material = ccLabel.Material;

                    if (server.GetSupportedMaterials().Contains(material) &&
                        server.GetSupportedCategories(material).Contains(category))
                    {
                        ElementId id = new ElementId(element.Id.IntegerValue);

                        SchemaClass  label  = EngineData.ReadElementLabel(category, material, ccLabel, data);
                        ResultStatus status = new Autodesk.Revit.DB.CodeChecking.Storage.ResultStatus(Server.Server.ID, activePackageId);
                        EngineData.VerifyElementLabel(category, material, label, ref status);

                        listElementId.Add(new Tuple <ElementId, ResultStatus>(id, status));
                    }
                }
            }

            return(listElementId);
        }
Esempio n. 2
0
        /// <summary>
        /// Reads from Revit information about selected elements and store it in the list with elements data.
        /// </summary>
        /// <param name="data">Acces to cref="ServiceData".</param>
        /// <param name="listElementStatus">List identyficators of elements with result status.</param>
        /// <param name="parameters">Common parameters.</param>
        /// <returns>List of elements data.</returns>
        protected List <ObjectDataBase> ReadListElementData(Autodesk.Revit.DB.CodeChecking.ServiceData data, List <Tuple <ElementId, ResultStatus> > listElementStatus, CommonParametersBase parameters)
        {
            Autodesk.Revit.DB.CodeChecking.Storage.StorageService  service         = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService();
            Autodesk.Revit.DB.CodeChecking.Storage.StorageDocument storageDocument = service.GetStorageDocument(data.Document);

            List <ObjectDataBase> listElementData = new List <ObjectDataBase>();

            foreach (Tuple <ElementId, ResultStatus> elemStatus in listElementStatus)
            {
                Element element = data.Document.GetElement(elemStatus.Item1);
                if (element != null)
                {
                    Autodesk.Revit.DB.CodeChecking.Storage.Label ccLabel = storageDocument.LabelsManager.GetLabel(element);
                    if (ccLabel != null)
                    {
                        Autodesk.Revit.DB.BuiltInCategory category = (Autodesk.Revit.DB.BuiltInCategory)element.Category.Id.IntegerValue;
                        StructuralAssetClass material = ccLabel.Material;
                        Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass label  = EngineData.ReadElementLabel(category, material, ccLabel, data);
                        Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass result = EngineData.CreateElementResult(category, material);

                        ObjectDataBase         objectData       = new ObjectDataBase(elemStatus.Item1, category, material, label);
                        List <SectionDataBase> listSectionsData = new List <SectionDataBase>();
                        List <CalcPoint>       listCalcPoints   = EngineData.CreateCalcPointsForElement(data, parameters, elemStatus.Item1);
                        foreach (CalcPoint p in listCalcPoints)
                        {
                            SectionDataBase sectBase = new SectionDataBase(p, objectData);
                            SectionDataBase sectData = EngineData.CreateSectionData(sectBase);

                            listSectionsData.Add(sectData);
                        }

                        ElementDataBase elemBase = new ElementDataBase(result, listCalcPoints, listSectionsData, elemStatus.Item2, data.Document, objectData);
                        ElementDataBase elemData = EngineData.CreateElementData(elemBase);

                        listElementData.Add(elemData);
                    }
                }
            }

            return(listElementData);
        }
Esempio n. 3
0
        /// <summary>
        /// Reads parameters of user element label.
        /// </summary>
        /// <param name="category">Category of the element.</param>
        /// <param name="material">Material of the element.</param>
        /// <param name="label">Acces to the Revit storage with labels."</param>
        /// <param name="data">Acces to cref="ServiceData".</param>
        /// <returns>User label of the element.</returns>
        public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass ReadElementLabel(Autodesk.Revit.DB.BuiltInCategory category, Autodesk.Revit.DB.StructuralAssetClass material, Autodesk.Revit.DB.CodeChecking.Storage.Label label, Autodesk.Revit.DB.CodeChecking.ServiceData data)
        {
            if (label != null)
            {
                switch (material)
                {
                case StructuralAssetClass.Concrete:
                    switch (category)
                    {
                    default:
                        break;

                    case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: return(label.GetEntity <LabelColumn>(data.Document));

                    case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: return(label.GetEntity <LabelBeam>(data.Document));
                    }
                    break;

                case StructuralAssetClass.Metal:
                    break;
                }
            }

            return(null);
        }