// // (C) Copyright 2003-2013 by Autodesk, Inc. // // Permission to use, copy, modify, and distribute this software in // object code form for any purpose and without fee is hereby granted, // provided that the above copyright notice appears in all copies and // that both that copyright notice and the limited warranty and // restricted rights notice below appear in all supporting // documentation. // // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) // (Rights in Technical Data and Computer Software), as applicable. // using System; using System.Collections.Generic; using System.Linq; using System.Text; using Autodesk.Revit.DB; using CodeCheckingConcreteExample.Engine; using Autodesk.Revit.DB.CodeChecking.Engineering; using Autodesk.Revit.DB.CodeChecking.Engineering.Tools; using CodeCheckingConcreteExample.Utility; using CodeCheckingConcreteExample.ConcreteTypes; using Autodesk.Revit.DB.CodeChecking.Storage; using CodeCheckingConcreteExample.Properties; using Autodesk.Revit.DB.CodeChecking; namespace CodeCheckingConcreteExample.Main.Calculation { /// /// Represents user's implementation of interface for the main loop class. Parameter of the default constructor of the cref="Engine" class. /// public class EngineData : IEngineData { #region IEngineData Members /// /// Gets the display unit which user want to use in the project. /// /// cref="DisplayUnit" public Autodesk.Revit.DB.DisplayUnit GetInputDataUnitSystem() { DisplayUnit displayUnit = DisplayUnit.IMPERIAL; if (Server.Server.UnitSystem == Autodesk.Revit.DB.ResultsBuilder.UnitsSystem.Metric) displayUnit = DisplayUnit.METRIC; return displayUnit; } /// /// Gets number of available threads or processors. user could switch off parallel calculation by returning value 1. /// /// Service data. /// Number of threads public int GetNumberOfThreads(Autodesk.Revit.DB.CodeChecking.ServiceData data) { /// if(Tools.IsJournalPlayback) return 1; else return Environment.ProcessorCount; /// } /// /// Gets ForceCalculationDataDescriptor object for the current structure /// /// Service Data /// List of selected combinations ids /// Id of Revit element /// Reference to ForceCalculationDataDescriptor protected ForceCalculationDataDescriptor GetForceCalculationDataDescriptor(Autodesk.Revit.DB.CodeChecking.ServiceData data, List combinations, ElementId elementId) { Tuple intData = GetElementInternalData(data, elementId); Label ccLabel = intData.Item1; CalculationParameter calculationParameters = intData.Item2; BuiltInCategory category = intData.Item3; Element element = intData.Item4; List forceTypes = new List();// { ForceType.Fx, ForceType.Fy, ForceType.Fz, ForceType.Mx, ForceType.My, ForceType.Mz }; forceTypes = GetForceTypes(data, new ElementId[] { elementId }); ForceCalculationDataDescriptor descriptor = null; /// switch (category) { case BuiltInCategory.OST_ColumnAnalytical: case BuiltInCategory.OST_BeamAnalytical: { double elementLength = (element as Autodesk.Revit.DB.Structure.AnalyticalModel).GetCurve().Length; elementLength = Autodesk.Revit.DB.UnitUtils.ConvertFromInternalUnits(elementLength, DisplayUnitType.DUT_METERS); descriptor = new ForceCalculationDataDescriptorLinear(elementId, 1.0, calculationParameters.CalculationPointsSelector.GetPointCoordinates(data.Document, true, elementLength, elementId, combinations, forceTypes), true, forceTypes); if (descriptor == null) { descriptor = new ForceCalculationDataDescriptorLinear(elementId); } } break; case BuiltInCategory.OST_FloorAnalytical: case BuiltInCategory.OST_FoundationSlabAnalytical: case BuiltInCategory.OST_WallAnalytical: { descriptor = new ForceCalculationDataDescriptor(elementId,forceTypes); } break; } if (descriptor == null) { descriptor = new ForceCalculationDataDescriptor(elementId,forceTypes); } /// return descriptor; } /// /// /// Creates user imlementation of cref="ICalculationScenario" which consists list of calculation objects cref="ICalculatinObject". /// /// User common parameters. /// The new instance of cref="ICalculationScenario" public ICalculationScenario CreateCalculationScenario(CommonParametersBase parameters) { return new CalculationScenario(); } /// /// /// Creates new instance of user class wich represents a section of a structure element. /// /// Instance of base class for the section. /// New instance of user implementation of section class derived from cref="SectionDataBase". public SectionDataBase CreateSectionData(SectionDataBase sectionDataBase) { switch (sectionDataBase.Material) { case StructuralAssetClass.Concrete: switch (sectionDataBase.Category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: return new ColumnSection(sectionDataBase); case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: return new BeamSection(sectionDataBase); /// case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical: return new FloorSection(sectionDataBase); case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical: return new FloorSection(sectionDataBase); case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical: return new WallSection(sectionDataBase); /// } break; case StructuralAssetClass.Metal: break; } return sectionDataBase; } /// /// Creates new instance of user class wich represents a structure element. /// /// Instance of base class for the element. /// New instance of user implementation of element class derived from cref="ElementDataBase". public ElementDataBase CreateElementData(ElementDataBase elementDataBase) { switch (elementDataBase.Material) { case StructuralAssetClass.Concrete: switch (elementDataBase.Category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: return new ColumnElement(elementDataBase); case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: return new BeamElement(elementDataBase); /// case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical: return new FloorElement(elementDataBase); case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical: return new FloorElement(elementDataBase); case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical: return new WallElement(elementDataBase); /// } break; case StructuralAssetClass.Metal: break; } return elementDataBase; } /// /// Creates new instance of class with results for the element. /// /// Category of the element. /// Material of the element. /// User result schema object for the element. public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass CreateElementResult(Autodesk.Revit.DB.BuiltInCategory category, Autodesk.Revit.DB.StructuralAssetClass material) { switch (material) { case StructuralAssetClass.Concrete: switch (category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: return new ResultBeam(); case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: return new ResultColumn(); /// case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical: return new ResultFloor(); case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical: return new ResultFloor(); case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical: return new ResultWall(); /// } break; case StructuralAssetClass.Metal: break; } return null; } /// /// Reads calculation parameters from revit data base. /// /// Acces to cref="ServiceData". /// User calculation parameters schema object. public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass ReadCalculationParameter(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); CalculationParameter calculationParameter = storageDocument.CalculationParamsManager.CalculationParams.GetEntity(data.Document); return calculationParameter; } /// /// Reads parameters of user element label. /// /// Category of the element. /// Material of the element. /// Acces to the Revit storage with labels." /// Acces to cref="ServiceData". /// User label of the element. public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass ReadElementLabel(Autodesk.Revit.DB.BuiltInCategory category, Autodesk.Revit.DB.StructuralAssetClass material, Autodesk.Revit.DB.CodeChecking.Storage.Label label, Autodesk.Revit.DB.CodeChecking.ServiceData data) { if (label != null) { switch (material) { case StructuralAssetClass.Concrete: switch (category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: return label.GetEntity(data.Document); case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: return label.GetEntity(data.Document); /// case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical: return label.GetEntity(data.Document); case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical: return label.GetEntity(data.Document); case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical: return label.GetEntity(data.Document); /// } break; case StructuralAssetClass.Metal: break; } } return null; } /// /// Verify parameters of steel in the label. /// /// Steel properties /// Information about the type of reinforcement. True if longitudinal. /// public List VerifySteel(CodeCheckingConcreteExample.UIComponents.RCSteelParameters.RCSteelParametersSchema steel, bool longitudinal) { List errors = new List(); if (steel.Material == null) errors.Add(Resources.ResourceManager.GetString(longitudinal ? "ErrReinforcementMaterialL" : "ErrReinforcementMaterialT")); else if (steel.MinimumYieldStress < Double.Epsilon) errors.Add(Resources.ResourceManager.GetString(longitudinal ? "ErrReinforcementYieldStressL" : "ErrReinforcementYieldStressT")); if (steel.RebarBarType == null || steel.BarDiameter < Double.Epsilon || steel.DeformationType == Autodesk.Revit.DB.CodeChecking.Engineering.Concrete.ConcreteTypes.SteelSurface.Unknown) errors.Add(Resources.ResourceManager.GetString(longitudinal ? "ErrRebarL" : "ErrRebarT")); return errors; } /// /// Verify parameters of user element label. /// /// Category of the element. /// Material of the element. /// Element label." /// Reference to element's status". public void VerifyElementLabel(Autodesk.Revit.DB.BuiltInCategory category, StructuralAssetClass material, Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass label, ref Autodesk.Revit.DB.CodeChecking.Storage.ResultStatus status) { if (label != null) { switch (material) { case StructuralAssetClass.Concrete: switch (category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: { LabelColumn labelCol = label as LabelColumn; if (labelCol != null) { if (labelCol.EnabledInternalForces.Count == 0) status.AddError(Resources.ResourceManager.GetString("ErrNoChosenInternalForces")); List errors = VerifySteel(labelCol.LongitudinalReinforcement, true); foreach(string s in errors) status.AddError(s); errors = VerifySteel(labelCol.TransversalReinforcement, false); foreach(string s in errors) status.AddError(s); } } break; case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: { LabelBeam labelBm = label as LabelBeam; if (labelBm != null) { if (labelBm.EnabledInternalForces.Count == 0) status.AddError(Resources.ResourceManager.GetString("ErrNoChosenInternalForces")); List errors = VerifySteel(labelBm.LongitudinalReinforcement, true); foreach(string s in errors) status.AddError(s); errors = VerifySteel(labelBm.TransversalReinforcement, false); foreach(string s in errors) status.AddError(s); } } break; case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical: case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical: { LabelFloor labelFloor = label as LabelFloor; if (labelFloor != null) { if (labelFloor.EnabledInternalForces.Count == 0) status.AddError(Resources.ResourceManager.GetString("ErrNoChosenInternalForces")); List errors = VerifySteel(labelFloor.PrimaryReinforcement, true); foreach (string s in errors) status.AddError(s); errors = VerifySteel(labelFloor.SecondaryReinforcement, false); foreach (string s in errors) status.AddError(s); } } break; case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical: { LabelWall labelWall = label as LabelWall; if (labelWall != null) { if (labelWall.EnabledInternalForces.Count == 0) status.AddError(Resources.ResourceManager.GetString("ErrNoChosenInternalForces")); List errors = VerifySteel(labelWall.VerticalReinforcement, true); foreach (string s in errors) status.AddError(s); errors = VerifySteel(labelWall.HorizontalReinforcement, false); foreach (string s in errors) status.AddError(s); } } break; } break; case StructuralAssetClass.Metal: break; } } } /// /// Filters list of elements due to e.g. a result status for calculation purposes. /// /// List of user element objects. /// Filtered list of user element objects. public List FilterElementForCalculation(List listElementData) { List listElementFiltered = new List(); foreach (ObjectDataBase obj in listElementData) { ElementDataBase elem = obj as ElementDataBase; if (elem != null) { if (!elem.Status.IsError()) { listElementFiltered.Add(elem); } } } return listElementFiltered; } /// /// Creates new instance of a user's class with common parameters. /// /// Acces to cref="ServiceData". /// Instance of base class with common parameters. /// New instance of user implementation of class derived from cref="CommonParametersBase". public CommonParametersBase CreateCommonParameters(Autodesk.Revit.DB.CodeChecking.ServiceData data, CommonParametersBase parameters) { Autodesk.Revit.DB.CodeChecking.NotificationService.ProgressStart(Resources.ResourceManager.GetString("DataPreparation"), 1); CommonParameters commonParameters = new CommonParameters(data, parameters); List calculationDataDescriptors = new List(); foreach (Tuple elemStatus in commonParameters.ListElementStatus) { ForceCalculationDataDescriptor forceCalculationDataDescriptor = GetForceCalculationDataDescriptor(data, parameters.ListCombinationId, elemStatus.Item1); /// if (forceCalculationDataDescriptor is ForceCalculationDataDescriptorLinear) { forceCalculationDataDescriptor.AddBendingForceTypes(new ForceType[] { ForceType.Ux, ForceType.Uy, ForceType.Uz }); } /// calculationDataDescriptors.Add(forceCalculationDataDescriptor); if (NotificationService.ProgressBreakInvoked()) break; } ForceResultsPackageDescriptor[] vResPackDesc = new ForceResultsPackageDescriptor[] { ForceResultsPackageDescriptor.GetResultPackageDescriptor(data.Document, commonParameters.ActivePackageGuid) }; // Uncomment the code below to dump to a text file the time spent on accessing ResultsBuilder // Int64 forceResultsCacheAccessTime = System.DateTime.Now.Ticks; commonParameters.ResultCache = new ForceResultsCache(data.Document, calculationDataDescriptors, vResPackDesc, commonParameters.ListCombinationId, GetInputDataUnitSystem()); // Uncomment the code below to dump to a text file the time spent on accessing ResultsBuilder // forceResultsCacheAccessTime = System.DateTime.Now.Ticks - forceResultsCacheAccessTime; foreach (Tuple elemStatus in commonParameters.ListElementStatus) { ForceResultsCache.ElementResultsStatus resultStatus = commonParameters.ResultCache.GetElementResultsStatus(elemStatus.Item1); if (resultStatus != ForceResultsCache.ElementResultsStatus.ResultsOK) { elemStatus.Item2.AddError(Resources.ResourceManager.GetString("ErrStaticResults")); } } // Uncomment the code below to dump to a text file the time spent on accessing ResultsBuilder // using (System.IO.StreamWriter writer = new System.IO.StreamWriter(data.Document.PathName + ".RBAccessTimeInfo.txt", true)) // { // string resultBuilderAccessTime = DateTime.Now.ToString() + " Cache: " + (new System.TimeSpan(forceResultsCacheAccessTime)).TotalSeconds + " RB: " + (new System.TimeSpan(commonParameters.ResultCache.ResultBuilderAccessTime)).TotalSeconds; // // writer.WriteLine(resultBuilderAccessTime); // } Autodesk.Revit.DB.CodeChecking.NotificationService.ProgressStep(""); return commonParameters; } /// /// Creates new instance of class with list of calculation points for user's elements. /// /// Acces to cref="ServiceData". /// User object with common parameters. /// Id of an element. /// List of calculation points for user's element. public List CreateCalcPointsForElement(Autodesk.Revit.DB.CodeChecking.ServiceData data, CommonParametersBase parameters, ElementId elementId) { List calculationPoints = new List(); CommonParameters commonParameters = parameters as CommonParameters; if (commonParameters != null) calculationPoints = commonParameters.ResultCache.GetCalculationPoints(elementId); return calculationPoints; } /// /// Gives possibility to read data from Revit data base and puts them into user element's objects and into user section's objects and into user common parameters. /// /// List of user element objects. /// User common parameters. /// Acces to cref="ServiceData". public void ReadFromRevitDB(List listElementData, CommonParametersBase parameters, Autodesk.Revit.DB.CodeChecking.ServiceData data) { // read additional information from Revit data and store them in user objects derived from ElementDataBase and listed in listElementData Autodesk.Revit.DB.CodeChecking.NotificationService.ProgressStart(Resources.ResourceManager.GetString("ReadingGeometry"), listElementData.Count); ElementAnalyser elementAnalyser = new ElementAnalyser(GetInputDataUnitSystem()); int step = 0; foreach (ObjectDataBase elemData in listElementData) { Element element = data.Document.GetElement(elemData.ElementId); if (element != null) { switch (elemData.Category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: { ColumnElement elem = elemData as ColumnElement; if (elem != null && !elem.Status.IsError()) { elem.Info = elementAnalyser.Analyse(element); if (elem.Info.Material.Characteristics.YoungModulus.X < Double.Epsilon) elem.Status.AddError(Resources.ResourceManager.GetString("ErrYoungModulus")); MaterialConcreteCharacteristics concrete = (MaterialConcreteCharacteristics)elem.Info.Material.Characteristics.Specific; if (concrete == null || concrete.Compression < Double.Epsilon) elem.Status.AddError(Resources.ResourceManager.GetString("ErrConcreteCompression")); foreach (SectionDataBase sectionDataBase in elem.ListSectionData) { ColumnSection sec = sectionDataBase as ColumnSection; if (sec != null) sec.Info = elem.Info; } } break; } case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: { BeamElement elem = elemData as BeamElement; if (elem != null && !elem.Status.IsError()) { elementAnalyser.TSectionAnalysis = false; LabelBeam labelBeam = elem.Label as LabelBeam; if (labelBeam != null) { elementAnalyser.TSectionAnalysis = ( labelBeam.SlabBeamInteraction == BeamSectionType.WithSlabBeamInteraction ); } elem.Info = elementAnalyser.Analyse(element); if (elem.Info.Material.Characteristics.YoungModulus.X < Double.Epsilon) elem.Status.AddError(Resources.ResourceManager.GetString("ErrYoungModulus")); MaterialConcreteCharacteristics concrete = (MaterialConcreteCharacteristics)elem.Info.Material.Characteristics.Specific; if (concrete == null || concrete.Compression < Double.Epsilon) elem.Status.AddError(Resources.ResourceManager.GetString("ErrConcreteCompression")); foreach (SectionDataBase sectionDataBase in elem.ListSectionData) { BeamSection sec = sectionDataBase as BeamSection; if (sec != null) sec.Info = elem.Info; } } break; } /// case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical: case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical: { FloorElement slab = elemData as FloorElement; if (slab != null) { slab.Info = elementAnalyser.Analyse(element); foreach (SectionDataBase secData in slab.ListSectionData) { FloorSection sec = secData as FloorSection; if (sec != null) sec.Info = slab.Info; } } } break; case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical: { WallElement wall = elemData as WallElement; if (wall != null) { wall.Info = elementAnalyser.Analyse(element); foreach (SectionDataBase secData in wall.ListSectionData) { WallSection sec = secData as WallSection; if (sec != null) sec.Info = wall.Info; } } } break; /// } } Autodesk.Revit.DB.CodeChecking.NotificationService.ProgressStep(string.Format("{0:d}%", ++step * 100 / listElementData.Count)); if (NotificationService.ProgressBreakInvoked()) break; } } /// /// Gives possibility to write data to Revit data base. /// /// List of user element objects. /// User common parameters. /// Acces to cref="ServiceData". public void SaveToRevitDB(List listElementData, CommonParametersBase parameters, Autodesk.Revit.DB.CodeChecking.ServiceData data) { Autodesk.Revit.DB.ResultsBuilder.Storage.ResultsPackageBuilder builder = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService().GetStorageDocument(data.Document).CalculationParamsManager.CalculationParams.GetOutputResultPackageBuilder(Server.Server.ID); ForceResultsWriter resultsWriter = new ForceResultsWriter(data.Document, builder, Autodesk.Revit.DB.ResultsBuilder.UnitsSystem.Metric); foreach (ObjectDataBase objectDataBase in listElementData) { ElementDataBase elementDataBase = objectDataBase as ElementDataBase; if (!elementDataBase.Status.IsError()) { switch (elementDataBase.Category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: { //TBD - RB doesn't support relative coordinates as input //Begin mod //IList vx = (from sec in elementDataBase.ListSectionData select (sec as LinearSection).GetCalcResultsInPt()[ResultTypeLinear.X_Rel ]).ToList(); bool isListForces = true; foreach (LinearSection sec in elementDataBase.ListSectionData) { if (sec.ListInternalForces == null || sec.ListInternalForces.Count == 0) { isListForces = false; break; } } if (isListForces) { IList xCoordinates = (from sec in elementDataBase.ListSectionData select (sec as LinearSection).GetCalcResultsInPoint()[ResultTypeLinear.X]).ToList(); //End Mod resultsWriter.SetMeasurementForElement(elementDataBase.ElementId, AxisDirection.X, xCoordinates); ResultTypeLinear[] resultTypesLinear = new ResultTypeLinear[] { ResultTypeLinear.Abottom, ResultTypeLinear.Atop, ResultTypeLinear.Aleft, ResultTypeLinear.Aright }; foreach (ResultTypeLinear forceType in resultTypesLinear) { ICollection valuesInPoints = (from LinearSection section in elementDataBase.ListSectionData select section.GetCalcResultsInPoint()[forceType]).ToList(); resultsWriter.AddResultsForElement(elementDataBase.ElementId, forceType.GetResultType(), valuesInPoints); } } } break; /// case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical: case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical: case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical: IList vx = (from sec in elementDataBase.ListSectionData select (sec as SurfaceSection).GetCalcResultsInPt()[ResultTypeSurface.X]).ToList(); IList vy = (from sec in elementDataBase.ListSectionData select (sec as SurfaceSection).GetCalcResultsInPt()[ResultTypeSurface.Y]).ToList(); IList vz = (from sec in elementDataBase.ListSectionData select (sec as SurfaceSection).GetCalcResultsInPt()[ResultTypeSurface.Z]).ToList(); resultsWriter.SetMeasurementForElement(elementDataBase.ElementId, AxisDirection.X, vx); resultsWriter.SetMeasurementForElement(elementDataBase.ElementId, AxisDirection.Y, vy); resultsWriter.SetMeasurementForElement(elementDataBase.ElementId, AxisDirection.Z, vz); ResultTypeSurface[] vType = new ResultTypeSurface[] { ResultTypeSurface.AxxBottom, ResultTypeSurface.AxxTop, ResultTypeSurface.AyyBottom, ResultTypeSurface.AyyTop }; foreach (ResultTypeSurface forceType in vType) { ICollection vVal = (from sec in elementDataBase.ListSectionData select (sec as SurfaceSection).GetCalcResultsInPt()[forceType]).ToList(); resultsWriter.AddResultsForElement(elementDataBase.ElementId, forceType.GetResultType(), vVal); } break; /// } } } resultsWriter.StoreResultsInResultsBuilder("RCCalculationsResults"); } private Tuple GetElementInternalData(Autodesk.Revit.DB.CodeChecking.ServiceData data, ElementId elementId) { Element element = data.Document.GetElement(elementId); BuiltInCategory category = Autodesk.Revit.DB.CodeChecking.Tools.GetCategoryOfElement(element); StorageDocument storageDocument = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService().GetStorageDocument(data.Document); CalculationParameter calculationParameter = storageDocument.CalculationParamsManager.CalculationParams.GetEntity(data.Document); Label ccLabel = storageDocument.LabelsManager.GetLabel(element); return new Tuple(ccLabel, calculationParameter, category, element); } private List GetForceTypes(Autodesk.Revit.DB.CodeChecking.ServiceData data, IEnumerable elementsIds) { List forceTypes = new List(); foreach (ElementId elementId in elementsIds) { Tuple elementsInternalData = GetElementInternalData(data, elementId); BuiltInCategory category = elementsInternalData.Item3; Label ccLabel = elementsInternalData.Item1; switch (category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: { LabelColumn label = ReadElementLabel(category, ccLabel.Material, ccLabel, data) as LabelColumn; if (label != null) { forceTypes = label.EnabledInternalForces.Select(s => s.GetForceType()).ToList(); } break; } case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: { LabelBeam label = ReadElementLabel(category, ccLabel.Material, ccLabel, data) as LabelBeam; if (label != null) { forceTypes = label.EnabledInternalForces.Select(s => s.GetForceType()).ToList(); } break; } /// case Autodesk.Revit.DB.BuiltInCategory.OST_FloorAnalytical: case Autodesk.Revit.DB.BuiltInCategory.OST_FoundationSlabAnalytical: { LabelFloor label = ReadElementLabel(category, ccLabel.Material, ccLabel, data) as LabelFloor; if (label != null) { if (label.EnabledInternalForces.Contains(EnabledInternalForces.MY)) { forceTypes.Add(ForceType.Mxx); forceTypes.Add(ForceType.Myy); } if (label.EnabledInternalForces.Contains(EnabledInternalForces.FX)) { forceTypes.Add(ForceType.Fyy); forceTypes.Add(ForceType.Fxx); } } break; } case Autodesk.Revit.DB.BuiltInCategory.OST_WallAnalytical: { LabelWall label = ReadElementLabel(category, ccLabel.Material, ccLabel, data) as LabelWall; if (label != null) { if (label.EnabledInternalForces.Contains(EnabledInternalForces.FX)) { forceTypes.Add(ForceType.Fyy); forceTypes.Add(ForceType.Fxx); } if (label.EnabledInternalForces.Contains(EnabledInternalForces.MY)) { forceTypes.Add(ForceType.Mxx); forceTypes.Add(ForceType.Myy); } } break; } /// } } return forceTypes; } #endregion } }