Structural Analysis Toolkit, ResultsBuilder, Reviewing Stored Results in Revit
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.
Interestingly, adding arbitrary results seems to work, but that is not something that I want at the moment.
Everything is being tested in Revit 2020.
Any help would be appreciated.