/// <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; } } }
/// <summary> /// Example explaining how to use force modification for beam: /// additonal minimum bending moment over support M=0.1*Mmax in ULS /// </summary> /// <param name="obj">cref="BeamElement" object or cref="ColumnElement" object.</param> private void ModifySupportForces(ObjectDataBase obj) { BeamElement elem = obj as BeamElement; double maximumM = Double.MinValue; double maximumL = Double.MinValue; double minimumL = Double.MaxValue; int beginIndexSupport = -1; int endIndexSupport = -1; int index = 0; bool isMaximumM = false; foreach (SectionDataBase sd in elem.ListSectionData) { BeamSection sec = sd as BeamSection; CalcPointLinear calcPoint = sec.CalcPoint as CalcPointLinear; if (calcPoint != null) { if (maximumL < calcPoint.CoordRelative) { maximumL = calcPoint.CoordRelative; endIndexSupport = index; } if (minimumL > calcPoint.CoordRelative) { minimumL = calcPoint.CoordRelative; beginIndexSupport = index; } } if (sec != null) { foreach (InternalForcesBase forces in sec.ListInternalForces) { InternalForcesLinear f = forces as InternalForcesLinear; if (f != null) { if (f.Forces.LimitState == ForceLimitState.Uls) { if (maximumM < f.Forces.MomentMy) { maximumM = f.Forces.MomentMy; isMaximumM = true; } } } } } index++; } if (isMaximumM) { if (beginIndexSupport > -1) { BeamSection bs = elem.ListSectionData[beginIndexSupport] as BeamSection; if (bs != null) { InternalForcesLinear f = new InternalForcesLinear(); f.Forces.LimitState = ForceLimitState.Uls; f.Forces.MomentMy = 0.1 * maximumM; bs.ListInternalForces.Add(f); } } if (endIndexSupport > -1) { BeamSection bs = elem.ListSectionData[endIndexSupport] as BeamSection; if (bs != null) { InternalForcesLinear f = new InternalForcesLinear(); f.Forces.LimitState = ForceLimitState.Uls; f.Forces.MomentMy = 0.1 * maximumM; bs.ListInternalForces.Add(f); } } } }
/// <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) { SectionDataBase sectionData = obj as SectionDataBase; if (obj != null) { CommonParameters commParams = Parameters as CommonParameters; ForceResultsCache cache = null; if (commParams != null) { cache = commParams.ResultCache; } Section sec = null; switch (sectionData.Category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: if (sectionData is ColumnSection) { ColumnSection section = sectionData as ColumnSection; if (section.Info != null) { SectionsInfo secInfo = section.Info.Sections.AtTheBeg; if (secInfo.Sections.Count > 0) { sec = secInfo.Sections[0]; } } } break; case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: if (sectionData is BeamSection && sectionData.Label is LabelBeam) { BeamSection section = sectionData as BeamSection; LabelBeam label = sectionData.Label as LabelBeam; if (section.Info != null) { SectionsInfo secInfo = section.Info.Sections.AtTheBeg; if (secInfo.Sections.Count > 0) { sec = secInfo.Sections[0]; if (label.SlabBeamInteraction == ConcreteTypes.BeamSectionType.WithSlabBeamInteraction && section.Info.Slabs != null && section.Info.Slabs.TSection != null) { int nbrPoints = (sec.Contour != null && sec.Contour.Points != null) ? sec.Contour.Points.Count : 0; double relativeX = (section.CalcPoint as CalcPointLinear).CoordRelative; double maxFlangeWidth = 0.5 * section.Info.SectionsParams.AtThePoint(relativeX).Dimensions.h; sec = section.Info.Slabs.TSection.GetContour(relativeX, maxFlangeWidth, maxFlangeWidth); if (sec.Contour.Points.Count != nbrPoints) { section.IsTSection = true; section.DesignInfo.Add(Resources.ResourceManager.GetString("SlabBeamInteraction")); } } } } } break; } switch (sectionData.Category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: if (sectionData is LinearSection) { LinearSection section = sectionData as LinearSection; if (sec != null && sec.Contour != null) { foreach (Autodesk.Revit.DB.XYZ p in sec.Contour.Points) { section.Geometry.Add(p.X, p.Y); } Autodesk.Revit.DB.XYZ pmin = sec.GetMinimumBoundary(); Autodesk.Revit.DB.XYZ pmax = sec.GetMaximumBoundary(); section.Width = Math.Abs(pmin.X - pmax.X); section.Height = Math.Abs(pmin.Y - pmax.Y); } if (cache != null) { IList <ForceLoadCaseDescriptor> loadCaseDescriptors = cache.GetLoadCaseDescriptors(); List <double> vFx = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Fx); List <double> vFy = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Fy); List <double> vFz = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Fz); List <double> vMx = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Mx); List <double> vMy = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.My); List <double> vMz = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Mz); List <double> vUx = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Ux); List <double> vUy = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Uy); List <double> vUz = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Uz); int i = -1; foreach (ForceLoadCaseDescriptor cas in loadCaseDescriptors) { i++; InternalForcesLinear linForces = new InternalForcesLinear(); InternalForcesContainer forces = new InternalForcesContainer(); forces.CaseName = cas.Name; forces.LimitState = cas.State; forces.ForceFx = vFx.Count == 0 ? 0.0 : vFx[i]; forces.ForceFy = vFy.Count == 0 ? 0.0 : vFy[i]; forces.ForceFz = vFz.Count == 0 ? 0.0 : vFz[i]; forces.MomentMx = vMx.Count == 0 ? 0.0 : vMx[i]; forces.MomentMy = vMy.Count == 0 ? 0.0 : vMy[i]; forces.MomentMz = vMz.Count == 0 ? 0.0 : vMz[i]; forces.DeflectionUx = vUx.Count == 0 ? 0.0 : vUx[i]; forces.DeflectionUy = vUy.Count == 0 ? 0.0 : vUy[i]; forces.DeflectionUz = vUz.Count == 0 ? 0.0 : vUz[i]; linForces.Forces = forces; section.ListInternalForces.Add(linForces); } } } break; } } return(true); }
/// <summary> /// Runs calculation\operations for cref="BeamElement". /// </summary> /// <param name="obj">cref="BeamElement".</param> /// <returns>Result of calculation.</returns> public bool Run(ObjectDataBase obj) { ElementDataBase elementData = obj as ElementDataBase; if (obj != null) { BeamElement objBeam = obj as BeamElement; if (objBeam != null) { CodeCheckingConcreteExample.Main.ResultBeam res = elementData.Result as CodeCheckingConcreteExample.Main.ResultBeam; if (res != null) { double young = objBeam.Info.Material.Characteristics.YoungModulus.X; double maxCoef = 0; double stifCoef = 0.0; double avrCoef = 0.0; int sectionNo = 0; foreach (SectionDataBase sd in elementData.ListSectionData) { BeamSection sec = sd as BeamSection; if (sec != null) { if (sec.MinStiffness > Double.Epsilon) { CalcPointLinear calcPoint = sec.CalcPoint as CalcPointLinear; double Iy = sec.Info.SectionsParams.AtThePoint(calcPoint.CoordRelative).Characteristics.Iy; stifCoef = (Iy * young) / sec.MinStiffness; } else { stifCoef = 0; break; } ++sectionNo; maxCoef = Math.Max(maxCoef, stifCoef); avrCoef += stifCoef; } } double finStiffnes = 0; if (stifCoef > Double.Epsilon) { avrCoef /= sectionNo; finStiffnes = 0.5 * (maxCoef + avrCoef); } else { objBeam.AddFormatedWarning(new ResultStatusMessage("Calculation of deflections was not performed.")); } foreach (SectionDataBase sd in elementData.ListSectionData) { BeamSection sec = sd as BeamSection; if (sec != null) { sec.StiffnesCoeff = finStiffnes; } } } } } return(true); }