/// <summary> /// function used to extract offset value from constraint /// </summary> /// <param name="updateData"> data used to pass or get information regarding constraints cover</param> /// <param name="constraint">constraint from which we extract the offset information</param> /// <param name="targetIdx">index of target in constraint</param> /// <param name="offset"> output value </param> /// <returns></returns> public static bool getOffsetFromConstraintAtTarget(RebarUpdateCurvesData updateData, RebarConstraint constraint, int targetIdx, out double offset) { offset = 0.0; if (updateData == null || constraint == null) { return(false); } double barDiam = updateData.GetBarModelDiameter(); var rebarStyle = updateData.GetRebarStyle(); var attachment = updateData.GetAttachmentType(); bool bIsInside = rebarStyle == RebarStyle.Standard || (rebarStyle != RebarStyle.Standard && attachment == StirrupTieAttachmentType.InteriorFace); if (constraint.IsToCover()) { if (targetIdx < 0 || targetIdx >= constraint.NumberOfTargets) { return(false); // incorrect index } RebarCoverType coverType = constraint.GetTargetCoverType(targetIdx); double coverDist = (coverType == null) ? 0.0 : coverType.CoverDistance; double diameterOffset = (barDiam / 2); if (bIsInside) { diameterOffset *= -1; } offset = constraint.GetDistanceToTargetCover() - coverDist + diameterOffset; return(true); } offset = constraint.GetDistanceToTargetHostFace(); return(true); }
public double rebarCover(Element e) { Autodesk.Revit.DB.Parameter rcPara = e.LookupParameter("Rebar Cover - Exterior Face"); ElementId rcId = rcPara.AsElementId(); RebarCoverType rcType = doc.GetElement(rcId) as ElementType as RebarCoverType; return(rcType.CoverDistance);; }
public static Dictionary <string, object> getRebarCover(List <Revit.Elements.Element> elements) { string message = ""; Document doc = DocumentManager.Instance.CurrentDBDocument; DynaFunctions f = new DynaFunctions(); //UIApplication uiapp = DocumentManager.Instance.CurrentUIApplication; //Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; //UIDocument uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument; List <double> topExterior = new List <double>(); List <double> bottomInterior = new List <double>(); List <double> others = new List <double>(); Autodesk.Revit.DB.Element el; List <BuiltInParameter> covers = new List <BuiltInParameter> { BuiltInParameter.CLEAR_COVER_EXTERIOR, BuiltInParameter.CLEAR_COVER_TOP, BuiltInParameter.CLEAR_COVER_INTERIOR, BuiltInParameter.CLEAR_COVER_BOTTOM, BuiltInParameter.CLEAR_COVER_OTHER, BuiltInParameter.CLEAR_COVER }; foreach (Revit.Elements.Element e in elements) { el = doc.GetElement(e.UniqueId.ToString()); List <double> coverValue = new List <double>(); foreach (BuiltInParameter c in covers) { try { ElementId rctId = el.get_Parameter(c).AsElementId(); RebarCoverType rct = doc.GetElement(rctId) as RebarCoverType; double cv = f.feetToMillimeter(rct.get_Parameter(BuiltInParameter.COVER_TYPE_LENGTH).AsDouble()); coverValue.Add(cv); } catch (Exception ex) { message = ex.Message; } } topExterior.Add(coverValue[0]); bottomInterior.Add(coverValue[1]); others.Add(coverValue[2]); } return(new Dictionary <string, object> { { "topExterior", topExterior }, { "bottomInterior", bottomInterior }, { "others", others }, //{ "Message", message }, }); }
private void Stream(ArrayList data, RebarCoverType rebarCoverType) { data.Add(new Snoop.Data.ClassSeparator(typeof(RebarCoverType))); data.Add(new Snoop.Data.Double("Cover distance", rebarCoverType.CoverDistance)); }
Stream(ArrayList data, ElementType sym) { data.Add(new Snoop.Data.ClassSeparator(typeof(ElementType))); // no data at this level yet AnnotationSymbolType annoType = sym as AnnotationSymbolType; if (annoType != null) { Stream(data, annoType); return; } AreaReinforcementType areaReinforcementType = sym as AreaReinforcementType; if (areaReinforcementType != null) { Stream(data, areaReinforcementType); return; } AreaTagType areaTagType = sym as AreaTagType; if (areaTagType != null) { Stream(data, areaTagType); return; } BeamSystemType beamSystemType = sym as BeamSystemType; if (beamSystemType != null) { Stream(data, beamSystemType); return; } DimensionType dimType = sym as DimensionType; if (dimType != null) { Stream(data, dimType); return; } //TF FabricSheetType fabricST = sym as FabricSheetType; if (fabricST != null) { Stream(data, fabricST); return; } FabricWireType fabricWT = sym as FabricWireType; if (fabricWT != null) { Stream(data, fabricWT); return; } //TFEND GroupType groupType = sym as GroupType; if (groupType != null) { Stream(data, groupType); return; } HostObjAttributes hostAtt = sym as HostObjAttributes; if (hostAtt != null) { Stream(data, hostAtt); return; } InsertableObject insObj = sym as InsertableObject; if (insObj != null) { Stream(data, insObj); return; } LevelType levelType = sym as LevelType; if (levelType != null) { Stream(data, levelType); return; } LineAndTextAttrSymbol lineAndTextAttr = sym as LineAndTextAttrSymbol; if (lineAndTextAttr != null) { Stream(data, lineAndTextAttr); return; } LoadTypeBase loadTypeBase = sym as LoadTypeBase; if (loadTypeBase != null) { Stream(data, loadTypeBase); return; } MEPBuildingConstruction mepBldConst = sym as MEPBuildingConstruction; if (mepBldConst != null) { Stream(data, mepBldConst); return; } PathReinforcementType pathReinforcementType = sym as PathReinforcementType; if (pathReinforcementType != null) { Stream(data, pathReinforcementType); return; } RebarBarType rebarBarType = sym as RebarBarType; if (rebarBarType != null) { Stream(data, rebarBarType); return; } RebarCoverType rebarCoverType = sym as RebarCoverType; if (rebarCoverType != null) { Stream(data, rebarCoverType); return; } RebarHookType rebarHookType = sym as RebarHookType; if (rebarHookType != null) { Stream(data, rebarHookType); return; } RebarShape rebarShape = sym as RebarShape; if (rebarShape != null) { Stream(data, rebarShape); return; } RoomTagType roomTagType = sym as RoomTagType; if (roomTagType != null) { Stream(data, roomTagType); return; } SpaceTagType spaceTagType = sym as SpaceTagType; if (spaceTagType != null) { Stream(data, spaceTagType); return; } TrussType trussType = sym as TrussType; if (trussType != null) { Stream(data, trussType); return; } DistributionSysType distSysType = sym as DistributionSysType; if (distSysType != null) { Stream(data, distSysType); return; } MEPCurveType mepCurType = sym as MEPCurveType; if (mepCurType != null) { Stream(data, mepCurType); return; } FluidType fluidType = sym as FluidType; if (fluidType != null) { Stream(data, fluidType); return; } PipeScheduleType pipeSchedType = sym as PipeScheduleType; if (pipeSchedType != null) { Stream(data, pipeSchedType); return; } VoltageType voltType = sym as VoltageType; if (voltType != null) { Stream(data, voltType); return; } WireType wireType = sym as WireType; if (wireType != null) { Stream(data, wireType); return; } ModelTextType modelTxtType = sym as ModelTextType; if (modelTxtType != null) { Stream(data, modelTxtType); return; } }
Stream(ArrayList data, RebarCoverType rebarCoverType) { data.Add(new Snoop.Data.ClassSeparator(typeof(RebarCoverType))); data.Add(new Snoop.Data.Double("Cover distance", rebarCoverType.CoverDistance)); }
/// <summary> /// This method parses geometry information of given Corbel to construct the CorbelFrame. /// </summary> /// <param name="corbel">Given corbel family instance to parse</param> /// <returns>CorbelFrame object</returns> public static CorbelFrame ParseCorbelGeometry(FamilyInstance corbel) { // Get Corbel Host information. Element corbelHost = corbel.Host; Reference corbelHostFace = corbel.HostFace; PlanarFace hostPlane = corbelHost.GetGeometryObjectFromReference(corbelHostFace) as PlanarFace; XYZ hostNormal = GetNormalOutside(hostPlane); // Extract the faces in Corbel parallel with Corbel host face. Solid corbelSolid = GetElementSolid(corbel); PlanarFace corbelTopFace = null; PlanarFace corbelBottomFace = null; foreach (Face face in corbelSolid.Faces) { PlanarFace planarFace = face as PlanarFace; XYZ normal = GetNormalOutside(planarFace); if (normal.IsAlmostEqualTo(hostNormal)) { corbelTopFace = planarFace; } else if (normal.IsAlmostEqualTo(-hostNormal)) { corbelBottomFace = planarFace; } } // Extract the faces in Corbel Host parallel with Corbel host face. Solid hostSolid = GetElementSolid(corbelHost); PlanarFace hostTopFace = null; PlanarFace hostBottomFace = hostPlane; foreach (Face face in hostSolid.Faces) { PlanarFace planarFace = face as PlanarFace; XYZ normal = GetNormalOutside(planarFace); if (normal.IsAlmostEqualTo(-hostNormal)) { hostTopFace = planarFace; } } // Parse the side faces to find out the Trapezoid face. Edge topEdge = null; Edge leftEdge = null; Edge bottomEdge = null; Edge rightEdge = null; PlanarFace trapezoidFace = null; int foundEdgeIndex = -1; bool foundTrapezoid = false; EdgeArray bottomEdges = corbelBottomFace.EdgeLoops.get_Item(0); foreach (Edge edge in bottomEdges) { bottomEdge = edge; foundEdgeIndex++; foundTrapezoid = IsTrapezoid(hostNormal, corbelBottomFace, bottomEdge, out trapezoidFace, out topEdge, out leftEdge, out rightEdge); if (foundTrapezoid) { break; } } // Check to see if the Trapezoid faces was found. if (!foundTrapezoid) { // Throw if no any trapezoid face in corbel. throw new Exception("Didn't find the trapezoid face in corbel [Id:" + corbel.Id + "]."); } Edge depthEdge = bottomEdges.get_Item((foundEdgeIndex + 1) % bottomEdges.Size); double hostDepth = GetDistance(hostTopFace, hostBottomFace); // Compute the host face cover distance. RebarHostData corbelHostData = RebarHostData.GetRebarHostData(corbelHost); // Get CoverType of the given host face RebarCoverType coverType = corbelHostData.GetCoverType(hostTopFace.Reference); // if the host face don't have a CoverType, then try to get the common CoverType. if (coverType == null) { coverType = corbelHostData.GetCommonCoverType(); } // Get the Cover Distance double coverDistance = coverType.CoverDistance; // Construct the CorbelFrame from the given parsed trapezoid information. return(ConstructCorbelFrame( corbel, depthEdge, leftEdge, bottomEdge, rightEdge, topEdge, corbel.Document, trapezoidFace, hostDepth, coverDistance)); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Debug.Listeners.Clear(); Debug.Listeners.Add(new RbsLogger.Logger("FloorAreaRebar")); Debug.WriteLine("Floor reinforcement start"); App.ActivateConfigFolder(); Document doc = commandData.Application.ActiveUIDocument.Document; Selection sel = commandData.Application.ActiveUIDocument.Selection; List <Floor> floors = new List <Floor>(); foreach (ElementId id in sel.GetElementIds()) { Element elem = doc.GetElement(id); if (elem is Floor) { floors.Add(elem as Floor); } } Debug.WriteLine("Selected floors: " + floors.Count); if (floors.Count == 0) { message = "Выберите плиты для армирования"; return(Result.Failed); } ElementId areaTypeId = SupportDocumentGetter.GetDefaultArea(doc).Id; Debug.WriteLine("AreaTypeId: " + areaTypeId.IntegerValue); RebarCoverType zeroCover = SupportDocumentGetter.GetRebarCoverType(doc, 0); Debug.WriteLine("Zero cover type id: " + zeroCover.Id.IntegerValue); List <string> rebarTypes = SupportDocumentGetter.GetRebarTypes(doc); Debug.WriteLine("Rebar types: " + rebarTypes.Count); if (floors.Count == 0) { message = "Нет подходящих перекрытий для армирования"; return(Result.Failed); } foreach (Floor fl in floors) { Parameter floorIsStructuralParam = fl.get_Parameter(BuiltInParameter.FLOOR_PARAM_IS_STRUCTURAL); if (floorIsStructuralParam != null) { if (floorIsStructuralParam.AsInteger() != 1) { elements.Insert(fl); } } } Debug.WriteLine("Structural floors: " + (floors.Count - elements.Size)); if (elements.Size > 0) { message = "Найдены не несущие плиты, армирование не будет выполнено"; return(Result.Failed); } string floorPath = System.IO.Path.Combine(App.localFolder, "floor.xml"); RebarInfoFloor rif = null; XmlSerializer serializer = new XmlSerializer(typeof(RebarInfoFloor)); if (System.IO.File.Exists(floorPath)) { using (System.IO.StreamReader reader = new System.IO.StreamReader(floorPath)) { try { rif = (RebarInfoFloor)serializer.Deserialize(reader); } catch (Exception ex) { Debug.WriteLine("Unable to deserialize, create new one: " + ex.Message); rif = RebarInfoFloor.GetDefault(doc); } if (rif == null) { Debug.WriteLine("Deserialize error: " + floorPath); throw new Exception("Не удалось десериализовать: " + floorPath); } } } else { Debug.WriteLine("No xml file, create new one"); rif = RebarInfoFloor.GetDefault(doc); } DialogWindowFloor form = new DialogWindowFloor(rif, rebarTypes); form.ShowDialog(); if (form.DialogResult != System.Windows.Forms.DialogResult.OK) { Debug.WriteLine("Cancelled by user"); return(Result.Cancelled); } if (File.Exists(floorPath)) { Debug.WriteLine("File is deleted: " + floorPath); File.Delete(floorPath); } using (FileStream writer = new FileStream(floorPath, FileMode.OpenOrCreate)) { serializer.Serialize(writer, form.rif); Debug.WriteLine("New file is created: " + floorPath); } List <string> rebarMessages = new List <string>(); using (Transaction t = new Transaction(doc)) { t.Start("Армирование плит"); foreach (Floor floor in floors) { Debug.WriteLine("Current reinforcement floor: " + floor.Id.IntegerValue); List <string> curRebarMessages = RebarWorkerFloor.Generate(doc, floor, rif, areaTypeId); rebarMessages.AddRange(curRebarMessages); } t.Commit(); } if (rebarMessages.Count > 0) { foreach (string msg in rebarMessages) { message += msg + System.Environment.NewLine; } Debug.WriteLine("Errors: " + message); return(Result.Failed); } Debug.WriteLine("All done"); return(Result.Succeeded); }
public static List <string> Generate(Document doc, Floor floor, RebarInfoFloor rif, ElementId areaTypeId) { Debug.WriteLine("RebarWorkerFloor is started"); List <string> messages = new List <string>(); MyRebarType mrt = new MyRebarType(doc, rif.rebarTypeName); if (mrt.isValid == false) { messages.Add("Не удалось получить тип стержня " + rif.rebarTypeName); } double interval = rif.interval; double topCoverUser = rif.topCover; double bottomCoverUser = rif.bottomCover; RebarCoverType coverTop = doc.GetElement(floor.get_Parameter(BuiltInParameter.CLEAR_COVER_TOP).AsElementId()) as RebarCoverType; RebarCoverType coverBottom = doc.GetElement(floor.get_Parameter(BuiltInParameter.CLEAR_COVER_BOTTOM).AsElementId()) as RebarCoverType; if (coverTop == null) { Debug.WriteLine("Top cover is null"); coverTop = coverBottom; } if (coverBottom == null) { Debug.WriteLine("Bottom cover is null"); coverBottom = coverTop; } Debug.WriteLine("Rebar cover types id, top: " + coverTop.Id.IntegerValue + ", bottom: " + coverBottom.Id.IntegerValue); #if R2017 || R2018 || R2019 || R2020 || R2021 double diam = mrt.bartype.BarDiameter; #else double diam = mrt.bartype.BarNominalDiameter; #endif double topCoverDir1 = topCoverUser - coverTop.CoverDistance; double topCoverDir2 = topCoverDir1 + diam; if (rif.turnTopBars) { topCoverDir1 += diam; topCoverDir2 -= diam; } double bottomCoverDir1 = bottomCoverUser - coverBottom.CoverDistance; double bottomCoverDir2 = bottomCoverDir1 + diam; if (rif.turnBottomBars) { bottomCoverDir1 += diam; bottomCoverDir2 -= diam; } List <Curve> curves = SupportGeometry.GetFloorOuterBoundary(floor); Debug.WriteLine("Boundary curves count: " + curves.Count); XYZ direction = new XYZ(1, 0, 0); if (rif.useDirection) { double angle = floor.SpanDirectionAngle; Transform rotateTransform = Transform.CreateRotationAtPoint(new XYZ(0, 0, 1), angle, new XYZ(0, 0, 0)); Line horizontal = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(1, 0, 0)); Curve rotatedCurve = horizontal.CreateTransformed(rotateTransform); direction = rotatedCurve.GetEndPoint(1); } Debug.WriteLine("Direction: " + direction.ToString()); AreaReinforcement arTopX = AreaReinforcement .Create(doc, floor, curves, direction, areaTypeId, mrt.bartype.Id, ElementId.InvalidElementId); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_1_GENERIC).Set(1); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_2_GENERIC).Set(0); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_1_GENERIC).Set(0); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_2_GENERIC).Set(0); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_TOP_DIR_1_GENERIC).Set(interval); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ADDL_TOP_OFFSET).Set(topCoverDir1); arTopX.get_Parameter(BuiltInParameter.NUMBER_PARTITION_PARAM).Set("верх X фон"); Debug.WriteLine("Top X is created"); AreaReinforcement arTopY = AreaReinforcement .Create(doc, floor, curves, direction, areaTypeId, mrt.bartype.Id, ElementId.InvalidElementId); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_1_GENERIC).Set(0); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_2_GENERIC).Set(1); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_1_GENERIC).Set(0); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_2_GENERIC).Set(0); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_TOP_DIR_2_GENERIC).Set(interval); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ADDL_TOP_OFFSET).Set(topCoverDir2); arTopY.get_Parameter(BuiltInParameter.NUMBER_PARTITION_PARAM).Set("верх Y фон"); Debug.WriteLine("Top Y is created"); AreaReinforcement arBottomX = AreaReinforcement .Create(doc, floor, curves, direction, areaTypeId, mrt.bartype.Id, ElementId.InvalidElementId); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_1_GENERIC).Set(0); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_2_GENERIC).Set(0); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_1_GENERIC).Set(1); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_2_GENERIC).Set(0); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_BOTTOM_DIR_1_GENERIC).Set(interval); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ADDL_BOTTOM_OFFSET).Set(bottomCoverDir1); arBottomX.get_Parameter(BuiltInParameter.NUMBER_PARTITION_PARAM).Set("низ X фон"); Debug.WriteLine("Bottom X is created"); AreaReinforcement arBottomY = AreaReinforcement .Create(doc, floor, curves, direction, areaTypeId, mrt.bartype.Id, ElementId.InvalidElementId); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_1_GENERIC).Set(0); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_2_GENERIC).Set(0); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_1_GENERIC).Set(0); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_2_GENERIC).Set(1); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_BOTTOM_DIR_2_GENERIC).Set(interval); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ADDL_BOTTOM_OFFSET).Set(bottomCoverDir2); arBottomY.get_Parameter(BuiltInParameter.NUMBER_PARTITION_PARAM).Set("низ Y фон"); Debug.WriteLine("Bottom Y is created"); return(messages); }
public static List <string> GenerateRebar(Document doc, Wall wall, RebarInfoWall wri, RebarCoverType zeroCover, ElementId areaTypeId) { Debug.WriteLine("Start reinforcement for wall: " + wall.Id.IntegerValue.ToString()); List <string> messages = new List <string>(); double lengthRound = 5 / 304.8; ProjectInfo pi = doc.ProjectInformation; Parameter roundLengthParam = pi.LookupParameter("Арм.ОкруглениеДлины"); if (roundLengthParam != null && roundLengthParam.HasValue) { lengthRound = roundLengthParam.AsDouble(); } wall.get_Parameter(BuiltInParameter.CLEAR_COVER_OTHER).Set(zeroCover.Id); Debug.WriteLine("Set zero rebar cover for other faces"); Solid sol = SupportGeometry.GetSolidFromElement(wall); List <Face> vertFaces = SupportGeometry.GetVerticalFaces(sol); Face mainFace = SupportGeometry.GetLargeFace(vertFaces); PlanarFace pface = mainFace as PlanarFace; Debug.WriteLine("Vertical planar face was found"); List <Curve> wallOutlineDraft = SupportGeometry.GetFaceOuterBoundary(pface); Debug.WriteLine("Outline draft curves found: " + wallOutlineDraft.Count.ToString()); //удаляю совпадающие линии List <Curve> wallOutline = SupportGeometry.CleanLoop(wallOutlineDraft); Debug.WriteLine("Outline clean curves found: " + wallOutline.Count.ToString()); //определяю отступы для защитных слоев RebarCoverType coverFront = doc.GetElement(wall.get_Parameter(BuiltInParameter.CLEAR_COVER_EXTERIOR).AsElementId()) as RebarCoverType; RebarCoverType coverBack = doc.GetElement(wall.get_Parameter(BuiltInParameter.CLEAR_COVER_INTERIOR).AsElementId()) as RebarCoverType; if (coverFront == null) { coverFront = coverBack; } if (coverBack == null) { coverBack = coverFront; } double userDefineCover = wri.rebarCover; MyRebarType verticalRebarType = new MyRebarType(doc, wri.verticalRebarTypeName); if (verticalRebarType.isValid == false) { messages.Add("Не удалось получить тип стержня " + wri.verticalRebarTypeName); Debug.WriteLine("Unable to get vertical rebartype: " + wri.verticalRebarTypeName); } MyRebarType horizontalRebarType = new MyRebarType(doc, wri.horizontalRebarTypeName); if (horizontalRebarType.isValid == false) { messages.Add("Не удалось получить тип стержня " + wri.horizontalRebarTypeName); Debug.WriteLine("Unable to get horizontal rebartype: " + wri.horizontalRebarTypeName); } #if R2017 || R2018 || R2019 || R2020 || R2021 double vertDiam = verticalRebarType.bartype.BarDiameter; double horizDiam = horizontalRebarType.bartype.BarDiameter; #else double vertDiam = verticalRebarType.bartype.BarNominalDiameter; double horizDiam = horizontalRebarType.bartype.BarNominalDiameter; #endif double offsetVerticalExterior = userDefineCover - coverFront.CoverDistance - 0.5 * vertDiam; double offsetVerticalInterior = userDefineCover - coverBack.CoverDistance - 0.5 * vertDiam; double offsetHorizontalExterior = offsetVerticalExterior - horizDiam; double offsetHorizontalInterior = offsetVerticalInterior - horizDiam; if (wri.generateVertical) { Debug.WriteLine("Start creating vertical rebar"); Parameter paramFloorThickinessParam = wall.LookupParameter("Рзм.ТолщинаПерекрытия"); if (wri.autoVerticalFreeLength) { Debug.WriteLine("Try to auto-calculate vertical free length"); if (paramFloorThickinessParam != null && paramFloorThickinessParam.HasValue) { double floorThickness = paramFloorThickinessParam.AsDouble(); double freeLength = ConcreteUtils.getRebarFreeLength(verticalRebarType.bartype, wall, lengthRound); wri.verticalFreeLength = floorThickness + freeLength; Debug.WriteLine("Vertical free length = " + wri.verticalFreeLength); } else { Debug.WriteLine("Unable to auto-calculate vertical free length"); throw new Exception("Не задан параметр Рзм.ТолщинаПерекрытия в элементе " + wall.Id.IntegerValue.ToString()); } } List <Curve> curvesVertical = SupportGeometry.MoveLine(wallOutline, wri.verticalFreeLength, SupportGeometry.LineSide.Top); Debug.WriteLine("Curves for vertical loop: " + curvesVertical.Count.ToString()); if (wri.useUnification) { Debug.WriteLine("Try to unificate vertical length"); double verticalZoneHeight = SupportGeometry.GetZoneHeigth(curvesVertical); double unificateLength = wri.getNearestLength(verticalZoneHeight); double moveToUnificate = unificateLength - verticalZoneHeight; if (moveToUnificate > 0.005) { List <Curve> curvesVerticalUnificate = SupportGeometry.MoveLine(curvesVertical, moveToUnificate, SupportGeometry.LineSide.Top); curvesVertical = curvesVerticalUnificate; } } /*LocationCurve wallLocCurve = wall.Location as LocationCurve; * Line wallCurve = wallLocCurve.Curve as Line; * if (wallCurve == null) throw new Exception("Curved wall!");*/ double sideOffset = wri.backOffset - 0.5 * vertDiam; curvesVertical = SupportGeometry.MoveLine(curvesVertical, sideOffset, SupportGeometry.LineSide.Left); curvesVertical = SupportGeometry.MoveLine(curvesVertical, sideOffset, SupportGeometry.LineSide.Right); CurveUtils.SortCurvesContiguous(doc.Application.Create, curvesVertical, true); Debug.WriteLine("Contiguous curves sort"); if (wri.verticalOffset < 0.0001) { Debug.WriteLine("Generate vertical rebar area without offset"); AreaReinforcement arVertical = Generate(doc, wall, curvesVertical, false, true, true, offsetVerticalInterior, offsetVerticalExterior, wri.verticalRebarInterval, areaTypeId, verticalRebarType.bartype, wri.verticalSectionText); } else { Debug.WriteLine("Generate vertical rebar area with offset"); AreaReinforcement arVertical1 = Generate(doc, wall, curvesVertical, false, true, false, offsetVerticalInterior, offsetVerticalExterior, wri.verticalRebarInterval, areaTypeId, verticalRebarType.bartype, wri.verticalSectionText); List <Curve> curves2 = SupportGeometry.MoveLine(curvesVertical, wri.verticalOffset, SupportGeometry.LineSide.Top); curves2 = SupportGeometry.MoveLine(curves2, wri.verticalOffset, SupportGeometry.LineSide.Bottom); AreaReinforcement arVertical2 = Generate(doc, wall, curves2, false, false, true, offsetVerticalInterior, offsetVerticalExterior, wri.verticalRebarInterval, areaTypeId, verticalRebarType.bartype, wri.verticalSectionText); } } if (wri.generateHorizontal) { Debug.WriteLine("Start creating horizontal rebar"); //определяю контур double horizontalTopOffset = 0.5 * horizDiam - wri.topOffset; double horizintalBottomOffset = wri.bottomOffset - 0.5 * horizDiam; List <Curve> curvesHorizontal = SupportGeometry.MoveLine(wallOutline, horizontalTopOffset, SupportGeometry.LineSide.Top); curvesHorizontal = SupportGeometry.MoveLine(curvesHorizontal, horizintalBottomOffset, SupportGeometry.LineSide.Bottom); double sideOffset = wri.horizontalFreeLength * -1; curvesHorizontal = SupportGeometry.MoveLine(curvesHorizontal, sideOffset, SupportGeometry.LineSide.Left); curvesHorizontal = SupportGeometry.MoveLine(curvesHorizontal, sideOffset, SupportGeometry.LineSide.Right); List <AreaRebarInfo> curvesBase = new List <AreaRebarInfo>(); if (wri.horizontalAddInterval) { Debug.WriteLine("Create with additional offset"); double horizRebarInterval = wri.horizontalRebarInterval; if (wri.horizontalAdditionalStepSpace) { horizRebarInterval = horizRebarInterval / 2; } double heigth = SupportGeometry.GetZoneHeigth(curvesHorizontal); double heigthByAxis = heigth - horizDiam; double countCheckAsDouble1 = heigthByAxis / horizRebarInterval; double countCheckAsDouble2 = Math.Round(countCheckAsDouble1, 2); double countCheckAsDouble3 = Math.Truncate(countCheckAsDouble2); int countCheck = (int)countCheckAsDouble3; double addIntervalByAxis = heigthByAxis - countCheck * horizRebarInterval; if (addIntervalByAxis < horizDiam) //доборный шаг не требуется { Debug.WriteLine("Additional offset not needed"); curvesBase.Add(new AreaRebarInfo(curvesHorizontal, horizRebarInterval)); } else { Debug.WriteLine("Additional offset = " + (addIntervalByAxis * 304.8).ToString("F3")); int count = countCheck - 1; if (addIntervalByAxis < 50 / 304.8) //доборный шаг менее 50мм - увеличиваю отступ сверху { count--; } double heigthClean = count * horizRebarInterval; double offsetMain = heigth - heigthClean - horizDiam; List <Curve> profileMain = SupportGeometry.MoveLine(curvesHorizontal, -offsetMain, SupportGeometry.LineSide.Top); if (wri.horizontalAdditionalStepSpace) { if (wri.horizontalAddStepHeightBottom > 0) { List <List <Curve> > profilesAddBottom = SupportGeometry.CopyTopOrBottomLines(curvesHorizontal, wri.horizontalAddStepHeightBottom, false); foreach (var prof in profilesAddBottom) { curvesBase.Add(new AreaRebarInfo(prof, horizRebarInterval)); } profileMain = SupportGeometry.MoveLine(profileMain, wri.horizontalAddStepHeightBottom, SupportGeometry.LineSide.Bottom); } else if (wri.horizontalAddStepHeightTop > 0) { List <List <Curve> > profilesAddTop = SupportGeometry.CopyTopOrBottomLines(curvesHorizontal, wri.horizontalAddStepHeightTop, true); foreach (var prof in profilesAddTop) { curvesBase.Add(new AreaRebarInfo(prof, horizRebarInterval)); } profileMain = SupportGeometry.MoveLine(profileMain, -wri.horizontalAddStepHeightTop, SupportGeometry.LineSide.Top); } curvesBase.Add(new AreaRebarInfo(profileMain, horizRebarInterval * 2)); } else { curvesBase.Add(new AreaRebarInfo(profileMain, horizRebarInterval)); } double heigthAdd = heigth - heigthClean - horizRebarInterval; List <List <Curve> > profilesAdd = SupportGeometry.CopyTopOrBottomLines(curvesHorizontal, heigthAdd, true); foreach (var prof in profilesAdd) { curvesBase.Add(new AreaRebarInfo(prof, horizRebarInterval)); } } } else { Debug.WriteLine("Create only one zone for horizontal rebars"); curvesBase.Add(new AreaRebarInfo(curvesHorizontal, wri.horizontalRebarInterval)); } Debug.WriteLine("Loops for horizontal rebar: " + curvesBase.Count.ToString()); foreach (var profileInfo in curvesBase) { double interval = profileInfo.interval; List <Curve> curves = profileInfo.curves; AreaReinforcement ar = Generate(doc, wall, curves, true, true, true, offsetHorizontalInterior, offsetHorizontalExterior, interval, areaTypeId, horizontalRebarType.bartype, wri.horizontalSectionText); } } return(messages); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Debug.Listeners.Clear(); Debug.Listeners.Add(new RbsLogger.Logger("WallAreaRebar")); Debug.WriteLine("Wall reinforcement start"); App.ActivateConfigFolder(); Document doc = commandData.Application.ActiveUIDocument.Document; Selection sel = commandData.Application.ActiveUIDocument.Selection; List <Wall> walls = new List <Wall>(); foreach (ElementId id in sel.GetElementIds()) { Element elem = doc.GetElement(id); if (elem is Wall) { walls.Add(elem as Wall); } } if (walls.Count == 0) { message = "Предварительно выберите стены для армирования"; return(Result.Failed); } Debug.WriteLine("Selected walls count: " + walls.Count.ToString()); foreach (Wall w in walls) { Parameter isStructural = w.get_Parameter(BuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT); if (isStructural == null) { continue; } if (isStructural.AsInteger() != 1) { elements.Insert(w); } } if (elements.Size > 0) { message = "Найдены не несущие стены, армирование не может быть выполнено"; Debug.WriteLine("Non-structural walls were found"); return(Result.Failed); } ElementId areaTypeId = SupportDocumentGetter.GetDefaultArea(doc).Id; RebarCoverType zeroCover = SupportDocumentGetter.GetRebarCoverType(doc, 0); List <string> rebarTypes = SupportDocumentGetter.GetRebarTypes(doc); List <string> rebarTypes2 = rebarTypes.ToList(); bool wallsHaveRebarInfo = SupportDocumentGetter.CheckWallsHaveRebarInfo(walls); RebarInfoWall riw = new RebarInfoWall(); //RebarInfoWall.GetDefault(doc); string wallPath = System.IO.Path.Combine(App.localFolder, "wall.xml"); Debug.WriteLine("Try to deserialize xml: " + wallPath); XmlSerializer serializer = new XmlSerializer(typeof(RebarInfoWall)); if (System.IO.File.Exists(wallPath)) { using (System.IO.StreamReader reader = new System.IO.StreamReader(wallPath)) { try { riw = (RebarInfoWall)serializer.Deserialize(reader); } catch { Debug.WriteLine("Deserialize fault!"); } } } if (wallsHaveRebarInfo) { //TaskDialog.Show("Внимание!", "Армирование будет выполнено по данным, указанным в стенах, без вывода диалогового окна."); Debug.WriteLine("DialogWindow for auto-reinforcement"); DialogWindowWallAuto dialogWallAuto = new DialogWindowWallAuto(riw); dialogWallAuto.ShowDialog(); if (dialogWallAuto.DialogResult != System.Windows.Forms.DialogResult.OK) { return(Result.Cancelled); } riw = dialogWallAuto.rebarInfo; Debug.WriteLine("RebarInfo created"); } else { Debug.WriteLine("Dialog window for manual-reinforcement"); DialogWindowWall form = new DialogWindowWall(riw, rebarTypes, rebarTypes2); form.ShowDialog(); if (form.DialogResult != System.Windows.Forms.DialogResult.OK) { return(Result.Cancelled); } } Debug.Write("Delete xml file and rewrite: " + wallPath); if (File.Exists(wallPath)) { File.Delete(wallPath); } using (FileStream writer = new FileStream(wallPath, FileMode.OpenOrCreate)) { serializer.Serialize(writer, riw); } Debug.WriteLine("... Success!"); using (Transaction t = new Transaction(doc)) { t.Start("Армирование стен"); Debug.WriteLine("Start transaction"); foreach (Wall wall in walls) { if (wallsHaveRebarInfo) { Debug.WriteLine("Start auto-reinforcement"); RebarInfoWall newRiw = new RebarInfoWall(doc, wall); newRiw.topOffset = riw.topOffset; newRiw.bottomOffset = riw.bottomOffset; newRiw.horizontalAddInterval = riw.horizontalAddInterval; newRiw.horizontalAdditionalStepSpace = riw.horizontalAdditionalStepSpace; newRiw.verticalSectionText = riw.verticalSectionText; newRiw.horizontalSectionText = riw.horizontalSectionText; newRiw.verticalOffset = riw.verticalOffset; newRiw.useUnification = riw.useUnification; newRiw.lengthsUnification = riw.lengthsUnification; newRiw.autoVerticalFreeLength = riw.autoVerticalFreeLength; RebarWorkerWall.GenerateRebar(doc, wall, newRiw, zeroCover, areaTypeId); } else { Debug.WriteLine("Start manual reinforcement"); RebarWorkerWall.GenerateRebar(doc, wall, riw, zeroCover, areaTypeId); } } t.Commit(); Debug.WriteLine("Finish transaction"); } return(Result.Succeeded); }