public WordDocument(Stream stream) { package = new WordDocumentPackage(stream); Body = new DocumentBody(this, package.DocumentPart); FooderCollection = new FooderCollection(package, this); NumberingCollection = new NumberingCollection(package.NumberingPart, package); }
public bool DeleteDocument() { var connection = new SqlConnection(connectionString); var sql1 = string.Format("DELETE FROM {0} WHERE DocumentID = {1}", bodyTable, Head.DocumentNumber); var sql2 = string.Format("DELETE FROM {0} WHERE DocumentID = {1}", headTable, Head.DocumentNumber); SqlTransaction tn = null;; try { connection.Open(); tn = connection.BeginTransaction(); var cmd = new SqlCommand(sql2, connection, tn); cmd.ExecuteNonQuery(); cmd.CommandText = sql1; cmd.ExecuteNonQuery(); tn.Commit(); } catch (Exception exc) { error = exc; tn.Rollback(); return(false); } Head = new InputDocumentHead(); DocumentBody.Clear(); return(true); }
public WordDocument(CultureInfo culture, bool isTemplate = false) { package = new WordDocumentPackage(culture, isTemplate); Body = new DocumentBody(this, package.DocumentPart); FooderCollection = new FooderCollection(package, this); NumberingCollection = new NumberingCollection(null, package); }
public void CreateReportSchema() { var server = new ServerUI(); // new schema base on default constructor var schema = new Schema(); // Add schema to the main report DocumentBody.FillBody(schema, this.docReport.Main, server, this.docRevit); }
/// <summary> /// Replace Body Tag. /// </summary> private void FinishBodyNode() { var tmpDict = new Dictionary <string, string>() { { "classes", string.Join(" ", DocumentBody.ClassList) }, { "contents", DocumentBody.InnerHtml }, }; DocumentBody.Replace(CreateFromHtml(Template("body", tmpDict), DocumentBody as IElement)); }
private void FinishTableNodes() { var tmpChildNodes = DocumentBody.Descendents().Where(inItem => (inItem as IElement)?.LocalName == "table"); foreach (IElement tmpChild in tmpChildNodes) { tmpChild.SetAttribute("border", "0"); tmpChild.SetAttribute("cellpadding", "0"); tmpChild.SetAttribute("cellspacing", "0"); } }
/// <summary> /// Replace all nodes with the Type and the spezified Template /// </summary> /// <param name="inTemplateFileName"></param> private void ReplaceNodesByTag(string inTag, string inTemplateFileName) { inTag = inTag.ToLower(); var tmpChildNodes = DocumentBody.Descendents().Where(inItem => (inItem as IElement)?.LocalName == inTag); foreach (IElement tmpNode in tmpChildNodes.Reverse().ToList()) { tmpNode.ClassList.Add("hr"); ReplaceNodeWithTemplateNode(tmpNode, inTemplateFileName); } }
/// </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); }
/// <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); }
/// <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> /// 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); } } } } }
/// <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); } } }