mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-08-19 03:33:44 +00:00
added Revit 2020 SDK files
This commit is contained in:
+643
@@ -0,0 +1,643 @@
|
||||
//
|
||||
// (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;
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace CodeCheckingConcreteExample.Server
|
||||
{
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.CalculationParamsStructure(typeof(CalculationParameter))]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.LabelStructure(typeof(LabelBeam), BuiltInCategory.OST_BeamAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.LabelStructure(typeof(LabelColumn), BuiltInCategory.OST_ColumnAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.ResultStructure(typeof(ResultBeam), BuiltInCategory.OST_BeamAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.ResultStructure(typeof(ResultColumn), BuiltInCategory.OST_ColumnAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
/// <structural_toolkit_2015>
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.LabelStructure(typeof(LabelWall), BuiltInCategory.OST_WallAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.LabelStructure(typeof(LabelFloor), BuiltInCategory.OST_FloorAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.LabelStructure(typeof(LabelFloor), BuiltInCategory.OST_FoundationSlabAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.ResultStructure(typeof(ResultWall), BuiltInCategory.OST_WallAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.ResultStructure(typeof(ResultFloor), BuiltInCategory.OST_FloorAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.ResultStructure(typeof(ResultFloor), BuiltInCategory.OST_FoundationSlabAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
/// </structural_toolkit_2015>
|
||||
public partial class Server : Autodesk.Revit.DB.CodeChecking.Documentation.MultiStructureServer
|
||||
{
|
||||
public static readonly Autodesk.Revit.DB.ResultsBuilder.UnitsSystem UnitSystem = Autodesk.Revit.DB.ResultsBuilder.UnitsSystem.Metric;
|
||||
public static readonly Guid ID = new Guid("1d3d13ad-4330-4b4a-bfe3-067ff87a72b1");
|
||||
#region ICodeCheckingServer Members
|
||||
|
||||
public override Entity GetDefaultLabel(Autodesk.Revit.DB.Document document, StructuralAssetClass material, BuiltInCategory category)
|
||||
{
|
||||
switch (material)
|
||||
{
|
||||
case StructuralAssetClass.Concrete:
|
||||
switch (category)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical:
|
||||
{
|
||||
IList<ElementId> materials = RebarUtility.GetListMaterialOfRebars(document);
|
||||
if (materials.Count > 0)
|
||||
{
|
||||
IList<ElementId> barsIds = RebarUtility.GetListRebarForMaterial(document, materials[0]);
|
||||
if (barsIds.Count > 0)
|
||||
{
|
||||
LabelColumn label = new LabelColumn();
|
||||
label.LongitudinalReinforcement.Material = document.GetElement(materials[0]) as Material;
|
||||
label.LongitudinalReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]);
|
||||
|
||||
label.TransversalReinforcement.Material = label.LongitudinalReinforcement.Material;
|
||||
label.TransversalReinforcement.RebarBarType = label.LongitudinalReinforcement.RebarBarType;
|
||||
|
||||
return label.GetEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical:
|
||||
{
|
||||
IList<ElementId> materials = RebarUtility.GetListMaterialOfRebars(document);
|
||||
if (materials.Count > 0)
|
||||
{
|
||||
IList<ElementId> barsIds = RebarUtility.GetListRebarForMaterial(document, materials[0]);
|
||||
if (barsIds.Count > 0)
|
||||
{
|
||||
LabelBeam label = new LabelBeam();
|
||||
label.LongitudinalReinforcement.Material = document.GetElement(materials[0]) as Material;
|
||||
label.LongitudinalReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]);
|
||||
|
||||
label.TransversalReinforcement.Material = label.LongitudinalReinforcement.Material;
|
||||
label.TransversalReinforcement.RebarBarType = label.LongitudinalReinforcement.RebarBarType;
|
||||
|
||||
return label.GetEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
/// <structural_toolkit_2015>
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical:
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical:
|
||||
{
|
||||
IList<ElementId> materials = RebarUtility.GetListMaterialOfRebars(document);
|
||||
if (materials.Count > 0)
|
||||
{
|
||||
IList<ElementId> barsIds = RebarUtility.GetListRebarForMaterial(document, materials[0]);
|
||||
if (barsIds.Count > 0)
|
||||
{
|
||||
LabelFloor label = new LabelFloor();
|
||||
label.PrimaryReinforcement.Material = document.GetElement(materials[0]) as Material;
|
||||
label.PrimaryReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]);
|
||||
label.SecondaryReinforcement.Material = document.GetElement(materials[0]) as Material;
|
||||
label.SecondaryReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]);
|
||||
return label.GetEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical:
|
||||
{
|
||||
IList<ElementId> materials = RebarUtility.GetListMaterialOfRebars(document);
|
||||
if (materials.Count > 0)
|
||||
{
|
||||
IList<ElementId> barsIds = RebarUtility.GetListRebarForMaterial(document, materials[0]);
|
||||
if (barsIds.Count > 0)
|
||||
{
|
||||
LabelWall label = new LabelWall();
|
||||
label.VerticalReinforcement.Material = document.GetElement(materials[0]) as Material;
|
||||
label.VerticalReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]);
|
||||
label.HorizontalReinforcement.Material = document.GetElement(materials[0]) as Material;
|
||||
label.HorizontalReinforcement.RebarBarType = RebarUtility.GetRebarType(document, barsIds[0]);
|
||||
return label.GetEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
/// </structural_toolkit_2015>
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return base.GetDefaultLabel(document, material, category);
|
||||
}
|
||||
/// <structural_toolkit_2015>
|
||||
|
||||
|
||||
// TODO : REMOVE
|
||||
|
||||
/// <summary>
|
||||
/// Classification of elements type
|
||||
/// </summary>
|
||||
public enum ElementType {
|
||||
/// <summary>
|
||||
/// RC Beam
|
||||
/// </summary>
|
||||
Beam,
|
||||
/// <summary>
|
||||
/// RC Column
|
||||
/// </summary>
|
||||
Column,
|
||||
/// <summary>
|
||||
/// RC Floor and Slab foundation
|
||||
/// </summary>
|
||||
Floor,
|
||||
/// <summary>
|
||||
/// RC Wall
|
||||
/// </summary>
|
||||
Wall
|
||||
}
|
||||
/// </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;
|
||||
}
|
||||
/// </structural_toolkit_2015>
|
||||
|
||||
|
||||
|
||||
public override IList<BuiltInCategory> GetSupportedCategories(StructuralAssetClass material)
|
||||
{
|
||||
List<BuiltInCategory> supportedCategories = new List<BuiltInCategory>();
|
||||
supportedCategories.Add(BuiltInCategory.OST_BeamAnalytical);
|
||||
supportedCategories.Add(BuiltInCategory.OST_ColumnAnalytical);
|
||||
/// <structural_toolkit_2015>
|
||||
supportedCategories.Add(BuiltInCategory.OST_FoundationSlabAnalytical);
|
||||
supportedCategories.Add(BuiltInCategory.OST_FloorAnalytical);
|
||||
supportedCategories.Add(BuiltInCategory.OST_WallAnalytical);
|
||||
/// </structural_toolkit_2015>
|
||||
return supportedCategories;
|
||||
}
|
||||
|
||||
public override IList<Autodesk.Revit.DB.StructuralAssetClass> GetSupportedMaterials()
|
||||
{
|
||||
return new List<Autodesk.Revit.DB.StructuralAssetClass>(){
|
||||
Autodesk.Revit.DB.StructuralAssetClass.Concrete};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets the document body for label.
|
||||
/// </summary>
|
||||
/// <param name="label">label.</param>
|
||||
/// <param name="document">document.</param>
|
||||
/// <returns>
|
||||
/// The body of the document.
|
||||
/// </returns>
|
||||
public override DocumentBody BuildLabelDocumentBody(Entity label, Autodesk.Revit.DB.Document document)
|
||||
{
|
||||
switch (label.Schema.SchemaName)
|
||||
{
|
||||
default:
|
||||
return base.BuildLabelDocumentBody(label, document);
|
||||
case "LabelColumn":
|
||||
{
|
||||
DocumentBody body = new DocumentBody();
|
||||
LabelColumn labelColumn = new LabelColumn();
|
||||
labelColumn.SetProperties(label, document);
|
||||
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("CalculationOptions"), 4));
|
||||
|
||||
if (labelColumn.EnabledInternalForces.Count > 0)
|
||||
{
|
||||
body.Elements.Add(new DocumentText(Resources.ResourceManager.GetString("EnabledInternalForces") + ":", true));
|
||||
if (labelColumn.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.FX))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("ColumnFX_Note"), true));
|
||||
if (labelColumn.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.FY))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("ColumnFY_Note"), true));
|
||||
if (labelColumn.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.FZ))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("ColumnFZ_Note"), true));
|
||||
if (labelColumn.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.MX))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("ColumnMX_Note"), true));
|
||||
if (labelColumn.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.MY))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("ColumnMY_Note"), true));
|
||||
if (labelColumn.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.MZ))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("ColumnMZ_Note"), true));
|
||||
}
|
||||
|
||||
body.Elements.Add(DocumentElement.GetDocumentElement("CreepCoefficient", labelColumn, this, document));
|
||||
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("Buckling"), 4));
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("BucklingDirectionY"), 5));
|
||||
if (labelColumn.BucklingDirectionY)
|
||||
{
|
||||
body.Elements.Add(DocumentElement.GetDocumentElement("LengthCoefficientY", labelColumn, this, document));
|
||||
body.Elements.Add(DocumentElement.GetDocumentElement("ColumnStructureTypeY", labelColumn, this, document));
|
||||
}
|
||||
else
|
||||
{
|
||||
body.Elements.Add(new DocumentText(Resources.ResourceManager.GetString("NotTakenIntoConsideration"), true));
|
||||
}
|
||||
|
||||
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("BucklingDirectionZ"), 5));
|
||||
if (labelColumn.BucklingDirectionZ)
|
||||
{
|
||||
body.Elements.Add(DocumentElement.GetDocumentElement("LengthCoefficientZ", labelColumn, this, document));
|
||||
body.Elements.Add(DocumentElement.GetDocumentElement("ColumnStructureTypeZ", labelColumn, this, document));
|
||||
}
|
||||
else
|
||||
{
|
||||
body.Elements.Add(new DocumentText(Resources.ResourceManager.GetString("NotTakenIntoConsideration"), true));
|
||||
}
|
||||
|
||||
|
||||
// longitudinal
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("LongitudinalReinforcement"), 4));
|
||||
if (labelColumn.LongitudinalReinforcement.Material != null)
|
||||
{
|
||||
StructuralAsset assL = Autodesk.Revit.DB.CodeChecking.Engineering.Concrete.RebarUtility.GetMaterialStructuralAsset(labelColumn.LongitudinalReinforcement.Material);
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), assL.Name));
|
||||
}
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("MinimumYieldStress"), labelColumn.LongitudinalReinforcement.MinimumYieldStress, UnitsConverter.GetInternalUnit(UnitType.UT_Stress), UnitType.UT_Stress, document.GetUnits()));
|
||||
|
||||
if (labelColumn.LongitudinalReinforcement.RebarBarType != null)
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), labelColumn.LongitudinalReinforcement.RebarBarType.Name));
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("DeformationType"), labelColumn.LongitudinalReinforcement.DeformationType.ToString()));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("BarDiameter"), labelColumn.LongitudinalReinforcement.BarDiameter, UnitsConverter.GetInternalUnit(UnitType.UT_Bar_Diameter), UnitType.UT_Bar_Diameter, document.GetUnits()));
|
||||
|
||||
// transverse
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("TransversalReinforcement"), 4));
|
||||
if (labelColumn.TransversalReinforcement.Material != null)
|
||||
{
|
||||
StructuralAsset assL = Autodesk.Revit.DB.CodeChecking.Engineering.Concrete.RebarUtility.GetMaterialStructuralAsset(labelColumn.TransversalReinforcement.Material);
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), assL.Name));
|
||||
}
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("MinimumYieldStress"), labelColumn.TransversalReinforcement.MinimumYieldStress, UnitsConverter.GetInternalUnit(UnitType.UT_Stress), UnitType.UT_Stress, document.GetUnits()));
|
||||
|
||||
if (labelColumn.TransversalReinforcement.RebarBarType != null)
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), labelColumn.TransversalReinforcement.RebarBarType.Name));
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("DeformationType"), labelColumn.TransversalReinforcement.DeformationType.ToString()));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("BarDiameter"), labelColumn.TransversalReinforcement.BarDiameter, UnitsConverter.GetInternalUnit(UnitType.UT_Bar_Diameter), UnitType.UT_Bar_Diameter, document.GetUnits()));
|
||||
|
||||
|
||||
return body;
|
||||
}
|
||||
case "LabelBeam":
|
||||
{
|
||||
DocumentBody body = new DocumentBody();
|
||||
LabelBeam labelBeam = new LabelBeam();
|
||||
labelBeam.SetProperties(label, document);
|
||||
|
||||
|
||||
body.Elements.Add(new DocumentLineBreak(1));
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("CalculationOptions"), 4));
|
||||
|
||||
if (labelBeam.EnabledInternalForces.Count > 0)
|
||||
{
|
||||
body.Elements.Add(new DocumentText(Resources.ResourceManager.GetString("EnabledInternalForces") + ":", true));
|
||||
if (labelBeam.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.FX))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("BeamFX_Note"), true));
|
||||
if (labelBeam.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.FY))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("BeamFY_Note"), true));
|
||||
if (labelBeam.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.FZ))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("BeamFZ_Note"), true));
|
||||
if (labelBeam.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.MX))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("BeamMX_Note"), true));
|
||||
if (labelBeam.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.MY))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("BeamMY_Note"), true));
|
||||
if (labelBeam.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.MZ))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("BeamMZ_Note"), true));
|
||||
}
|
||||
|
||||
body.Elements.Add(DocumentElement.GetDocumentElement("CreepCoefficient", labelBeam, this, document));
|
||||
|
||||
string interaction = Resources.ResourceManager.GetString("No");
|
||||
if (labelBeam.SlabBeamInteraction == ConcreteTypes.BeamSectionType.WithSlabBeamInteraction)
|
||||
{
|
||||
interaction = Resources.ResourceManager.GetString("Yes");
|
||||
}
|
||||
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("SlabBeamInteraction"), interaction));
|
||||
|
||||
// longitudinal
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("LongitudinalReinforcement"), 4));
|
||||
if (labelBeam.LongitudinalReinforcement.Material != null)
|
||||
{
|
||||
StructuralAsset assL = Autodesk.Revit.DB.CodeChecking.Engineering.Concrete.RebarUtility.GetMaterialStructuralAsset(labelBeam.LongitudinalReinforcement.Material);
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), assL.Name));
|
||||
}
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("MinimumYieldStress"), labelBeam.LongitudinalReinforcement.MinimumYieldStress, UnitsConverter.GetInternalUnit(UnitType.UT_Stress), UnitType.UT_Stress, document.GetUnits()));
|
||||
|
||||
if (labelBeam.LongitudinalReinforcement.RebarBarType != null)
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), labelBeam.LongitudinalReinforcement.RebarBarType.Name));
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("DeformationType"), labelBeam.LongitudinalReinforcement.DeformationType.ToString()));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("BarDiameter"), labelBeam.LongitudinalReinforcement.BarDiameter, UnitsConverter.GetInternalUnit(UnitType.UT_Bar_Diameter), UnitType.UT_Bar_Diameter, document.GetUnits()));
|
||||
|
||||
// transverse
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("TransversalReinforcement"), 4));
|
||||
if (labelBeam.TransversalReinforcement.Material != null)
|
||||
{
|
||||
StructuralAsset assL = Autodesk.Revit.DB.CodeChecking.Engineering.Concrete.RebarUtility.GetMaterialStructuralAsset(labelBeam.TransversalReinforcement.Material);
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), assL.Name));
|
||||
}
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("MinimumYieldStress"), labelBeam.TransversalReinforcement.MinimumYieldStress, UnitsConverter.GetInternalUnit(UnitType.UT_Stress), UnitType.UT_Stress, document.GetUnits()));
|
||||
|
||||
if (labelBeam.TransversalReinforcement.RebarBarType != null)
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), labelBeam.TransversalReinforcement.RebarBarType.Name));
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("DeformationType"), labelBeam.TransversalReinforcement.DeformationType.ToString()));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("BarDiameter"), labelBeam.TransversalReinforcement.BarDiameter, UnitsConverter.GetInternalUnit(UnitType.UT_Bar_Diameter), UnitType.UT_Bar_Diameter, document.GetUnits()));
|
||||
|
||||
return body;
|
||||
}
|
||||
/// <structural_toolkit_2015>
|
||||
case "LabelFloor":
|
||||
{
|
||||
DocumentBody body = new DocumentBody();
|
||||
LabelFloor LabelFloor = new LabelFloor();
|
||||
LabelFloor.SetProperties(label, document);
|
||||
|
||||
|
||||
body.Elements.Add(new DocumentLineBreak(1));
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("CalculationOptions"), 4));
|
||||
|
||||
if (LabelFloor.EnabledInternalForces.Count > 0)
|
||||
{
|
||||
body.Elements.Add(new DocumentText(Resources.ResourceManager.GetString("EnabledInternalForces") + ":", true));
|
||||
if (LabelFloor.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.FX))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("FloorF_Note"), true));
|
||||
if (LabelFloor.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.FZ))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("FloorQ_Note"), true));
|
||||
if (LabelFloor.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.MY))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("FloorM_Note"), true));
|
||||
}
|
||||
|
||||
body.Elements.Add(DocumentElement.GetDocumentElement("CreepCoefficient", LabelFloor, this, document));
|
||||
// Primary
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("PrimaryReinforcement"), 4));
|
||||
if (LabelFloor.PrimaryReinforcement.Material != null)
|
||||
{
|
||||
StructuralAsset assL = Autodesk.Revit.DB.CodeChecking.Engineering.Concrete.RebarUtility.GetMaterialStructuralAsset(LabelFloor.PrimaryReinforcement.Material);
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), assL.Name));
|
||||
}
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("MinimumYieldStress"), LabelFloor.PrimaryReinforcement.MinimumYieldStress, UnitsConverter.GetInternalUnit(UnitType.UT_Stress), UnitType.UT_Stress, document.GetUnits()));
|
||||
|
||||
if (LabelFloor.PrimaryReinforcement.RebarBarType != null)
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), LabelFloor.PrimaryReinforcement.RebarBarType.Name));
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("DeformationType"), LabelFloor.PrimaryReinforcement.DeformationType.ToString()));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("BarDiameter"), LabelFloor.PrimaryReinforcement.BarDiameter, UnitsConverter.GetInternalUnit(UnitType.UT_Bar_Diameter), UnitType.UT_Bar_Diameter, document.GetUnits()));
|
||||
|
||||
// Secondary
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("SecondaryReinforcement"), 4));
|
||||
if (LabelFloor.SecondaryReinforcement.Material != null)
|
||||
{
|
||||
StructuralAsset assL = Autodesk.Revit.DB.CodeChecking.Engineering.Concrete.RebarUtility.GetMaterialStructuralAsset(LabelFloor.SecondaryReinforcement.Material);
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), assL.Name));
|
||||
}
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("MinimumYieldStress"), LabelFloor.SecondaryReinforcement.MinimumYieldStress, UnitsConverter.GetInternalUnit(UnitType.UT_Stress), UnitType.UT_Stress, document.GetUnits()));
|
||||
|
||||
if (LabelFloor.SecondaryReinforcement.RebarBarType != null)
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), LabelFloor.SecondaryReinforcement.RebarBarType.Name));
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("DeformationType"), LabelFloor.SecondaryReinforcement.DeformationType.ToString()));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("BarDiameter"), LabelFloor.SecondaryReinforcement.BarDiameter, UnitsConverter.GetInternalUnit(UnitType.UT_Bar_Diameter), UnitType.UT_Bar_Diameter, document.GetUnits()));
|
||||
|
||||
return body;
|
||||
}
|
||||
case "LabelWall":
|
||||
{
|
||||
DocumentBody body = new DocumentBody();
|
||||
LabelWall LabelWall = new LabelWall();
|
||||
LabelWall.SetProperties(label, document);
|
||||
|
||||
|
||||
body.Elements.Add(new DocumentLineBreak(1));
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("CalculationOptions"), 4));
|
||||
|
||||
if (LabelWall.EnabledInternalForces.Count > 0)
|
||||
{
|
||||
body.Elements.Add(new DocumentText(Resources.ResourceManager.GetString("EnabledInternalForces") + ":", true));
|
||||
if (LabelWall.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.FX))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("WallF_Note"), true));
|
||||
if (LabelWall.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.FZ))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("WallQ_Note"), true));
|
||||
if (LabelWall.EnabledInternalForces.Contains(ConcreteTypes.EnabledInternalForces.MX))
|
||||
body.Elements.Add(new DocumentText("- " + Resources.ResourceManager.GetString("WallM_Note"), true));
|
||||
}
|
||||
|
||||
body.Elements.Add(DocumentElement.GetDocumentElement("CreepCoefficient", LabelWall, this, document));
|
||||
// Vertical
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("VerticalReinforcement"), 4));
|
||||
if (LabelWall.VerticalReinforcement.Material != null)
|
||||
{
|
||||
StructuralAsset assL = Autodesk.Revit.DB.CodeChecking.Engineering.Concrete.RebarUtility.GetMaterialStructuralAsset(LabelWall.VerticalReinforcement.Material);
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), assL.Name));
|
||||
}
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("MinimumYieldStress"), LabelWall.VerticalReinforcement.MinimumYieldStress, UnitsConverter.GetInternalUnit(UnitType.UT_Stress), UnitType.UT_Stress, document.GetUnits()));
|
||||
|
||||
if (LabelWall.VerticalReinforcement.RebarBarType != null)
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), LabelWall.VerticalReinforcement.RebarBarType.Name));
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("DeformationType"), LabelWall.VerticalReinforcement.DeformationType.ToString()));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("BarDiameter"), LabelWall.VerticalReinforcement.BarDiameter, UnitsConverter.GetInternalUnit(UnitType.UT_Bar_Diameter), UnitType.UT_Bar_Diameter, document.GetUnits()));
|
||||
|
||||
// Horizontal
|
||||
body.Elements.Add(new DocumentTitle(Resources.ResourceManager.GetString("HorizontalReinforcement"), 4));
|
||||
if (LabelWall.HorizontalReinforcement.Material != null)
|
||||
{
|
||||
StructuralAsset assL = Autodesk.Revit.DB.CodeChecking.Engineering.Concrete.RebarUtility.GetMaterialStructuralAsset(LabelWall.HorizontalReinforcement.Material);
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), assL.Name));
|
||||
}
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("Material"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("MinimumYieldStress"), LabelWall.HorizontalReinforcement.MinimumYieldStress, UnitsConverter.GetInternalUnit(UnitType.UT_Stress), UnitType.UT_Stress, document.GetUnits()));
|
||||
|
||||
if (LabelWall.HorizontalReinforcement.RebarBarType != null)
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), LabelWall.HorizontalReinforcement.RebarBarType.Name));
|
||||
else
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("RebarBarType"), ""));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("DeformationType"), LabelWall.HorizontalReinforcement.DeformationType.ToString()));
|
||||
body.Elements.Add(new DocumentValueWithName(Resources.ResourceManager.GetString("BarDiameter"), LabelWall.HorizontalReinforcement.BarDiameter, UnitsConverter.GetInternalUnit(UnitType.UT_Bar_Diameter), UnitType.UT_Bar_Diameter, document.GetUnits()));
|
||||
|
||||
return body;
|
||||
}
|
||||
/// </structural_toolkit_2015>
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the document body for calculation parameters.
|
||||
/// </summary>
|
||||
/// <param name="calcParams">Calculation parameters</param>
|
||||
/// <param name="document">document</param>
|
||||
/// <returns>Body of the document</returns>
|
||||
public override DocumentBody BuildCalculationParamDocumentBody(Entity calcParams, Autodesk.Revit.DB.Document document)
|
||||
{
|
||||
DocumentBody body = new DocumentBody();
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
#region IExternalServer Members
|
||||
|
||||
public override string GetDescription()
|
||||
{
|
||||
return "Code Checking Concrete Example for Revit API";
|
||||
}
|
||||
|
||||
public override string GetName()
|
||||
{
|
||||
return "CodeCheckingConcreteExample";
|
||||
}
|
||||
|
||||
public override Guid GetServerId()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
|
||||
public override string GetVendorId()
|
||||
{
|
||||
return "ADSK";
|
||||
}
|
||||
|
||||
public override void Verify(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);
|
||||
|
||||
|
||||
Main.Calculation.EngineData enginData = new Main.Calculation.EngineData();
|
||||
Engine.Engine engine = new Engine.Engine(enginData);
|
||||
|
||||
engine.Calculate(this, data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the output package result types. This information is needed to create proper ResultsBuilder Package.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Autodesk.Revit.DB.ResultsBuilder.ResultsPackageTypes GetOutputPackageResultTypes()
|
||||
{
|
||||
return Autodesk.Revit.DB.ResultsBuilder.ResultsPackageTypes.RequiredReinforcement | Autodesk.Revit.DB.ResultsBuilder.ResultsPackageTypes.SteelRatio;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the output package unit system. This information is needed to create proper ResultsBuilder Package.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Autodesk.Revit.DB.ResultsBuilder.UnitsSystem GetOutputPackageUnitSystem()
|
||||
{
|
||||
return UnitSystem;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICodeCheckingServerDocumentation Members
|
||||
|
||||
public override string GetResource(string key, string context)
|
||||
{
|
||||
string txt = Resources.ResourceManager.GetString(key);
|
||||
|
||||
if (!string.IsNullOrEmpty(txt))
|
||||
return txt;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+437
@@ -0,0 +1,437 @@
|
||||
//
|
||||
// (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
|
||||
{
|
||||
/// Moved from Server.cs
|
||||
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="linearElementResult">Calculation results schema class</param>
|
||||
/// <param name="document">Active Revit document</param>
|
||||
/// <param name="elementType">Structural element type</param>
|
||||
private void WriteResultsToNoteForLinearElements(DocumentBody body, ResultLinearElement linearElementResult, Autodesk.Revit.DB.Document document, ElementType elementType)
|
||||
{
|
||||
/////////////////////////// Prepare data
|
||||
// Get revit units
|
||||
Units units = document.GetUnits();
|
||||
|
||||
// Get raw calculation results as a collection of ResultInPointLinear objects for all element sections ( one ResultInPointLinear per section)
|
||||
List<ResultInPointLinear> resultsInPoints = linearElementResult.GetResultsInPointsCollection();
|
||||
|
||||
if (resultsInPoints.Count == 0)
|
||||
return;
|
||||
|
||||
/////////////////////////// Add a general reinforcement review to the body( mean and extreme values of reinfocement )
|
||||
|
||||
// Create document section
|
||||
DocumentSection resultSummary = new DocumentSection(Resources.ResourceManager.GetString("Summary"), 5);
|
||||
// Calculate mean and extreme values
|
||||
IEnumerable<ResultTypeLinear> longRnf = new List<ResultTypeLinear> { ResultTypeLinear.Atop, ResultTypeLinear.Abottom, ResultTypeLinear.Aleft, ResultTypeLinear.Aright };
|
||||
double maxLongitudinal = resultsInPoints.Max(s => (longRnf.Sum(q => s[q]))),
|
||||
minLongitudinal = resultsInPoints.Min(s => (longRnf.Sum(q => s[q]))),
|
||||
maxSpacing = resultsInPoints.Max(s => s[ResultTypeLinear.StirrupsSpacing]),
|
||||
minSpacing = resultsInPoints.Min(s => s[ResultTypeLinear.StirrupsSpacing]),
|
||||
maxX = resultsInPoints.Max(s => s[ResultTypeLinear.X]),
|
||||
minX = resultsInPoints.Min(s => s[ResultTypeLinear.X]),
|
||||
meanLongitudinal = resultsInPoints.Average(s => (longRnf.Sum(q => s[q]))),
|
||||
meanTransversal = resultsInPoints.Average(s => s[ResultTypeLinear.TransversalReinforcemenDensity]);
|
||||
|
||||
// Add them to the section
|
||||
resultSummary.Body.Elements.Add((new DocumentValueWithName(Resources.ResourceManager.GetString("MeanReinforcemenDensityLongitudinal"), meanLongitudinal, UnitsConverter.GetInternalUnit(UnitType.UT_Reinforcement_Area), UnitType.UT_Reinforcement_Area, document.GetUnits())));
|
||||
resultSummary.Body.Elements.Add((new DocumentValueWithName(Resources.ResourceManager.GetString("MeanTransversalReinforcemenDensity"), meanTransversal, UnitsConverter.GetInternalUnit(UnitType.UT_Reinforcement_Area_per_Unit_Length), UnitType.UT_Reinforcement_Area_per_Unit_Length, document.GetUnits())));
|
||||
resultSummary.Body.Elements.Add((new DocumentValueWithName(Resources.ResourceManager.GetString("MaximumLongitudinalReinforcement"), maxLongitudinal, UnitsConverter.GetInternalUnit(UnitType.UT_Reinforcement_Area), UnitType.UT_Reinforcement_Area, document.GetUnits())));
|
||||
resultSummary.Body.Elements.Add((new DocumentValueWithName(Resources.ResourceManager.GetString("MinimumLongitudinalReinforcement"), minLongitudinal, UnitsConverter.GetInternalUnit(UnitType.UT_Reinforcement_Area), UnitType.UT_Reinforcement_Area, document.GetUnits())));
|
||||
resultSummary.Body.Elements.Add((new DocumentValueWithName(Resources.ResourceManager.GetString("MaximumStirrupsSpacing"), maxSpacing, UnitsConverter.GetInternalUnit(UnitType.UT_Section_Dimension), UnitType.UT_Section_Dimension, document.GetUnits())));
|
||||
resultSummary.Body.Elements.Add((new DocumentValueWithName(Resources.ResourceManager.GetString("MinimumStirrupsSpacing"), minSpacing, UnitsConverter.GetInternalUnit(UnitType.UT_Section_Dimension), UnitType.UT_Section_Dimension, document.GetUnits())));
|
||||
resultSummary.Level = DetailLevel.General;
|
||||
// Add section to the document body
|
||||
body.Elements.Add(resultSummary);
|
||||
|
||||
|
||||
|
||||
/////////////////////////// Create result tables for deflection, internal forces and reinforcement
|
||||
|
||||
// Create reinforcement table
|
||||
List<ResultTypeLinear> nonZeroReinforcement = ResultTypeLinearHelper.ReinforcementResults.Where(s => resultsInPoints.Any(r => Math.Abs(r[s]) > Double.Epsilon)).ToList();
|
||||
if (nonZeroReinforcement.Count() > 0)
|
||||
{
|
||||
DocumentSection section = CreateSectionTableAndDiagramForLinearElements(resultsInPoints, nonZeroReinforcement, document, elementType, true, false, false, Resources.ResourceManager.GetString("Reinforcement"));
|
||||
if (section != null)
|
||||
body.Elements.Add(section);
|
||||
string diagramTitle = "";
|
||||
bool reversedAxis = false;
|
||||
|
||||
foreach (ResultTypeLinear resultType in nonZeroReinforcement)
|
||||
{
|
||||
switch (resultType)
|
||||
{
|
||||
case ResultTypeLinear.Abottom:
|
||||
diagramTitle = Resources.ResourceManager.GetString("LongReinforcementBottom");
|
||||
break;
|
||||
case ResultTypeLinear.Atop:
|
||||
diagramTitle = Resources.ResourceManager.GetString("LongReinforcementTop");
|
||||
break;
|
||||
case ResultTypeLinear.Aleft:
|
||||
diagramTitle = Resources.ResourceManager.GetString("LongReinforcementLeft");
|
||||
break;
|
||||
case ResultTypeLinear.Aright:
|
||||
diagramTitle = Resources.ResourceManager.GetString("LongReinforcementRight");
|
||||
break;
|
||||
case ResultTypeLinear.TransversalReinforcemenDensity:
|
||||
diagramTitle = Resources.ResourceManager.GetString("TransversalReinforcement");
|
||||
break;
|
||||
case ResultTypeLinear.StirrupsSpacing:
|
||||
diagramTitle = Resources.ResourceManager.GetString("StirrupsSpacing");
|
||||
break;
|
||||
}
|
||||
List<ResultTypeLinear> oneNonZeroReinforcement = new List<ResultTypeLinear>(1);
|
||||
oneNonZeroReinforcement.Add(resultType);
|
||||
section = CreateSectionTableAndDiagramForLinearElements(resultsInPoints, oneNonZeroReinforcement, document, elementType, false, true, reversedAxis, "", "", diagramTitle);
|
||||
if (section != null)
|
||||
body.Elements.Add(section);
|
||||
}
|
||||
}
|
||||
// Create internal forces tables and graph
|
||||
List<ResultTypeLinear> nonZeroInternalForces = ResultTypeLinearHelper.InternalForcesResults.Where(s => resultsInPoints.Any(r => Math.Abs(r[s]) > Double.Epsilon)).ToList();
|
||||
if (nonZeroInternalForces.Count() > 0)
|
||||
{
|
||||
DocumentSection section = CreateSectionTableAndDiagramForLinearElements(resultsInPoints, nonZeroInternalForces, document, elementType, true, true, false, Resources.ResourceManager.GetString("InternalForces"), "", Resources.ResourceManager.GetString("Internal_Forces"));
|
||||
if (section != null)
|
||||
body.Elements.Add(section);
|
||||
}
|
||||
List<ResultTypeLinear> nonZeroInternalMoments = ResultTypeLinearHelper.InternalMomentsResults.Where(s => resultsInPoints.Any(r => Math.Abs(r[s]) > Double.Epsilon)).ToList();
|
||||
if (nonZeroInternalMoments.Count() > 0)
|
||||
{
|
||||
DocumentSection section = null;
|
||||
if (nonZeroInternalForces.Count() != 0)
|
||||
section = CreateSectionTableAndDiagramForLinearElements(resultsInPoints, nonZeroInternalMoments, document, elementType, true, true, true, "", "", Resources.ResourceManager.GetString("Internal_Moments"));
|
||||
else
|
||||
section = CreateSectionTableAndDiagramForLinearElements(resultsInPoints, nonZeroInternalMoments, document, elementType, true, true, true, Resources.ResourceManager.GetString("InternalForces"), "", Resources.ResourceManager.GetString("Internal_Moments"));
|
||||
if (section != null)
|
||||
body.Elements.Add(section);
|
||||
}
|
||||
|
||||
// Create deflection table and graph
|
||||
List<ResultTypeLinear> nonZeroDeflection = ResultTypeLinearHelper.RealDeflectionResults.Where(s => resultsInPoints.Any(r => Math.Abs(r[s]) > Double.Epsilon)).ToList();
|
||||
if (nonZeroDeflection.Count() > 0)
|
||||
{
|
||||
List<ResultTypeLinear> displacement = new List<ResultTypeLinear>(nonZeroDeflection.Count());
|
||||
List<ResultTypeLinear> displacementAndDeflection = new List<ResultTypeLinear>(nonZeroDeflection.Count() * 2);
|
||||
displacementAndDeflection.AddRange(nonZeroDeflection);
|
||||
foreach (ResultTypeLinear resultType in nonZeroDeflection)
|
||||
{
|
||||
switch (resultType)
|
||||
{
|
||||
case ResultTypeLinear.UxRealMax:
|
||||
displacement.Add(ResultTypeLinear.UxMax);
|
||||
break;
|
||||
case ResultTypeLinear.UxRealMin:
|
||||
displacement.Add(ResultTypeLinear.UxMin);
|
||||
break;
|
||||
case ResultTypeLinear.UyRealMax:
|
||||
displacement.Add(ResultTypeLinear.UyMax);
|
||||
break;
|
||||
case ResultTypeLinear.UyRealMin:
|
||||
displacement.Add(ResultTypeLinear.UyMin);
|
||||
break;
|
||||
case ResultTypeLinear.UzRealMax:
|
||||
displacement.Add(ResultTypeLinear.UzMax);
|
||||
break;
|
||||
case ResultTypeLinear.UzRealMin:
|
||||
displacement.Add(ResultTypeLinear.UzMin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
displacementAndDeflection.AddRange(displacement);
|
||||
DocumentSection section = CreateSectionTableAndDiagramForLinearElements(resultsInPoints, displacementAndDeflection, document, elementType, true, false, false, Resources.ResourceManager.GetString("Deflection"), "", Resources.ResourceManager.GetString("DeflectionEnvelope"));
|
||||
if (section != null)
|
||||
{
|
||||
body.Elements.Add(section);
|
||||
section = CreateSectionTableAndDiagramForLinearElements(resultsInPoints, nonZeroDeflection, document, elementType, false, true, false, "", "", Resources.ResourceManager.GetString("DeflectionEnvelope"));
|
||||
if (section != null)
|
||||
{
|
||||
body.Elements.Add(section);
|
||||
section = CreateSectionTableAndDiagramForLinearElements(resultsInPoints, displacement, document, elementType, false, true, false, "", "", Resources.ResourceManager.GetString("DisplacementEnvelope"));
|
||||
if (section != null)
|
||||
body.Elements.Add(section);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static private Dictionary<ResultTypeLinear, Color> ResultTypeLinearToColorDictionary = new Dictionary<ResultTypeLinear, Color>()
|
||||
{
|
||||
{ResultTypeLinear.X, new Color (0, 255, 0 ) },
|
||||
{ResultTypeLinear.X_Rel, new Color (225, 0, 0 ) },
|
||||
|
||||
{ResultTypeLinear.MxMax, new Color (0, 0, 255 ) },
|
||||
{ResultTypeLinear.MxMin, new Color (255, 119, 28 ) },
|
||||
{ResultTypeLinear.MyMin, new Color (51, 177, 33 ) },
|
||||
{ResultTypeLinear.MyMax, new Color (163, 73, 180 ) },
|
||||
{ResultTypeLinear.MzMin, new Color (159, 99, 66 ) },
|
||||
{ResultTypeLinear.MzMax, new Color (0, 128, 128 ) },
|
||||
|
||||
{ResultTypeLinear.FxMax, new Color (0, 0, 255 ) },
|
||||
{ResultTypeLinear.FxMin, new Color (255, 119, 28 ) },
|
||||
{ResultTypeLinear.FyMin, new Color (51, 177, 33 ) },
|
||||
{ResultTypeLinear.FyMax, new Color (163, 73, 180 ) },
|
||||
{ResultTypeLinear.FzMin, new Color (159, 99, 66 ) },
|
||||
{ResultTypeLinear.FzMax, new Color (0, 128, 128 ) },
|
||||
|
||||
{ResultTypeLinear.Abottom, new Color (0, 0, 255 ) },
|
||||
{ResultTypeLinear.Atop, new Color (255, 119, 28 ) },
|
||||
{ResultTypeLinear.Aleft, new Color (51, 177, 33 ) },
|
||||
{ResultTypeLinear.Aright, new Color (163, 73, 180 ) },
|
||||
{ResultTypeLinear.StirrupsSpacing, new Color (159, 99, 66 ) },
|
||||
{ResultTypeLinear.TransversalReinforcemenDensity, new Color (0, 128, 128 ) },
|
||||
|
||||
{ResultTypeLinear.UxMax, new Color (0, 0, 255 ) },
|
||||
{ResultTypeLinear.UxMin, new Color (255, 119, 28 ) },
|
||||
{ResultTypeLinear.UyMax, new Color (51, 177, 33 ) },
|
||||
{ResultTypeLinear.UyMin, new Color (163, 73, 180 ) },
|
||||
{ResultTypeLinear.UzMax, new Color (159, 99, 66 ) },
|
||||
{ResultTypeLinear.UzMin, new Color (0, 128, 128 ) },
|
||||
|
||||
{ResultTypeLinear.UxRealMax, new Color (0, 0, 255 ) },
|
||||
{ResultTypeLinear.UxRealMin, new Color (255, 119, 28 ) },
|
||||
{ResultTypeLinear.UyRealMax, new Color (51, 177, 33 ) },
|
||||
{ResultTypeLinear.UyRealMin, new Color (163, 73, 180 ) },
|
||||
{ResultTypeLinear.UzRealMax, new Color (159, 99, 66 ) },
|
||||
{ResultTypeLinear.UzRealMin, new Color (0, 128, 128 ) },
|
||||
|
||||
};
|
||||
/// <summary>
|
||||
/// Creats the section of document with table
|
||||
/// </summary>
|
||||
/// <param name="resultsInPoints"> Result in point collection</param>
|
||||
/// <param name="resultTypes">The type of results that will be displayed in the table.</param>
|
||||
/// <param name="document">Active Revit document</param>
|
||||
/// <returns>Returns section of document with table</returns>
|
||||
private DocumentTable CreateResultTableForLinearElements(ICollection<ResultInPointLinear> resultsInPoints, List<ResultTypeLinear> resultTypes, Autodesk.Revit.DB.Document document)
|
||||
{
|
||||
Units units = document.GetUnits();
|
||||
resultTypes.Insert(0, ResultTypeLinear.X);
|
||||
DocumentTable resultTable = new DocumentTable(resultsInPoints.Count + 1, resultTypes.Count());
|
||||
int colId = 0;
|
||||
resultTable.HeaderColumnsCount = 1;
|
||||
resultTable.HeaderRowsCount = 1;
|
||||
foreach (ResultTypeLinear resultType in resultTypes)
|
||||
{
|
||||
string description = Resources.ResourceManager.GetString(resultType == ResultTypeLinear.X ? "X_" : resultType.ToString());
|
||||
resultTable[0, colId].Elements.Add(new DocumentText(description));
|
||||
int rowId = 1;
|
||||
UnitType unitType = resultType.GetUnitType();
|
||||
DisplayUnitType displayUnitType = Utility.UnitsConverter.GetInternalUnit(unitType);
|
||||
foreach (ResultInPointLinear resultInPoint in resultsInPoints)
|
||||
{
|
||||
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++;
|
||||
}
|
||||
resultTypes.Remove(ResultTypeLinear.X);
|
||||
return resultTable;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creats the section of document with diagram
|
||||
/// </summary>
|
||||
/// <param name="title">Title of the diagram</param>
|
||||
/// <param name="resultsInPoints"> Result in point collection</param>
|
||||
/// <param name="resultTypes">The type of results that will be displayed in the diagram.</param>
|
||||
/// <param name="document">Active Revit document</param>
|
||||
/// <param name="elementType">Structural element type</param>
|
||||
/// <param name="reversedAxis">Sets the direction of the Y axis on the graph</param>
|
||||
/// <returns>Returns section of document with diagram</returns>
|
||||
private DocumentDiagram CreateResultDiagramForLinearElements(String title, IEnumerable<ResultInPointLinear> resultsInPoints, List<ResultTypeLinear> resultTypes, Autodesk.Revit.DB.Document document, ElementType elementType, bool reversedAxis)
|
||||
{
|
||||
Units units = document.GetUnits();
|
||||
DocumentDiagram chart = new DocumentDiagram();
|
||||
if (resultTypes != null)
|
||||
{
|
||||
if (resultTypes.Count() > 0)
|
||||
{
|
||||
if (title.Length != 0)
|
||||
chart.Title = title;
|
||||
chart.Height = 200;
|
||||
chart.Width = 4 * chart.Height;
|
||||
|
||||
UnitType unitTypeX = ResultTypeLinear.X.GetUnitType();
|
||||
FormatOptions formatOptions = units.GetFormatOptions(unitTypeX);
|
||||
DisplayUnitType displayUnitTypeX = formatOptions.DisplayUnits;
|
||||
DisplayUnitType internalDisplayUnitTypeX = UnitsConverter.GetInternalUnit(unitTypeX);
|
||||
UnitSymbolType unitSymbolTypeX = formatOptions.UnitSymbol;
|
||||
String axisTitle = "";
|
||||
if (ElementType.Column == elementType)
|
||||
axisTitle = Resources.ResourceManager.GetString("AxisHeight");
|
||||
else
|
||||
axisTitle = Resources.ResourceManager.GetString("AxisLength");
|
||||
if (UnitSymbolType.UST_NONE != unitSymbolTypeX)
|
||||
{
|
||||
axisTitle += " " + LabelUtils.GetLabelFor(unitSymbolTypeX);
|
||||
}
|
||||
chart.AxisX.Title = axisTitle;
|
||||
chart.AxisY.Reversed = reversedAxis;
|
||||
UnitType unitTypeY = resultTypes.First().GetUnitType();
|
||||
formatOptions = units.GetFormatOptions(unitTypeY);
|
||||
DisplayUnitType displayUnitTypeY = formatOptions.DisplayUnits;
|
||||
DisplayUnitType internalDisplayUnitTypeY = UnitsConverter.GetInternalUnit(unitTypeY);
|
||||
UnitSymbolType unitSymbolTypeY = formatOptions.UnitSymbol;
|
||||
switch (unitTypeY)
|
||||
{
|
||||
case UnitType.UT_Reinforcement_Area:
|
||||
axisTitle = Resources.ResourceManager.GetString("AxisArea");
|
||||
break;
|
||||
case UnitType.UT_Force:
|
||||
axisTitle = Resources.ResourceManager.GetString("AxisForce");
|
||||
break;
|
||||
case UnitType.UT_Moment:
|
||||
axisTitle = Resources.ResourceManager.GetString("AxisMoment");
|
||||
break;
|
||||
case UnitType.UT_Displacement_Deflection:
|
||||
axisTitle = Resources.ResourceManager.GetString("AxisDisplacmentDeflection");
|
||||
break;
|
||||
case UnitType.UT_Section_Dimension:
|
||||
axisTitle = Resources.ResourceManager.GetString("AxisSpacing");
|
||||
break;
|
||||
case UnitType.UT_Reinforcement_Area_per_Unit_Length:
|
||||
axisTitle = Resources.ResourceManager.GetString("AxisDencity");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
axisTitle += " ";
|
||||
if (UnitSymbolType.UST_NONE == unitSymbolTypeY)
|
||||
{
|
||||
if(DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES == displayUnitTypeY)
|
||||
axisTitle += LabelUtils.GetLabelFor(UnitSymbolType.UST_FT);
|
||||
else if (DisplayUnitType.DUT_FRACTIONAL_INCHES == displayUnitTypeY)
|
||||
axisTitle += LabelUtils.GetLabelFor(UnitSymbolType.UST_IN);
|
||||
}
|
||||
else
|
||||
{
|
||||
axisTitle += LabelUtils.GetLabelFor(unitSymbolTypeY);
|
||||
}
|
||||
chart.AxisY.Title = axisTitle;
|
||||
double valX = 0;
|
||||
double valY = 0;
|
||||
foreach (ResultTypeLinear resultType in resultTypes)
|
||||
{
|
||||
DocumentDiagramSeries series = new DocumentDiagramSeries(resultType.ToString());
|
||||
chart.Legend = true;
|
||||
chart.Series.Add(series);
|
||||
series.Color = ResultTypeLinearToColorDictionary[resultType];
|
||||
series.Name = Resources.ResourceManager.GetString(resultType.ToString());
|
||||
int lblNbr = 5;
|
||||
int lblN = 0;
|
||||
int lblStep = resultsInPoints.Count<ResultInPointLinear>() / lblNbr;
|
||||
// Labels on the X axis will be formatted according to Revit preferences
|
||||
//formatOptions = units.GetFormatOptions(unitTypeX);
|
||||
//string accuracy = formatOptions.Accuracy.ToString();
|
||||
//accuracy = accuracy.Replace("1", "0");
|
||||
string valXAsString = "";
|
||||
foreach (ResultInPointLinear resultInPoint in resultsInPoints)
|
||||
{
|
||||
valX = Autodesk.Revit.DB.UnitUtils.Convert(resultInPoint[ResultTypeLinear.X], internalDisplayUnitTypeX, displayUnitTypeX);
|
||||
valY = Autodesk.Revit.DB.UnitUtils.Convert(resultInPoint[resultType], internalDisplayUnitTypeY, displayUnitTypeY);
|
||||
series.AddXY(valX, valY);
|
||||
if (lblStep == 0 || lblN % lblStep == 0)
|
||||
{
|
||||
//DocumentValue docVal = new DocumentValue(resultInPoint[ResultTypeLinear.X], displayUnitTypeX, unitTypeX, units);
|
||||
DocumentValue docVal = new DocumentValue(valX, displayUnitTypeX, unitTypeX, units);
|
||||
valXAsString = (string)docVal.Value;
|
||||
chart.AxisX.Labels.Add(new DocumentDiagramAxisLabel(valX, valXAsString));
|
||||
}
|
||||
lblN++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return chart;
|
||||
}
|
||||
/// <summary>
|
||||
/// Creats document section with table and graph
|
||||
/// </summary>
|
||||
/// <param name="sectionTitle">Title of the section</param>
|
||||
/// <param name="resultsInPoints"> Result in point collection</param>
|
||||
/// <param name="resultTypes">The type of results that will be displayed in the diagram and in the table.</param>
|
||||
/// <param name="document">Active Revit document</param>
|
||||
/// <param name="elementType">Structural element type</param>
|
||||
/// <param name="addTable">Enabling/disabling inserting a table</param>
|
||||
/// <param name="addDiagram">Enabling/disabling inserting a graph</param>
|
||||
/// <param name="tableTitle"> Title of the table</param>
|
||||
/// <param name="diagramTitle"> Title of the graph</param>
|
||||
/// <param name="reversedAxis">Sets the direction of the Y axis on the graph</param>
|
||||
/// <returns>Returns section of document with diagram and table</returns>
|
||||
private DocumentSection CreateSectionTableAndDiagramForLinearElements(ICollection<ResultInPointLinear> resultsInPoints, List<ResultTypeLinear> resultTypes, Autodesk.Revit.DB.Document document, ElementType elementType, bool addTable = true, bool addDiagram = true, bool reversedAxis = false, String sectionTitle = "", String tableTitle = "", String diagramTitle = "")
|
||||
{
|
||||
DocumentSection newDocumentSection = null;
|
||||
if (addTable || addDiagram)
|
||||
{
|
||||
newDocumentSection = new DocumentSection(sectionTitle, 5);
|
||||
newDocumentSection.Level = DetailLevel.Medium;
|
||||
if (addTable)
|
||||
{
|
||||
DocumentSection tableSection = new DocumentSection(tableTitle, 6);
|
||||
DocumentTable resultTable = CreateResultTableForLinearElements(resultsInPoints, resultTypes, document);
|
||||
resultTable.Level = DetailLevel.Medium;
|
||||
newDocumentSection.Body.Elements.Add(resultTable);
|
||||
}
|
||||
if (addDiagram)
|
||||
{
|
||||
DocumentSection diagramSection = new DocumentSection();
|
||||
DocumentDiagram resultDiagram = CreateResultDiagramForLinearElements(diagramTitle, resultsInPoints, resultTypes, document, elementType, reversedAxis);
|
||||
resultDiagram.Level = DetailLevel.Detail;
|
||||
newDocumentSection.Body.Elements.Add(new DocumentLineBreak(2));
|
||||
newDocumentSection.Body.Elements.Add(resultDiagram);
|
||||
}
|
||||
}
|
||||
return newDocumentSection;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// </structural_toolkit_2015>
|
||||
+404
@@ -0,0 +1,404 @@
|
||||
//
|
||||
// (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>
|
||||
}
|
||||
+326
@@ -0,0 +1,326 @@
|
||||
//
|
||||
// (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 Autodesk.Revit.UI.ExtensibleStorage.Framework.Attributes;
|
||||
using Autodesk.Revit.UI.ExtensibleStorage.Framework;
|
||||
using Autodesk.Revit.UI.ExtensibleStorage;
|
||||
using CodeCheckingConcreteExample.ConcreteTypes;
|
||||
using CodeCheckingConcreteExample.Properties;
|
||||
using CodeCheckingConcreteExample.Main;
|
||||
|
||||
#pragma warning disable 1591
|
||||
|
||||
namespace CodeCheckingConcreteExample.Server
|
||||
{
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.CalculationParamsStructure(typeof(CalculationParameter))]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.LabelStructure(typeof(LabelBeam), BuiltInCategory.OST_BeamAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.LabelStructure(typeof(LabelColumn), BuiltInCategory.OST_ColumnAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
/// <structural_toolkit_2015>
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.LabelStructure(typeof(LabelFloor), BuiltInCategory.OST_FloorAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.LabelStructure(typeof(LabelFloor), BuiltInCategory.OST_FoundationSlabAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
[Autodesk.Revit.DB.CodeChecking.Attributes.LabelStructure(typeof(LabelWall), BuiltInCategory.OST_WallAnalytical, Autodesk.Revit.DB.StructuralAssetClass.Concrete)]
|
||||
/// </structural_toolkit_2015>
|
||||
public class ServerUI : Autodesk.Revit.UI.CodeChecking.MultiStructureServer
|
||||
{
|
||||
#region ICodeCheckingServerUI Members
|
||||
public override string GetResource(string key, string context)
|
||||
{
|
||||
string txt = "";
|
||||
string resname = "";
|
||||
if (context != null)
|
||||
{
|
||||
switch (context)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case "ColumnLabel":
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "FX":
|
||||
case "FY":
|
||||
case "FZ":
|
||||
case "MX":
|
||||
case "MY":
|
||||
case "MZ":
|
||||
resname = "Column" + key;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "BeamLabel":
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "FX":
|
||||
case "FY":
|
||||
case "FZ":
|
||||
case "MX":
|
||||
case "MY":
|
||||
case "MZ":
|
||||
resname = "Beam" + key;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/// <structural_toolkit_2015>
|
||||
case "FloorLabel":
|
||||
switch (key)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case "FX":
|
||||
resname = "FloorF";
|
||||
break;
|
||||
case "MY":
|
||||
resname = "FloorM";
|
||||
break;
|
||||
case "FZ":
|
||||
resname = "FloorQ";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "WallLabel":
|
||||
switch (key)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case "FX":
|
||||
resname = "WallF";
|
||||
break;
|
||||
case "MY":
|
||||
resname = "WallM";
|
||||
break;
|
||||
case "FZ":
|
||||
resname = "WallQ";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
/// </structural_toolkit_2015>
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(resname))
|
||||
txt = Resources.ResourceManager.GetString(resname);
|
||||
|
||||
if (string.IsNullOrEmpty(txt))
|
||||
txt = Resources.ResourceManager.GetString(key);
|
||||
|
||||
if (!string.IsNullOrEmpty(txt))
|
||||
return txt;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
public override Uri GetResourceImage(string key, string context)
|
||||
{
|
||||
String contextKey = "";
|
||||
if (context != null)
|
||||
{
|
||||
switch (context)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case "ColumnLabel":
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "FX":
|
||||
contextKey = "CFX_32";
|
||||
break;
|
||||
case "FY":
|
||||
contextKey = "CFY_32";
|
||||
break;
|
||||
case "FZ":
|
||||
contextKey = "CFZ_32";
|
||||
break;
|
||||
case "MX":
|
||||
contextKey = "CMX_32";
|
||||
break;
|
||||
case "MY":
|
||||
contextKey = "CMY_32";
|
||||
break;
|
||||
case "MZ":
|
||||
contextKey = "CMZ_32";
|
||||
break;
|
||||
case "DirectionY":
|
||||
contextKey = "buckling_Y";
|
||||
break;
|
||||
case "DirectionZ":
|
||||
contextKey = "buckling_Z";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "BeamLabel":
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "FX":
|
||||
contextKey = "BFX_32";
|
||||
break;
|
||||
case "FY":
|
||||
contextKey = "BFY_32";
|
||||
break;
|
||||
case "FZ":
|
||||
contextKey = "BFZ_32";
|
||||
break;
|
||||
case "MX":
|
||||
contextKey = "BMX_32";
|
||||
break;
|
||||
case "MY":
|
||||
contextKey = "BMY_32";
|
||||
break;
|
||||
case "MZ":
|
||||
contextKey = "BMZ_32";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/// <structural_toolkit_2015>
|
||||
case "FloorLabel":
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "FX":
|
||||
case "MY":
|
||||
contextKey = "F" + key + "_32";
|
||||
break;
|
||||
default:
|
||||
contextKey = null;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "WallLabel":
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "FX":
|
||||
case "FY":
|
||||
case "MY":
|
||||
contextKey = "W" + key + "_32";
|
||||
break;
|
||||
default:
|
||||
contextKey = null;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (contextKey == "")
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "WithSlabBeamInteraction":
|
||||
contextKey = "BWithSlabBeamInteraction";
|
||||
break;
|
||||
case "WithoutSlabBeamInteraction":
|
||||
contextKey = "BWithoutSlabBeamInteraction";
|
||||
break;
|
||||
default:
|
||||
contextKey = context != null ? context + key : key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String currAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().ToString();
|
||||
return contextKey==null ? null : new Uri("pack://application:,,,/" + currAssemblyName + ";component/UIComponents/ICons/" + contextKey + ".png");
|
||||
}
|
||||
|
||||
public override void LayoutInitialized(object sender, Autodesk.Revit.UI.ExtensibleStorage.Framework.LayoutInitializedEventArgs e)
|
||||
{
|
||||
onChange(e);
|
||||
|
||||
base.LayoutInitialized(sender, e);
|
||||
}
|
||||
|
||||
public override void ValueChanged(object sender, Autodesk.Revit.UI.ExtensibleStorage.Framework.ValueChangedEventArgs e)
|
||||
{
|
||||
onChange(e);
|
||||
}
|
||||
|
||||
private void onChange(Autodesk.Revit.UI.ExtensibleStorage.Framework.SchemaEditorEventArgs e)
|
||||
{
|
||||
String elementTypeName = e.Editor.GetEntity().Schema.SchemaName;
|
||||
if (elementTypeName == "LabelColumn")
|
||||
{
|
||||
LabelColumn obj = new LabelColumn();
|
||||
obj.SetProperties(e.Entity as Autodesk.Revit.DB.ExtensibleStorage.Entity, e.Document);
|
||||
|
||||
e.Editor.SetAttribute("LengthCoefficientY", FieldUIAttribute.PropertyIsEnabled, obj.BucklingDirectionY, DisplayUnitType.DUT_UNDEFINED);
|
||||
e.Editor.SetAttribute("ColumnStructureTypeY", FieldUIAttribute.PropertyIsEnabled, obj.BucklingDirectionY, DisplayUnitType.DUT_UNDEFINED);
|
||||
e.Editor.SetAttribute("LengthCoefficientZ", FieldUIAttribute.PropertyIsEnabled, obj.BucklingDirectionZ, DisplayUnitType.DUT_UNDEFINED);
|
||||
e.Editor.SetAttribute("ColumnStructureTypeZ", FieldUIAttribute.PropertyIsEnabled, obj.BucklingDirectionZ, DisplayUnitType.DUT_UNDEFINED);
|
||||
}
|
||||
}
|
||||
|
||||
public override Layout BuildLabelLayout(Schema schema, Document document)
|
||||
{
|
||||
Layout layout = null;
|
||||
|
||||
if (schema.SchemaName == "LabelBeam")
|
||||
{
|
||||
layout = Layout.Build(typeof(LabelBeam), this);
|
||||
}
|
||||
|
||||
if (schema.SchemaName == "LabelColumn")
|
||||
{
|
||||
layout = Layout.Build(typeof(LabelColumn), this);
|
||||
if (layout != null)
|
||||
{
|
||||
Autodesk.Revit.UI.ExtensibleStorage.Framework.Category category = layout.GetCategory("Buckling");
|
||||
String currAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().ToString();
|
||||
Image image = new Image() { Source = new Uri("pack://application:,,,/" + currAssemblyName + ";component/UIComponents/ICons/" + "buckling.png"), Index = 1 };
|
||||
category.Controls.Add(image);
|
||||
layout.SortIndexBased();
|
||||
}
|
||||
}
|
||||
/// <structural_toolkit_2015>
|
||||
if (schema.SchemaName == "LabelWall")
|
||||
{
|
||||
layout = Layout.Build(typeof(LabelWall), this);
|
||||
}
|
||||
if (schema.SchemaName == "LabelFloor")
|
||||
{
|
||||
layout = Layout.Build(typeof(LabelFloor), this);
|
||||
}
|
||||
/// </structural_toolkit_2015>
|
||||
return layout;
|
||||
}
|
||||
|
||||
public override System.Collections.IList GetDataSource(string key, Autodesk.Revit.DB.Document document, Autodesk.Revit.DB.DisplayUnitType unitType)
|
||||
{
|
||||
return base.GetDataSource(key, document, unitType);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user