Structural Analysis Toolkit, ResultsBuilder, Reviewing Stored Results in Revit

ahmadizm
Participant
Participant

Structural Analysis Toolkit, ResultsBuilder, Reviewing Stored Results in Revit

ahmadizm
Participant
Participant

Hi,

 

I was trying to store some structural analysis results, but failed to see the results/diagrams inside Revit after writing the data. So I went back to the SDK examples that usie ResultsBuilder, and cannot even get that to work. Or maybe I don't know how to retrieve the results that are stored using resultsPackageBuilder.SetBarResult in Revit UI.

 

To reproduce my problem, I changed the sample code to only write the linear results for a stick element (column) in the ResultsInRevit.rvt model that comes with Structural SDK:

 

Transaction trans = new Transaction(doc);
         try
         {
            trans.SetName("ResultsInRevit_Transaction");
            trans.Start();

ResultsPackageBuilder resultsPackageBuilder = createResultsPackageBuilder(doc);
AddLinearResults(resultsPackageBuilder, linearElementId, new ElementId[] { loadCaseId1, loadCaseId2 });
resultsPackageBuilder.Finish(); trans.Commit(); } catch (Exception ex) { // Rollback transaction and display warning if there were any problems trans.RollBack(); Autodesk.Revit.UI.TaskDialog.Show("Failed to write results to Revit", ex.Message.ToString()); retVal = Autodesk.Revit.UI.Result.Failed; }

And I left the other app parts unchanged. I am using something similar to AddLinearResults for my purpose:

 

private void AddLinearResults(ResultsPackageBuilder resultsPackageBuilder, ElementId elementId, ElementId []loadCaseIds)
      {
         // Create a list of points ( represented here by relative coordinates on the element ) in which results will be stored
         List<double> xCoordinateValues = new List<double>() { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 };

         // Create list of some results
         // Each list element contains result type and a list of result values
         List<Tuple<LinearResultType, List<double>>> valuesForForceType = new List<Tuple<LinearResultType, List<double>>>()
         {
            new Tuple<LinearResultType,List<double>> ( LinearResultType.Fx, new List<double>() {  4.01,  4.02,  4.03,  4.04,  4.05, 4.06, 4.07, 4.08, 4.09, 4.10 }),
            new Tuple<LinearResultType,List<double>> ( LinearResultType.Fy, new List<double>() { -0.40, -0.30, -0.20, -0.10,  0.00, 0.10, 0.20, 0.30, 0.40, 0.50 }),
            new Tuple<LinearResultType,List<double>> ( LinearResultType.Fz, new List<double>() {  1.00,  1.20,  1.30,  1.40,  1.50, 1.60, 1.70, 1.80, 1.90, 2.00 }),
            new Tuple<LinearResultType,List<double>> ( LinearResultType.Mx, new List<double>() {  1.60,  1.60,  1.60,  1.60,  1.60, 1.60, 1.60, 1.60, 1.60, 1.60 }),
            new Tuple<LinearResultType,List<double>> ( LinearResultType.My, new List<double>() {  1.21,  1.00,  0.90,  0.40,  0.10, 0.10, 0.40, 0.90, 1.00, 1.21 }),
            new Tuple<LinearResultType,List<double>> ( LinearResultType.Mz, new List<double>() {  6.21,  6.00,  5.90,  5.40,  5.10, 5.10, 5.40, 5.90, 6.00, 6.21 }),
         };
            
         // Add results for the first load case
         ElementId loadCaseId1 = loadCaseIds[0];
         // First result domain
         resultsPackageBuilder.SetBarResult(elementId, loadCaseId1, DomainResultType.X, xCoordinateValues);
         // Then result values
         foreach ( var valueForForce in valuesForForceType)
         {
            resultsPackageBuilder.SetBarResult(elementId, loadCaseId1, valueForForce.Item1, valueForForce.Item2);
         }

         // Modify results and add them for the second load case as well
         ElementId loadCaseId2 = loadCaseIds[1];
         resultsPackageBuilder.SetBarResult(elementId, loadCaseId2, DomainResultType.X, xCoordinateValues);
         foreach (var valueForForce in valuesForForceType)
         {
            resultsPackageBuilder.SetBarResult(elementId, loadCaseId2, valueForForce.Item1, valueForForce.Item2.Select(s => s * 2));
         }

      }

The results are being written for load cases DL1 and LL1. Running this example in Revit on ResultsInRevit.rvt goes through without any errors. But when I want to actually see these results in Revit, it does not show anything for any of the elements/load cases.

 

2019-05-08_0838.png

 

 

Interestingly, adding arbitrary results seems to work, but that is not something that I want at the moment.

 

2019-05-08_0841.png

 

Everything is being tested in Revit 2020.

 

Any help would be appreciated.

0 Likes
Reply
646 Views
3 Replies
Replies (3)

ahmadizm
Participant
Participant

So either this question is irrelevant, or nobody really cares about this.

 

To be clear, ResultsBuilder is a part of Revit Structural Toolkit (an addin by Autodesk), and it is used in Revit Structural SDK as the natural way of storing analysis results in Revit. My question is why the sample that comes with SDK does not seem to work as expected. I would appreciate any comments that can help me resolve this issue.

 

Does anybody recommend avoiding ResultsBuilder and directly using Revit's official API to write the results?

0 Likes

okapawal
Autodesk
Autodesk

Give us some time to investigate your question.

You can write directly to me waldemar.okapa@autodesk.com  to give us more details.



Waldemar Okapa

Sr Product Owner
0 Likes

okapawal
Autodesk
Autodesk

 

Answering the first question:

 

 

When calling the AddLinearResult function, the result package is set as type of  ResultsPackageTypes.All.

 

 

The ResultsPackageTypes.Static type package should be used here because the static analysis results are saved in this function

code1.png

 

 

Answering the second question:

 

Inside function AddArbitraryResults is calling the method with parameter which saying that  results are not dependent on load cases.

 

code2.png

 

In the case of saving the reinforcement results, it is preferable to create a new package that will contain results for reinforcement.

 

        /// <summary>
        /// Creates an empty results package to store reinforcement results
        /// </summary>
        /// <param name="doc">Revit document</param>
        /// <returns>Reference to the newly created package</returns>
        private ResultsPackageBuilder createReinforcementResultsPackageBuilder( Document doc)
      {
         ResultsAccess resultsAccess = ResultsAccess.CreateResultsAccess(doc);
         ResultsPackageBuilder resultsPackageBuilder = resultsAccess.CreateResultsPackage(reinfPackageGuid, "REINFORCEMENT_ResultsInRevit", UnitsSystem.Metric, ResultsPackageTypes.RequiredReinforcement);

         resultsPackageBuilder.SetAnalysisName("Reinforcement__ResultsInRevit_Analysis");
         resultsPackageBuilder.SetModelName("ResultsInRevit_Model");
         resultsPackageBuilder.SetDescription("Sample results");
         resultsPackageBuilder.SetVendorDescription("Autodesk");
         resultsPackageBuilder.SetVendorId("ADSK");

         return resultsPackageBuilder;
      }



        /// <summary>
        /// Adds reinforcement results to a linear element
        /// </summary>
        /// <param name="resultsPackageBuilder">Reference to the results package</param>
        /// <param name="elementId">Id of the linear element to which results are to be added</param>
        private void AddReinforcementLinearResults(ResultsPackageBuilder resultsPackageBuilder, ElementId elementId)
        {
            // Create list of some results
            // Each list element contains result type and a list of result values
            List<Tuple<LinearResultType, List<double>>> valuesForRnf = new List<Tuple<LinearResultType, List<double>>>()
            {
              new Tuple<LinearResultType,List<double>> ( LinearResultType.AsBottom, new List<double>() {  45.00,  30.00,  15.00,  60.00,  0.00, 0.00, 10.00, 0.00, 0.00, 90.00 }),
              new Tuple<LinearResultType,List<double>> ( LinearResultType.AsTop,    new List<double>() {  45.00,  30.00,  15.00,  60.00,  0.00, 0.00, 10.00, 0.00, 0.00, 90.00 }),
              new Tuple<LinearResultType,List<double>> ( LinearResultType.AsLeft,   new List<double>() {  45.00,  30.00,  15.00,  60.00,  0.00, 0.00, 10.00, 0.00, 0.00, 90.00 }),
              new Tuple<LinearResultType,List<double>> ( LinearResultType.AsRight,  new List<double>() {  45.00,  30.00,  15.00,  60.00,  0.00, 0.00, 10.00, 0.00, 0.00, 90.00 }),
            };

            // Add result domain for load independent results
            List<double> xCoordinateValues = new List<double>() { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 };
            resultsPackageBuilder.SetBarResult(elementId, null, DomainResultType.X, xCoordinateValues);
            // Add result values
            foreach (var valueForRnf in valuesForRnf)
            {
                resultsPackageBuilder.SetBarResult(elementId, null, valueForRnf.Item1, valueForRnf.Item2);
            }
        }

        /// <summary>
        /// Auxiliary method. Generates a list of sample reinforcement results for points on surface element contour
        /// </summary>
        /// <param name="points">List of points for which arbitrary results are to be generated</param>
        /// <returns>A list containing a number of records with arbitrary surface result type and corresponding result values</returns>
        private List<Tuple<SurfaceResultType, List<double>>> GenerateSampleReinforcementSurfaceResultsForContour(List<XYZ> points)
        {
            // Create an array of arbitrary result types.
            SurfaceResultType[] surfaceResultTypes = { SurfaceResultType.AxxBottom, SurfaceResultType.AyyBottom, SurfaceResultType.AxxTop, SurfaceResultType.AyyTop };

            // Create list
            var sampleResults = new List<Tuple<SurfaceResultType, List<double>>>();
            double coeff = 1.0e-4;
            // Iterate over types, create a value for each point and add a record to the list
            foreach (SurfaceResultType surfaceResultType in surfaceResultTypes)
            {
                coeff *= 1.5;
                List<double> results = points.Select(s => (s.X * coeff + s.Y * coeff + s.Z * coeff)).ToList();
                sampleResults.Add(new Tuple<SurfaceResultType, List<double>>(surfaceResultType, results));
            }
            return sampleResults;
        }



       

I am attaching  new source code, if you use it, you will see in Revit

 

ResBuilder.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 



Waldemar Okapa

Sr Product Owner