integrate Revit 2025 SDK

This commit is contained in:
Jeremy Tammik
2024-04-11 13:47:20 +02:00
parent e786953544
commit f414362f2b
889 changed files with 26676 additions and 26865 deletions
@@ -1,11 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
None
</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -242,4 +236,4 @@
</Target>
-->
</Project>
</Project>
@@ -1,77 +0,0 @@
//
// (C) Copyright 2003-2013 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB.CodeChecking.Engineering;
/// <structural_toolkit_2015>
namespace CodeCheckingConcreteExample.Concrete
{
class InternalForcesSurface : InternalForcesBase
{
public InternalForcesSurface()
{
ForceFxx = 0.0; ForceFyy = 0.0; ForceFxy = 0.0;
MomentMxx = 0.0; MomentMyy = 0.0; MomentMxy = 0.0;
LimitState = ForceLimitState.Unknown;
ForceDescription = "";
}
public InternalForcesContainer Forces(ConcreteTypes.DimensioningDirection direction)
{
InternalForcesContainer forces = new InternalForcesContainer();
forces.CaseName = ForceDescription;
forces.LimitState = LimitState;
if (direction == ConcreteTypes.DimensioningDirection.X)
{
forces.ForceFx = -ForceFxx; // Due to ResultBuilder conventions of the forces sign.
forces.MomentMy = -MomentMxx; // Due to ResultBuilder conventions of the forces sign.
forces.ForceFz = ForceQxx;
}
else
{
forces.ForceFx = -ForceFyy; // Due to ResultBuilder conventions of the forces sign.
forces.MomentMy = -MomentMyy; // Due to ResultBuilder conventions of the forces sign.
forces.ForceFz = ForceQyy;
}
return forces;
}
public double ForceFxx { get; set; }
public double ForceFyy { get; set; }
public double ForceFxy { get; set; }
public double MomentMxx { get; set; }
public double MomentMyy { get; set; }
public double MomentMxy { get; set; }
public double ForceQxx { get; set; }
public double ForceQyy { get; set; }
public ForceLimitState LimitState { get; set; }
public string ForceDescription { get; set; }
}
}
/// </structural_toolkit_2015>
@@ -1,135 +0,0 @@
//
// (C) Copyright 2003-2013 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.CodeChecking.Engineering;
using Autodesk.CodeChecking.Concrete;
using CodeCheckingConcreteExample.Engine;
using CodeCheckingConcreteExample.Concrete;
using CodeCheckingConcreteExample.Utility;
using CodeCheckingConcreteExample.ConcreteTypes;
using DD = CodeCheckingConcreteExample.ConcreteTypes.DimensioningDirection;
/// <structural_toolkit_2015>
namespace CodeCheckingConcreteExample.Main.Calculation
{
class SurfaceSection : SectionDataBase
{
/// <summary>
/// Initializes a new instance of user's section object of linear element.
/// </summary>
/// <param name="sectionDataBase">Instance of base section object with predefined parameters to copy.</param>
public SurfaceSection(SectionDataBase sectionDataBase)
: base(sectionDataBase)
{
DesignWarning = new Dictionary<DD, List<string>>() { { DD.X, new List<string>() }, { DD.Y, new List<string>() } };
DesignInfo = new Dictionary<DD, List<string>>() { { DD.X, new List<string>() }, { DD.Y, new List<string>() } };
DesignError = new Dictionary<DD, List<string>>() { { DD.X, new List<string>() }, { DD.Y, new List<string>() } };
}
/// <summary>
/// Gets analitical results for RC surface elements (floor, slab, wall)
/// </summary>
/// <returns>Analitical results in the section.</returns>
public ResultInPointSurface GetCalcResultsInPt()
{
ResultInPointSurface resultInPoint = new ResultInPointSurface();
List<InternalForcesBase> vForces = ListInternalForces;
resultInPoint[ResultTypeSurface.X] = (CalcPoint as CalcPointSurface).Coord.X;
resultInPoint[ResultTypeSurface.Y] = (CalcPoint as CalcPointSurface).Coord.Y;
resultInPoint[ResultTypeSurface.Z] = (CalcPoint as CalcPointSurface).Coord.Z;
IEnumerable<double> vmxx = from ifo in vForces let mxx = (ifo as InternalForcesSurface).MomentMxx select mxx;
resultInPoint[ResultTypeSurface.MxxMax] = vmxx.Max();
resultInPoint[ResultTypeSurface.MxxMin] = vmxx.Min();
IEnumerable<double> vmyy = from ifo in vForces let myy = (ifo as InternalForcesSurface).MomentMyy select myy;
resultInPoint[ResultTypeSurface.MyyMax] = vmyy.Max();
resultInPoint[ResultTypeSurface.MyyMin] = vmyy.Min();
IEnumerable<double> vmxy = from ifo in vForces let mxy = (ifo as InternalForcesSurface).MomentMxy select mxy;
resultInPoint[ResultTypeSurface.MxyMax] = vmxy.Max();
resultInPoint[ResultTypeSurface.MxyMin] = vmxy.Min();
IEnumerable<double> fmxx = from ifo in vForces let fxx = (ifo as InternalForcesSurface).ForceFxx select fxx;
resultInPoint[ResultTypeSurface.FxxMax] = fmxx.Max();
resultInPoint[ResultTypeSurface.FxxMin] = fmxx.Min();
IEnumerable<double> fmyy = from ifo in vForces let fyy = (ifo as InternalForcesSurface).ForceFyy select fyy;
resultInPoint[ResultTypeSurface.FyyMax] = fmyy.Max();
resultInPoint[ResultTypeSurface.FyyMin] = fmyy.Min();
IEnumerable<double> fmxy = from ifo in vForces let fxy = (ifo as InternalForcesSurface).ForceFxy select fxy;
resultInPoint[ResultTypeSurface.FxyMax] = fmxy.Max();
resultInPoint[ResultTypeSurface.FxyMin] = fmxy.Min();
IEnumerable<double> qmxx = from ifo in vForces let qxx = (ifo as InternalForcesSurface).ForceQxx select qxx;
resultInPoint[ResultTypeSurface.QxxMax] = qmxx.Max();
resultInPoint[ResultTypeSurface.QxxMin] = qmxx.Min();
IEnumerable<double> qmyy = from ifo in vForces let qyy = (ifo as InternalForcesSurface).ForceQyy select qyy;
resultInPoint[ResultTypeSurface.QyyMax] = qmyy.Max();
resultInPoint[ResultTypeSurface.QyyMin] = qmyy.Min();
resultInPoint[ResultTypeSurface.AxxBottom] = AsBottom[DD.X];
resultInPoint[ResultTypeSurface.AxxTop] = AsTop[DD.X];
resultInPoint[ResultTypeSurface.AyyBottom] = AsBottom[DD.Y];
resultInPoint[ResultTypeSurface.AyyTop] = AsTop[DD.Y];
return resultInPoint;
}
public List<InternalForcesBase> ListInternalForces { get; set; }
public Geometry Geometry { get; set; }
public double Width { get; set; }
public double Height { get; set; }
public Dictionary<DD, double> AsBottom = new Dictionary<DD, double>() { { DD.X, 0.00 }, { DD.Y, 0.00 } };
public Dictionary<DD, double> AsTop = new Dictionary<DD, double>() { { DD.X, 0.00 }, { DD.Y, 0.00 } };
public Dictionary<DD, double> MinStiffnes = new Dictionary<DD, double>() { { DD.X, 0.0 }, { DD.Y, 0.0 } };
public Dictionary<DD, List<Rebar>> LRebar = new Dictionary<DD, List<Rebar>>() { { DD.X, null }, { DD.Y, null } };
/// <summary>
/// Gets and sets a list of texts with calculation warnings.
/// </summary>
public Dictionary<DD, List<string>> DesignWarning { get; set; }
/// <summary>
/// Gets and sets a list of texts with additional calculation information.
/// </summary>
public Dictionary<DD, List<string>> DesignInfo { get; set; }
/// <summary>
/// Gets and sets a list of texts with calculation errors.
/// </summary>
public Dictionary<DD, List<string>> DesignError { get; set; }
/// <summary>
/// Gets and sets cref="ElementInfo" object.
/// </summary>
public ElementInfo Info { get; set; }
}
}
/// </structural_toolkit_2015>
@@ -1,130 +0,0 @@
//
// (C) Copyright 2003-2013 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB.ExtensibleStorage;
using Autodesk.Revit.DB;
using CodeCheckingConcreteExample.Utility;
namespace CodeCheckingConcreteExample.Main
{
/// <summary>
/// Container for surface element results data
/// </summary>
[Autodesk.Revit.DB.ExtensibleStorage.Framework.Attributes.Schema("ResultSurface", "37147943-1A9A-44E8-8BAC-20628BC26896")]
public class ResultSurfaceElement : Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass
{
/// <summary>
/// Collection of values representing element results in raw format
/// </summary>
[Autodesk.Revit.DB.ExtensibleStorage.Framework.Attributes.SchemaProperty(Unit = Autodesk.Revit.DB.UnitType.UT_Length, DisplayUnit = Autodesk.Revit.DB.DisplayUnitType.DUT_METERS)]
public List<Double> ValuesInPointsData { get; set; }
/// <summary>
/// Information that the surface object is multilayer.
/// </summary>
[Autodesk.Revit.DB.ExtensibleStorage.Framework.Attributes.SchemaProperty()]
public bool MultiLayer { get; set; }
/// <summary>
/// Collection of layer thickness
/// </summary>
[Autodesk.Revit.DB.ExtensibleStorage.Framework.Attributes.SchemaProperty(Unit = Autodesk.Revit.DB.UnitType.UT_Length, DisplayUnit = Autodesk.Revit.DB.DisplayUnitType.DUT_METERS)]
public List<Double> StructuralLayersThickness { get; set; }
/// <summary>
/// Collection of layer materials name
/// </summary>
[Autodesk.Revit.DB.ExtensibleStorage.Framework.Attributes.SchemaProperty()]
public List<String> StructuralLayersMaterialName { get; set; }
/// <summary>
/// Informationa about structural layers for multilayers object
/// </summary>
/// <returns>List of names and thickness of structural layers</returns>
public List<Tuple<string, double>> GetStructuralLayers()
{
int numberOfLayers = StructuralLayersThickness.Count();
if (numberOfLayers != StructuralLayersMaterialName.Count())
throw new Exception("Invalid layers properties");
List<Tuple<string, double>> layers = new List<Tuple<string, double>>();
for (int layersId = 0; layersId < numberOfLayers; layersId++)
{
layers.Add(new Tuple<string, double>(StructuralLayersMaterialName[layersId],StructuralLayersThickness[layersId]));
}
return layers;
}
/// <summary>
/// Removing information about all structural layers
/// </summary>
public void ClearStructuralLayers()
{
StructuralLayersThickness.Clear();
StructuralLayersMaterialName.Clear();
}
/// <summary>
/// Adds new structural layer
/// </summary>
/// <param name="materialName">Material name for layer</param>
/// <param name="thickness">Thickness of layer</param>
public void AddStructuralLayer(string materialName, double thickness)
{
StructuralLayersThickness.Add(thickness);
StructuralLayersMaterialName.Add(materialName);
}
/// <summary>
/// Gets results in point formatted as a list of ResultInPointSurface elements
/// </summary>
/// <returns>List of ResultInPointSurface</returns>
public List<ResultInPointSurface> GetResultsInPointsCollection()
{
IEnumerable<ResultTypeSurface> vType = Enum.GetValues(typeof(ResultTypeSurface)).OfType<ResultTypeSurface>();
int numberOfValsInPoint = vType.Count(),
numberOfPoints = ValuesInPointsData.Count / numberOfValsInPoint;
List<ResultInPointSurface> resultsInPoints = new List<ResultInPointSurface>();
for (int ptId = 0; ptId < numberOfPoints; ptId++)
{
resultsInPoints.Add(new ResultInPointSurface(ValuesInPointsData.GetRange(ptId * numberOfValsInPoint, numberOfValsInPoint)));
}
return resultsInPoints;
}
/// <summary>
/// Creates default ResultSurfaceElement
/// </summary>
public ResultSurfaceElement()
{
ValuesInPointsData = new List<double>();
StructuralLayersThickness = new List<double>();
StructuralLayersMaterialName = new List<string>();
MultiLayer = false;
}
}
}
@@ -1,404 +0,0 @@
//
// (C) Copyright 2003-2013 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB.CodeChecking;
using Autodesk.Revit.DB.CodeChecking.Documentation;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.DB.ExtensibleStorage.Framework.Documentation;
using Autodesk.Revit.DB.ExtensibleStorage;
using Autodesk.Revit.DB.CodeChecking.Engineering;
using Autodesk.Revit.DB.CodeChecking.Engineering.Concrete;
using CodeCheckingConcreteExample.Utility;
using CodeCheckingConcreteExample.Main;
using CodeCheckingConcreteExample.Properties;
using Autodesk.Revit.DB.CodeChecking.Engineering.Tools;
/// <structural_toolkit_2015>
namespace CodeCheckingConcreteExample.Server
{
public partial class Server : Autodesk.Revit.DB.CodeChecking.Documentation.MultiStructureServer
{
/// <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);
}
}
}
/// <summary>
/// Returns UI descriptions depends to element type and results type.
/// </summary>
/// <param name="elementType">Typ of element</param>
/// <param name="result">Results.</param>
/// <returns>Description that can be displayed on the maps and in the table.</returns>
private string ResultDescription(ElementType elementType, ResultTypeSurface result)
{
string description = string.Empty;
switch (result)
{
case ResultTypeSurface.AxxBottom:
case ResultTypeSurface.AxxTop:
case ResultTypeSurface.AyyBottom:
case ResultTypeSurface.AyyTop:
description = Resources.ResourceManager.GetString(elementType.ToString() + result.ToString());
break;
default:
description = Resources.ResourceManager.GetString(result.ToString());
break;
}
if (null == description)
description = result.ToString();
return description;
}
/// <summary>
/// Creates maps based on surface results. The maps can be displayed in the documentation.
/// </summary>
/// <param name="element">Revit element for which result document is built</param>
/// <param name="resultsInPoints">Result in point collection</param>
/// <param name="resultTypes">The type of results, values and description that can be displayed on the maps.</param>
/// <returns>Returns list of documets maps based on results that can be displayed in the documentation</returns>
private List<DocumentMap> CreateResultMapSeriesForSurfaceElements(Element element, ICollection<ResultInPointSurface> resultsInPoints, IEnumerable<Tuple<ResultTypeSurface, string>> resultTypes)
{
List<DocumentMap> vDocMap = new List<DocumentMap>();
MapDataGenerator mapPoints = new MapDataGenerator();
foreach (Tuple<ResultTypeSurface, string> forceDesc in resultTypes)
{
List<double> resData = resultsInPoints.Select(s => s[forceDesc.Item1]).ToList();
if (resData.Max(s => (Math.Abs(s))) < 1.0e-8)
{
continue;
}
AnalyticalModel slab = element as AnalyticalModel;
DisplayUnit displayUnit = DisplayUnit.IMPERIAL;
if (Server.UnitSystem == Autodesk.Revit.DB.ResultsBuilder.UnitsSystem.Metric)
displayUnit = DisplayUnit.METRIC;
ElementAnalyser elementAnalyser = new ElementAnalyser(displayUnit);
ElementInfo info = elementAnalyser.Analyse(element);
XYZ xyz = new XYZ();
if (info != null)
{
foreach (ResultInPointSurface resInPt in resultsInPoints)
{
mapPoints.AddPoint(new XYZ(resInPt[ResultTypeSurface.X], resInPt[ResultTypeSurface.Y], resInPt[ResultTypeSurface.Z]), resInPt[forceDesc.Item1]);
}
var contourAndHoles = getContourAndHolePoints(info);
contourAndHoles.Item1.ForEach( s=>mapPoints.AddPointToContour(s));
contourAndHoles.Item2.ForEach( s=>mapPoints.AddHole(s));
UnitType ut = forceDesc.Item1.GetUnitType();
DocumentMap docMap = new DocumentMap(ut, UnitsConverter.GetInternalUnit(ut));
docMap.Title = forceDesc.Item2;
int nofPoints = mapPoints.Count;
for (int ptId = 0; ptId < nofPoints; ptId++)
{
UV pt = mapPoints.GetPoint(ptId);
docMap.AddPoint(pt.U, pt.V, mapPoints.GetValue(ptId));
}
List<List<int>> holes = mapPoints.Holes;
foreach (List<int> hole in holes)
{
docMap.AddHole(hole);
}
docMap.DefineContour(mapPoints.Contour);
vDocMap.Add(docMap);
}
mapPoints.Clear();
}
return vDocMap;
}
private Tuple<List<XYZ>,List<List<XYZ>>> getContourAndHolePoints( ElementInfo info)
{
List<XYZ> contour = null;
List<List<XYZ>> holes = null;
if( info.Type==Autodesk.Revit.DB.CodeChecking.Engineering.ElementType.Slab )
{
contour = info.Slabs.AsElement.Contours.First(c=>c.ContourType==SlabContourType.Main).Edges.SelectMany( e=>e.Nodes.Select( n=>n.GetGlobalCoordinates())).ToList();
holes = info.Slabs.AsElement.Contours.Where( c=>c.ContourType==SlabContourType.Hole).Select
( hc=> hc.Edges.SelectMany( e=>e.Nodes.Select( n=>n.GetGlobalCoordinates())).ToList() ).ToList();
}
else if (info.Type == Autodesk.Revit.DB.CodeChecking.Engineering.ElementType.Wall)
{
contour = info.Walls.AsElement.Transform.ManyPoints2Global( info.Walls.AsElement.Contour.Points ).ToList();
holes = info.Walls.AsElement.Openings.Select(o => info.Walls.AsElement.Transform.ManyPoints2Global(o.Points).ToList()).ToList();
}
return new Tuple<List<XYZ>, List<List<XYZ>>>(contour,holes);
}
/// <summary>
/// Creates result table based on surface results.
/// </summary>
/// <param name="resInPtCollection">Result in point collection</param>
/// <param name="resultTypes">The type of results, values and description to use in the table.</param>
/// <param name="document">Revit document</param>
/// <param name="elementType">Type of element</param>
/// <returns>Document table containing surface results</returns>
private DocumentTable CreateResultTableForSurfaceElements(List<ResultInPointSurface> resInPtCollection, IEnumerable<ResultTypeSurface> resultTypes, Autodesk.Revit.DB.Document document, ElementType elementType)
{
// results table data
int rowsCount = 1 + resInPtCollection.Count(),
colsCount = (ElementType.Wall == elementType ? 3 : 2) + resultTypes.Count();
Units units = document.GetUnits();
DocumentTable resultTable = new DocumentTable( rowsCount, colsCount);
resultTable.HeaderColumnsCount = ElementType.Wall == elementType ? 3 : 2;
resultTable.HeaderRowsCount = 1;
// results table data
List<ResultTypeSurface> typesToPresent = ElementType.Wall == elementType ? new List<ResultTypeSurface>() { ResultTypeSurface.X, ResultTypeSurface.Y, ResultTypeSurface.Z } : new List<ResultTypeSurface>() { ResultTypeSurface.X, ResultTypeSurface.Y };
typesToPresent.AddRange(resultTypes);
int colId = 0;
foreach (ResultTypeSurface resultType in typesToPresent)
{
resultTable[0, colId].Elements.Add(new DocumentText(ResultDescription(elementType,resultType)));
UnitType unitType = resultType.GetUnitType();
DisplayUnitType displayUnitType = Utility.UnitsConverter.GetInternalUnit(unitType);
int rowId = 1;
foreach (ResultInPointSurface resultInPoint in resInPtCollection)
{
if (DisplayUnitType.DUT_UNDEFINED != displayUnitType)
{
resultTable[rowId++, colId].Elements.Add(new DocumentValue(resultInPoint[resultType], displayUnitType, unitType, units));
}
else
{
resultTable[rowId++, colId].Elements.Add(new DocumentText(resultInPoint[resultType].ToString()));
}
}
colId++;
}
return resultTable;
}
/// <summary>
/// Creates result table based on surface results that contains extreme values for specified result types.
/// </summary>
/// <param name="resInPtCollection">Result in point collection</param>
/// <param name="resultTypes">The type of results, values and description to use in the table.</param>
/// <param name="document">Revit document</param>
/// <param name="elementType">Type of element</param>
/// <returns>Document table containing surface results</returns>
private DocumentTable CreateExtremeResultTableForSurfaceElements(List<ResultInPointSurface> resInPtCollection, IEnumerable<ResultTypeSurface> resultTypes, Autodesk.Revit.DB.Document document, ElementType elementType)
{
IEnumerable<Tuple<ResultTypeSurface, double>> maxValues = resultTypes.Select(s => new Tuple<ResultTypeSurface, double>(s, s.ToString().ToLower().Contains("min") ? resInPtCollection.Min(q => q[s]) : resInPtCollection.Max(q => q[s])));
int rowsCount = 2,
colsCount = resultTypes.Count();
Units units = document.GetUnits();
DocumentTable resultTable = new DocumentTable(rowsCount, colsCount);
resultTable.HeaderColumnsCount = 0;
resultTable.HeaderRowsCount = 1;
// results table data
List<ResultTypeSurface> typesToPresent = new List<ResultTypeSurface>() { ResultTypeSurface.X, ResultTypeSurface.Y };
typesToPresent.AddRange(resultTypes);
int colId=0;
foreach (Tuple<ResultTypeSurface, double> result in maxValues)
{
resultTable[0, colId].Elements.Add(new DocumentText(ResultDescription(elementType, result.Item1)));
UnitType unitType = result.Item1.GetUnitType();
DisplayUnitType displayUnitType = Utility.UnitsConverter.GetInternalUnit(unitType);
if (DisplayUnitType.DUT_UNDEFINED != displayUnitType)
{
resultTable[1, colId].Elements.Add(new DocumentValue(result.Item2, displayUnitType, unitType, units));
}
else
{
resultTable[1, colId].Elements.Add(new DocumentText(result.Item2.ToString()));
}
colId++;
}
return resultTable;
}
}
/// </structural_toolkit_2015>
}
@@ -1,356 +0,0 @@
//
// (C) Copyright 2003-2013 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.Revit.DB;
/// <structural_toolkit_2015>
namespace CodeCheckingConcreteExample.Utility
{
/// <summary>
/// Type of results for rc section
/// </summary>
public enum ResultTypeSurface
{
/// <summary>
/// X position (absolute)
/// </summary>
X,
/// <summary>
/// Y position (absolute)
/// </summary>
Y,
/// <summary>
/// Z position (absolute)
/// </summary>
Z,
/// <summary>
/// Bending moment , x-axis, min value [moment per unit length]
/// </summary>
MxxMin,
/// <summary>
/// Bending moment , x-axis, max value [moment per unit length]
/// </summary>
MxxMax,
/// <summary>
/// Bending moment , y-axis, min value [moment per unit length]
/// </summary>
MyyMin,
/// <summary>
/// Bending moment , x-axis, min value [moment per unit length]
/// </summary>
MyyMax,
/// <summary>
/// Twisting moments, , x-axis/y-axis, min value [moment per unit length]
/// </summary>
MxyMin,
/// <summary>
/// Twisting moments, , x-axis/y-axis, min value [moment per unit length]
/// </summary>
MxyMax,
/// <summary>
/// In-plane forces tension/compresion , x-direction, max value [moment per unit length]
/// </summary>
FxxMin,
/// <summary>
/// In-plane forces tension/compresion, x-direction, min value [force per unit length]
/// </summary>
FxxMax,
/// <summary>
/// In-plane forces tension/compresion, y-direction, max value [force per unit length]
/// </summary>
FyyMin,
/// <summary>
/// In-plane forces tension/compresion, y-direction, min value [force per unit length]
/// </summary>
FyyMax,
/// <summary>
/// In-plane shear forces , y-direction, max value [force per unit length]
/// </summary>
FxyMin,
/// <summary>
/// In-plane shear forces , y-direction, min value [force per unit length]
/// </summary>
FxyMax,
/// <summary>
/// Shear forces , x-direction, max value [force per unit length]
/// </summary>
QxxMin,
/// <summary>
/// Shear forces , x-direction, min value [force per unit length]
/// </summary>
QxxMax,
/// <summary>
/// Shear forces , y-direction, max value [force per unit length]
/// </summary>
QyyMin,
/// <summary>
/// Shear forces , y-direction, max value [force per unit length]
/// </summary>
QyyMax,
/// <summary>
/// Longitudinal reinforcement, bottom [area per unit length], according to Mxx
/// </summary>
AxxBottom,
/// <summary>
/// Longitudinal reinforcement, top [area per unit length], according to Mxx
/// </summary>
AxxTop,
/// <summary>
/// Longitudinal reinforcement, bottom [area per unit length], according to Myy
/// </summary>
AyyBottom,
/// <summary>
/// Longitudinal reinforcement, top [area per unit length], according to Myy
/// </summary>
AyyTop,
/// <summary>
/// Deflection, z-direction, max value
/// </summary>
UzMax,
/// <summary>
/// Deflection, z-direction, min value
/// </summary>
UzMin,
/// <summary>
/// Calculated deflection, z-direction, min value
/// </summary>
UzRealMax,
/// <summary>
/// Calculated deflection, z-direction, max value
/// </summary>
UzRealMin,
}
static class ResultTypeSurfaceHelper
{
/// <summary>
/// Converts value from cref="ResultTypeSurface" into value from cref="ResultType".
/// </summary>
/// <param name="forceType">Type of force.</param>
/// <returns>Type of result.</returns>
static public Autodesk.Revit.DB.CodeChecking.Engineering.ResultType GetResultType(this ResultTypeSurface forceType)
{
Autodesk.Revit.DB.CodeChecking.Engineering.ResultType resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.Unknown;
switch (forceType)
{
// reinforcement
case ResultTypeSurface.AxxBottom: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.AxxBottom; break;
case ResultTypeSurface.AxxTop: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.AxxTop; break;
case ResultTypeSurface.AyyBottom: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.AyyBottom; break;
case ResultTypeSurface.AyyTop: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.AyyTop; break;
// deflection
///TMP
///
/*
case ResultTypeSurface.UxRealMax: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UxMax; break;
case ResultTypeSurface.UxRealMin: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UxMin; break;
case ResultTypeSurface.UyRealMax: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UyMax; break;
case ResultTypeSurface.UyRealMin: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UyMin; break;
case ResultTypeSurface.UzRealMax: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UzMax; break;
case ResultTypeSurface.UzRealMin: resultType = Autodesk.Revit.DB.CodeChecking.Engineering.ResultType.UzMin; break;
* */
}
return resultType;
}
/// <summary>
/// Gets unit for a specific Result type
/// </summary>
/// <param name="forceType"></param>
/// <returns></returns>
static public UnitType GetUnitType(this ResultTypeSurface forceType)
{
return ResultInPointSurface.ValueType[(int)forceType];
}
/// <summary>
/// Gets reinforcement result types
/// </summary>
static public List<ResultTypeSurface> ReinforcementResults
{
get { return new List<ResultTypeSurface> { ResultTypeSurface.AxxBottom, ResultTypeSurface.AxxTop, ResultTypeSurface.AyyBottom, ResultTypeSurface.AxxTop}; }
}
/// <summary>
/// Gets displacement result types
/// </summary>
static public List<ResultTypeSurface> DisplacementResults
{
get
{
return new List<ResultTypeSurface>
{
ResultTypeSurface.UzMax, ResultTypeSurface.UzMin,
};
}
}
/// <summary>
/// Gets real deflection result types
/// </summary>
static public List<ResultTypeSurface> RealDeflectionResults
{
get
{
return new List<ResultTypeSurface>
{
ResultTypeSurface.UzRealMax, ResultTypeSurface.UzRealMin,
};
}
}
/// <summary>
/// Gets base internal forces result types
/// </summary>
static public List<ResultTypeSurface> InternalForcesResults
{
get
{
return new List<ResultTypeSurface>
{
ResultTypeSurface.FxxMin, ResultTypeSurface.FxxMax, ResultTypeSurface.FyyMin, ResultTypeSurface.FyyMax,
};
}
}
/// <summary>
/// Gets all internal forces result types
/// </summary>
static public List<ResultTypeSurface> InternalForcesResultsAll
{
get
{
return new List<ResultTypeSurface>
{
ResultTypeSurface.FxxMin, ResultTypeSurface.FxxMax, ResultTypeSurface.FyyMin, ResultTypeSurface.FyyMax, ResultTypeSurface.FxyMin, ResultTypeSurface.FxyMax,
};
}
}
/// <summary>
/// Gets base internal moments result types
/// </summary>
static public List<ResultTypeSurface> InternalMomentsResults
{
get
{
return new List<ResultTypeSurface>
{
ResultTypeSurface.MxxMin, ResultTypeSurface.MxxMax, ResultTypeSurface.MyyMin, ResultTypeSurface.MyyMax
};
}
}
/// <summary>
/// Gets all internal moments result types
/// </summary>
static public List<ResultTypeSurface> InternalMomentsResultsAll
{
get
{
return new List<ResultTypeSurface>
{
ResultTypeSurface.MxxMin, ResultTypeSurface.MxxMax, ResultTypeSurface.MyyMin, ResultTypeSurface.MyyMax, ResultTypeSurface.MxyMin, ResultTypeSurface.MxyMax,
};
}
}
}
/// <summary>
/// Container representing analitical results in RC surface section
/// Results are represented as numbers along with their respective units
/// </summary>
public class ResultInPointSurface
{
private double[] data = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
static internal UnitType[] ValueType = new UnitType[] { UnitType.UT_Length,
UnitType.UT_Length,
UnitType.UT_Length,
UnitType.UT_LinearMoment,
UnitType.UT_LinearMoment,
UnitType.UT_LinearMoment,
UnitType.UT_LinearMoment,
UnitType.UT_LinearMoment,
UnitType.UT_LinearMoment,
UnitType.UT_LinearForce,
UnitType.UT_LinearForce,
UnitType.UT_LinearForce,
UnitType.UT_LinearForce,
UnitType.UT_LinearForce,
UnitType.UT_LinearForce,
UnitType.UT_LinearForce,
UnitType.UT_LinearForce,
UnitType.UT_LinearForce,
UnitType.UT_LinearForce,
UnitType.UT_Reinforcement_Area_per_Unit_Length,
UnitType.UT_Reinforcement_Area_per_Unit_Length,
UnitType.UT_Reinforcement_Area_per_Unit_Length,
UnitType.UT_Reinforcement_Area_per_Unit_Length,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection,
UnitType.UT_Displacement_Deflection};
/// <summary>
/// Creates default ResultInPointSurface
/// </summary>
public ResultInPointSurface() { }
/// <summary>
/// Creates default ResultInPointLinear
/// </summary>
/// <param name="data">List of result according to ResultTypeSurface order</param>
public ResultInPointSurface(IEnumerable<double> data) { DataRaw = data.ToArray(); }
/// <summary>
/// Access to the raw format of surface section results
/// </summary>
public double[] DataRaw {
get { return data; }
set {
int reqSize = Enum.GetValues(typeof(ResultTypeSurface)).Length;
if (value.Count() != reqSize)
{
throw new ArgumentException("Value list lenght should be equal to " + reqSize);
}
else
{
data = value;
}
}
}
/// <summary>
/// Access to a specific result
/// </summary>
/// <param name="type">Result type</param>
/// <returns>Formatted result value</returns>
public double this[ResultTypeSurface type]
{
get { return data[(int)type]; }
set
{
if (Double.IsNaN(value))
{
throw new ArgumentOutOfRangeException(type.ToString() + "Cannot be NAN");
}
data[(int)type] = value;
}
}
}
}
/// </structural_toolkit_2015>