Beispiel #1
0
        /// </structural_toolkit_2015>

        /// <structural_toolkit_2015>

        /// <summary>
        /// Build document body for result document
        /// </summary>
        /// <param name="calculationParameters">Code calculation parameters</param>
        /// <param name="element">Revit element for which result document is built</param>
        /// <param name="document">Active Revit document</param>
        /// <returns>DocumentBody object</returns>
        public override DocumentBody BuildResultDocumentBody(Autodesk.Revit.DB.ExtensibleStorage.Entity calculationParameters, Element element, Autodesk.Revit.DB.Document document)
        {
            Autodesk.Revit.DB.CodeChecking.Storage.StorageService  service         = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService();
            Autodesk.Revit.DB.CodeChecking.Storage.StorageDocument storageDocument = service.GetStorageDocument(document);
            Guid activePackageId = storageDocument.CalculationParamsManager.CalculationParams.GetInputResultPackageId(Server.ID);

            Autodesk.Revit.DB.CodeChecking.Storage.ResultStatus status = storageDocument.ResultsManager.GetResultStatus(element, activePackageId, Server.ID);
            DocumentBody body = new DocumentBody();

            if (!status.IsError())
            {
                // create body object
                // get results schema for the current element
                string schemaName = calculationParameters.Schema.SchemaName;
                switch (schemaName)
                {
                case "ResultBeam":
                    ResultLinearElement resultBeam = new ResultBeam();
                    resultBeam.SetProperties(calculationParameters);
                    WriteResultsToNoteForLinearElements(body, resultBeam, document, ElementType.Beam);
                    break;

                case "ResultColumn":
                    ResultLinearElement resultColumn = new ResultColumn();
                    resultColumn.SetProperties(calculationParameters);
                    WriteResultsToNoteForLinearElements(body, resultColumn, document, ElementType.Column);
                    break;

                case "ResultFloor":
                    ResultSurfaceElement resultFloor = new ResultSurfaceElement();
                    resultFloor.SetProperties(calculationParameters);
                    WriteResultsToNoteForSurfaceElements(body, resultFloor, document, element, ElementType.Floor);
                    break;

                case "ResultWall":
                    ResultSurfaceElement resultWall = new ResultSurfaceElement();
                    resultWall.SetProperties(calculationParameters);
                    WriteResultsToNoteForSurfaceElements(body, resultWall, document, element, ElementType.Wall);
                    break;
                }
            }
            return(body);
        }
Beispiel #2
0
        /// <summary>
        /// Fills document body object with formatted reinforcement calculation results
        /// </summary>
        /// <param name="body">DocumentBody to be filled</param>
        /// <param name="resultSurfaceElement">Calculation results schema class</param>
        /// <param name="document">Active Revit document</param>
        /// <param name="element">Structural element</param>
        /// <param name="elementType">Typ of element</param>
        private void WriteResultsToNoteForSurfaceElements(DocumentBody body, ResultSurfaceElement resultSurfaceElement, Autodesk.Revit.DB.Document document, Element element, ElementType elementType)
        {
            List <ResultInPointSurface> resultsInPointsCollection = resultSurfaceElement.GetResultsInPointsCollection();

            /////////////////////////// Basic Level ///////////////////////////////////////

            //////////////////// Summary
            {
                if (resultSurfaceElement.MultiLayer)
                {
                    DocumentSection resultLeyerSection = new DocumentSection(Resources.ResourceManager.GetString("Layers"), 5);
                    resultLeyerSection.Level = DetailLevel.General;
                    List <Tuple <string, double> > structuralLayers = resultSurfaceElement.GetStructuralLayers();
                    double calculationThickness = 0;
                    resultLeyerSection.Body.Elements.Add(new DocumentText(Resources.ResourceManager.GetString("LayerTakenIntoConsideration"), true));
                    for (int layersId = 0; layersId < structuralLayers.Count(); layersId++)
                    {
                        resultLeyerSection.Body.Elements.Add((new DocumentValueWithName("- " + structuralLayers[layersId].Item1, structuralLayers[layersId].Item2, UnitsConverter.GetInternalUnit(UnitType.UT_Section_Dimension), UnitType.UT_Section_Dimension, document.GetUnits())));
                        calculationThickness += structuralLayers[layersId].Item2;
                    }
                    resultLeyerSection.Body.Elements.Add((new DocumentValueWithName(Resources.ResourceManager.GetString("ThicknessTakenIntoConsideration"), calculationThickness, UnitsConverter.GetInternalUnit(UnitType.UT_Section_Dimension), UnitType.UT_Section_Dimension, document.GetUnits())));
                    body.Elements.Add(resultLeyerSection);
                }

                // Create document section
                DocumentSection resultSummarySection = new DocumentSection(Resources.ResourceManager.GetString("Summary"), 5);
                resultSummarySection.Level = DetailLevel.General;

                // Calculate mean and extreme values
                IEnumerable <ResultTypeSurface> primary = new List <ResultTypeSurface> {
                    ResultTypeSurface.AxxTop, ResultTypeSurface.AxxBottom
                };
                IEnumerable <ResultTypeSurface> secondary = new List <ResultTypeSurface> {
                    ResultTypeSurface.AyyTop, ResultTypeSurface.AyyBottom
                };
                double meanPrimary   = resultsInPointsCollection.Average(s => (primary.Sum(q => s[q]))),
                       meanSecondary = resultsInPointsCollection.Average(s => (secondary.Sum(q => s[q])));

                // Add them to the section
                string meanPrimaryString   = elementType == ElementType.Floor ? "MeanPrimaryReinforcementDensity" : "MeanVerticallReinforcementDensity";
                string meanSecondaryString = elementType == ElementType.Floor ? "MeanSecondaryReinforcementDensity" : "MeanHorizontalReinforcementDensity";
                meanPrimaryString   = Resources.ResourceManager.GetString(meanPrimaryString);
                meanSecondaryString = Resources.ResourceManager.GetString(meanSecondaryString);
                resultSummarySection.Body.Elements.Add((new DocumentValueWithName(meanPrimaryString, meanPrimary, UnitsConverter.GetInternalUnit(UnitType.UT_Reinforcement_Area_per_Unit_Length), UnitType.UT_Reinforcement_Area_per_Unit_Length, document.GetUnits())));
                resultSummarySection.Body.Elements.Add((new DocumentValueWithName(meanSecondaryString, meanSecondary, UnitsConverter.GetInternalUnit(UnitType.UT_Reinforcement_Area_per_Unit_Length), UnitType.UT_Reinforcement_Area_per_Unit_Length, document.GetUnits())));


                // Add extreme reinforcement table
                resultSummarySection.Body.Elements.Add(new DocumentText(Resources.ResourceManager.GetString("ExtremeValuesOfReinforcement")));
                resultSummarySection.Body.Elements.Add(CreateExtremeResultTableForSurfaceElements(resultsInPointsCollection, new List <ResultTypeSurface>()
                {
                    ResultTypeSurface.AxxBottom, ResultTypeSurface.AxxTop, ResultTypeSurface.AyyBottom, ResultTypeSurface.AyyTop
                }, document, elementType));


                // Add section to the document body
                body.Elements.Add(resultSummarySection);
            }
            /////////////////////////// Other levels ///////////////////////////////////////

            //////////////////// Reinforcement table
            {
                // Create document section
                DocumentSection reinforcementTableSection = new DocumentSection(Resources.ResourceManager.GetString("Reinforcement"), 5);
                reinforcementTableSection.Level = DetailLevel.Medium;

                // Add extreme reinforcement table
                reinforcementTableSection.Body.Elements.Add(CreateResultTableForSurfaceElements(resultsInPointsCollection, new List <ResultTypeSurface>()
                {
                    ResultTypeSurface.AxxBottom, ResultTypeSurface.AxxTop, ResultTypeSurface.AyyBottom, ResultTypeSurface.AyyTop
                }, document, elementType));

                // Add section to the document body
                body.Elements.Add(reinforcementTableSection);
            }

            //////////////////// Reinforcement maps
            {
                // Create document section
                DocumentSection reinforcementMapsSection = new DocumentSection(Resources.ResourceManager.GetString("ReinforcementMaps"), 5);
                reinforcementMapsSection.Level = DetailLevel.Detail;

                // Create and add reinforcement maps
                ResultTypeSurface[] vForceType = { ResultTypeSurface.AxxBottom, ResultTypeSurface.AyyBottom, ResultTypeSurface.AxxTop, ResultTypeSurface.AyyTop };
                List <DocumentMap>  vMap       = CreateResultMapSeriesForSurfaceElements(element, resultsInPointsCollection, vForceType.Select(s => new Tuple <ResultTypeSurface, string>(s, ResultDescription(elementType, s))));
                foreach (DocumentMap map in vMap)
                {
                    reinforcementMapsSection.Body.Elements.Add(map);
                }
                // Add section to the document body
                body.Elements.Add(reinforcementMapsSection);
            }

            //////////////////// Extreme forces table
            List <ResultTypeSurface> nonZeroInternalForces = ResultTypeSurfaceHelper.InternalForcesResults.Where(s => resultsInPointsCollection.Any(r => Math.Abs(r[s]) > Double.Epsilon)).ToList();
            bool isNonZeroInternalForces = (nonZeroInternalForces.Count() > 0);
            {
                // Only for non-zero values
                if (isNonZeroInternalForces)
                {
                    // Create document section
                    DocumentSection extremeForcesTable = new DocumentSection(Resources.ResourceManager.GetString("ExtremeAxialForces"), 5);
                    extremeForcesTable.Level = DetailLevel.Medium;

                    // Add extreme force  table
                    extremeForcesTable.Body.Elements.Add(CreateExtremeResultTableForSurfaceElements(resultsInPointsCollection, ResultTypeSurfaceHelper.InternalForcesResults, document, elementType));

                    // Add section to the document body
                    body.Elements.Add(extremeForcesTable);
                }
            }

            //////////////////// Extreme moments table
            List <ResultTypeSurface> nonZeroInternalMoments = ResultTypeSurfaceHelper.InternalMomentsResults.Where(s => resultsInPointsCollection.Any(r => Math.Abs(r[s]) > Double.Epsilon)).ToList();
            bool isNonZeroInternalMoments = (nonZeroInternalMoments.Count() > 0);
            {
                // Only for non-zero values
                if (isNonZeroInternalMoments)
                {
                    // Create document section
                    DocumentSection extremeMomentsTable = new DocumentSection(Resources.ResourceManager.GetString("ExtremeBendingMoments"), 5);
                    extremeMomentsTable.Level = DetailLevel.Medium;

                    // Add extreme moment  table
                    extremeMomentsTable.Body.Elements.Add(CreateExtremeResultTableForSurfaceElements(resultsInPointsCollection, ResultTypeSurfaceHelper.InternalMomentsResults, document, elementType));

                    // Add section to the document body
                    body.Elements.Add(extremeMomentsTable);
                }
            }

            //////////////////// Force envelopes table
            {
                // Only for non-zero values
                if (isNonZeroInternalForces)
                {
                    // Create document section
                    DocumentSection forceEnvelopesTable = new DocumentSection(Resources.ResourceManager.GetString("EnvelopeF"), 5);
                    forceEnvelopesTable.Level = DetailLevel.Detail;

                    // Add extreme force  table
                    forceEnvelopesTable.Body.Elements.Add(CreateResultTableForSurfaceElements(resultsInPointsCollection, ResultTypeSurfaceHelper.InternalForcesResults, document, elementType));

                    // Add section to the document body
                    body.Elements.Add(forceEnvelopesTable);
                }
            }

            //////////////////// Moments envelopes table
            {
                // Only for non-zero values
                if (isNonZeroInternalMoments)
                {
                    // Create document section
                    DocumentSection momentEnvelopesTable = new DocumentSection(Resources.ResourceManager.GetString("EnvelopeM"), 5);
                    momentEnvelopesTable.Level = DetailLevel.Detail;

                    // Add extreme force  table
                    momentEnvelopesTable.Body.Elements.Add(CreateResultTableForSurfaceElements(resultsInPointsCollection, ResultTypeSurfaceHelper.InternalMomentsResults, document, elementType));

                    // Add section to the document body
                    body.Elements.Add(momentEnvelopesTable);
                }
            }
        }