/// <summary> /// 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. /// </summary> /// <param name="listElementData">List of user element objects.</param> /// <param name="parameters">User common parameters.</param> /// <param name="data">Acces to cref="ServiceData".</param> public void ReadFromRevitDB(List <ObjectDataBase> 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; } } } Autodesk.Revit.DB.CodeChecking.NotificationService.ProgressStep(string.Format("{0:d}%", ++step * 100 / listElementData.Count)); if (NotificationService.ProgressBreakInvoked()) { break; } } }
public void DoBinding(MaterialInfo materialParams, MaterialLayerDescription layerDescription, Autodesk.Revit.DB.DisplayUnit?unitSystem) { if (layerDescription != null) { string unitThicknessName = "LayerThickness"; string unitOffsetName = "LayerOffset"; string unitThickness; string unitOffset; if (null == unitSystem) { unitThickness = UnitsAssignment.GetUnitSymbol(unitThicknessName, ElementInfoUnits.Assignments); unitOffset = UnitsAssignment.GetUnitSymbol(unitOffsetName, ElementInfoUnits.Assignments); } else { unitThickness = UnitsAssignment.GetUnitSymbol(unitThicknessName, ElementInfoUnits.Assignments, (Autodesk.Revit.DB.DisplayUnit)unitSystem); unitOffset = UnitsAssignment.GetUnitSymbol(unitOffsetName, ElementInfoUnits.Assignments, (Autodesk.Revit.DB.DisplayUnit)unitSystem); } string stringThicknessValue = layerDescription.LayerThickness.ToString(); string stringOffsetValue = layerDescription.LayerOffset.ToString(); if (null == unitSystem) { stringThicknessValue = UnitsAssignment.FormatToRevitUI(unitThicknessName, layerDescription.LayerThickness, ElementInfoUnits.Assignments); stringOffsetValue = UnitsAssignment.FormatToRevitUI(unitOffsetName, layerDescription.LayerOffset, ElementInfoUnits.Assignments); } LayerThickness.Content = stringThicknessValue + " " + unitThickness; LayerOffset.Content = stringOffsetValue + " " + unitOffset; LayerDescription.Visibility = System.Windows.Visibility.Visible; } else { LayerDescription.Visibility = System.Windows.Visibility.Collapsed; } List <MaterialParameterDescription> matParDescrList = new List <MaterialParameterDescription>(); if (materialParams.Category != MaterialCategory.Undefined) { MaterialName.Content = materialParams.Properties.Name; MaterialDescription.Content = materialParams.Properties.Description; MaterialCharacteristics materialCharacteristics = materialParams.Characteristics; foreach (object o in materialCharacteristics) { List <MaterialParameterDescription> matParDescr = ParameterBinding(o, materialCharacteristics, MaterialCharacteristicsUnits.Assignments, unitSystem); if (null == matParDescr) { continue; } matParDescrList.AddRange(matParDescr); } } switch (materialParams.Category) { case MaterialCategory.Concrete: MaterialConcreteCharacteristics concrete = (MaterialConcreteCharacteristics)materialParams.Characteristics.Specific; foreach (object o in concrete) { List <MaterialParameterDescription> matParDescr = ParameterBinding(o, concrete, MaterialConcreteCharacteristicsUnits.Assignments, unitSystem); if (matParDescr != null) { matParDescrList.AddRange(matParDescr); } } break; case MaterialCategory.Metal: MaterialMetalCharacteristics metal = (MaterialMetalCharacteristics)materialParams.Characteristics.Specific; foreach (object o in metal) { List <MaterialParameterDescription> matParDescr = ParameterBinding(o, metal, MaterialMetalCharacteristicsUnits.Assignments, unitSystem); if (matParDescr != null) { matParDescrList.AddRange(matParDescr); } } break; case MaterialCategory.Timber: MaterialTimberCharacteristics timber = (MaterialTimberCharacteristics)materialParams.Characteristics.Specific; foreach (object o in timber) { List <MaterialParameterDescription> matParDescr = ParameterBinding(o, timber, MaterialTimberCharacteristicsUnits.Assignments, unitSystem); if (matParDescr != null) { matParDescrList.AddRange(matParDescr); } } break; } materialParameters.ItemsSource = matParDescrList; }
/// <summary> /// Runs calculation\operations for cref="BeamSection" and cref="ColumnSection". /// </summary> /// <param name="obj">cref="BeamSection" object or cref="ColumnSection" object.</param> /// <returns>Result of calculation.</returns> public bool Run(ObjectDataBase obj) { bool ret = true; SectionDataBase sectionData = obj as SectionDataBase; if (obj != null) { Concrete.ConcreteSectionDesign design = new ConcreteSectionDesign(); design.ElementType = sectionData.Category; switch (sectionData.Category) { default: break; case BuiltInCategory.OST_ColumnAnalytical: case BuiltInCategory.OST_BeamAnalytical: if (sectionData.Label is LabelColumn) { CodeCheckingConcreteExample.Main.LabelColumn label = sectionData.Label as CodeCheckingConcreteExample.Main.LabelColumn; design.LongitudinalReinforcementMinimumYieldStress = label.LongitudinalReinforcement.MinimumYieldStress; design.LongitudinalReinforcementArea = label.LongitudinalReinforcement.Area; design.LongitudinalReinforcementDiameter = label.LongitudinalReinforcement.BarDiameter; design.LongitudinalCalculationType = label.LongitudinalCalculationType; /// design.TransversalReinforcementMinimumYieldStress = label.TransversalReinforcement.MinimumYieldStress; design.TransversalReinforcementArea = label.TransversalReinforcement.Area; design.TransversalReinforcementDiameter = label.TransversalReinforcement.BarDiameter; design.TransversalCalculationType = label.TransversalCalculationType; design.CreepCoefficient = label.CreepCoefficient; } if (sectionData.Label is LabelBeam) { CodeCheckingConcreteExample.Main.LabelBeam label = sectionData.Label as CodeCheckingConcreteExample.Main.LabelBeam; design.LongitudinalReinforcementMinimumYieldStress = label.LongitudinalReinforcement.MinimumYieldStress; design.LongitudinalReinforcementArea = label.LongitudinalReinforcement.Area; design.LongitudinalReinforcementDiameter = label.LongitudinalReinforcement.BarDiameter; design.LongitudinalCalculationType = label.LongitudinalCalculationType; /// design.TransversalReinforcementMinimumYieldStress = label.TransversalReinforcement.MinimumYieldStress; design.TransversalReinforcementArea = label.TransversalReinforcement.Area; design.TransversalReinforcementDiameter = label.TransversalReinforcement.BarDiameter; design.TransversalCalculationType = label.TransversalCalculationType; design.CreepCoefficient = label.CreepCoefficient; } if (sectionData is LinearSection) { LinearSection section = sectionData as LinearSection; if (section.Info != null) { design.CoverTop = 0.0; design.CoverBottom = 0.0; if (section.Info.RebarCovers != null) { if (section is BeamSection) { if (section.Info.RebarCovers.Exist(BuiltInParameter.CLEAR_COVER_BOTTOM)) { design.CoverBottom = section.Info.RebarCovers.GetDistance(BuiltInParameter.CLEAR_COVER_BOTTOM); } if (section.Info.RebarCovers.Exist(BuiltInParameter.CLEAR_COVER_TOP)) { design.CoverTop = section.Info.RebarCovers.GetDistance(BuiltInParameter.CLEAR_COVER_TOP); } } if (section is ColumnSection) { if (section.Info.RebarCovers.Exist(BuiltInParameter.CLEAR_COVER_OTHER)) { design.CoverBottom = section.Info.RebarCovers.GetDistance(BuiltInParameter.CLEAR_COVER_OTHER); design.CoverTop = section.Info.RebarCovers.GetDistance(BuiltInParameter.CLEAR_COVER_OTHER); } } } if (section.Info.SectionsParams == null) { design.Type = SectionShapeType.RectangularBar; } else { design.Type = section.Info.SectionsParams.ShapeType; } design.YoungModulus = section.Info.Material.Characteristics.YoungModulus.X; MaterialConcreteCharacteristics concrete = (MaterialConcreteCharacteristics)section.Info.Material.Characteristics.Specific; if (concrete != null) { design.Compression = concrete.Compression; } design.Geometry = section.Geometry; design.Width = section.Width; design.Height = section.Height; List <InternalForcesContainer> listInternalForces = new List <InternalForcesContainer>(); foreach (InternalForcesLinear force in section.ListInternalForces) { listInternalForces.Add(force.Forces); } design.ListInternalForces = listInternalForces;; // // calculation // design.Calculate(); // // save result // section.AsBottom = design.AsBottom; section.AsTop = design.AsTop; section.AsRight = design.AsRight; section.AsLeft = design.AsLeft; section.Spacing = design.Spacing; section.TransversalDensity = design.TransversalDensity; section.MinStiffness = design.MinStiffness; section.DesignInfo.AddRange(design.DesignInfo); section.DesignError.AddRange(design.DesignError); section.DesignWarning.AddRange(design.DesignWarning); if (section.DesignError.Count > 0) { ret = false; } } } break; } } return(ret); }
public void DoBinding(MaterialInfo materialParams, Autodesk.Revit.DB.DisplayUnit?unitSystem) { List <MaterialParameterDescription> matParDescrList = new List <MaterialParameterDescription>(); if (materialParams.Category != MaterialCategory.Undefined) { MaterialName.Content = materialParams.Properties.Name; MaterialDescription.Content = materialParams.Properties.Description; MaterialCharacteristics materialCharacteristics = materialParams.Characteristics; foreach (object o in materialCharacteristics) { List <MaterialParameterDescription> matParDescr = ParameterBinding(o, materialCharacteristics, MaterialCharacteristicsUnits.Assignments, unitSystem); if (null == matParDescr) { continue; } matParDescrList.AddRange(matParDescr); } } switch (materialParams.Category) { case MaterialCategory.Concrete: MaterialConcreteCharacteristics concrete = (MaterialConcreteCharacteristics)materialParams.Characteristics.Specific; foreach (object o in concrete) { List <MaterialParameterDescription> matParDescr = ParameterBinding(o, concrete, MaterialConcreteCharacteristicsUnits.Assignments, unitSystem); if (matParDescr != null) { matParDescrList.AddRange(matParDescr); } } break; case MaterialCategory.Metal: MaterialMetalCharacteristics metal = (MaterialMetalCharacteristics)materialParams.Characteristics.Specific; foreach (object o in metal) { List <MaterialParameterDescription> matParDescr = ParameterBinding(o, metal, MaterialMetalCharacteristicsUnits.Assignments, unitSystem); if (matParDescr != null) { matParDescrList.AddRange(matParDescr); } } break; case MaterialCategory.Timber: MaterialTimberCharacteristics timber = (MaterialTimberCharacteristics)materialParams.Characteristics.Specific; foreach (object o in timber) { List <MaterialParameterDescription> matParDescr = ParameterBinding(o, timber, MaterialTimberCharacteristicsUnits.Assignments, unitSystem); if (matParDescr != null) { matParDescrList.AddRange(matParDescr); } } break; } materialParameters.ItemsSource = matParDescrList; }