예제 #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);
        }
예제 #2
0
        /// <summary>
        /// Reads calculation parameters from revit data base.
        /// </summary>
        /// <param name="data">Acces to cref="ServiceData".</param>
        /// <returns>User calculation parameters schema object.</returns>
        public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass ReadCalculationParameter(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);
            CalculationParameter calculationParameter = storageDocument.CalculationParamsManager.CalculationParams.GetEntity <CalculationParameter>(data.Document);

            return(calculationParameter);
        }
예제 #3
0
        /// <summary>
        /// Saves in Revit the result object of an element.
        /// </summary>
        /// <param name="elementId">Identificator of an element.</param>
        /// <param name="resultSchema">Result object.</param>
        /// <param name="status">Status of element's results.</param>
        /// <param name="data">Acces to cref="ServiceData".</param>
        protected void SaveElementResult(ElementId elementId, Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass resultSchema, Autodesk.Revit.DB.CodeChecking.Storage.ResultStatus status, 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);

            Element element = data.Document.GetElement(elementId);

            if (resultSchema != null)
            {
                storageDocument.ResultsManager.SetResult(resultSchema.GetEntity(), element, status, true);
            }
        }
예제 #4
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);
        }
예제 #5
0
        /// </structural_toolkit_2015>

        /// <summary>
        /// Read from Revit parameters common for all selected elements and stores them in cref="CommonParametersBase".
        /// </summary>
        /// <param name="listElementStatus">List identyficators of elements with result status.</param>
        /// <param name="server">Acces to cref="Server".</param>
        /// <param name="data">Acces to cref="ServiceData".</param>
        /// <returns>Common parameters.</returns>
        protected CommonParametersBase ReadCommonParameters(List <Tuple <ElementId, ResultStatus> > listElementStatus, 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());

            Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass calcParams = EngineData.ReadCalculationParameter(data);

            List <ElementId> listCombinationId = new List <ElementId>();

            if (server.LoadCasesAndCombinationsSupport())
            {
                listCombinationId = storageDocument.CalculationParamsManager.CalculationParams.GetLoadCasesAndCombinations(Server.Server.ID);
            }

            CommonParametersBase parameBase = new CommonParametersBase(listElementStatus, listCombinationId, activePackageId, calcParams);
            CommonParametersBase parameters = EngineData.CreateCommonParameters(data, parameBase);

            return(parameters);
        }