def editStraightRebar( Rebar, f_cover, coverAlong, rt_cover, lb_cover, diameter, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None, ): sketch = Rebar.Base if structure and facename: sketch.Support = [(structure, facename)] FreeCAD.ActiveDocument.recompute() # Check if sketch support is empty. if not sketch.Support: showWarning( "You have checked: 'Remove external geometry of base sketches when " "needed.'\nTo uncheck: Edit->Preferences->Arch.") return # Assigned values facename = sketch.Support[0][1][0] structure = sketch.Support[0][0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] # StructurePRM = getTrueParametersOfStructure(structure) # Get parameters of the face where sketch of rebar is drawn FacePRM = getParametersOfFace(structure, facename) # Get points of Straight rebar points = getpointsOfStraightRebar( FacePRM, rt_cover, lb_cover, coverAlong, orientation, diameter, facenormalDirection(structure, facename), ) sketch.movePoint(0, 1, points[0], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(0, 2, points[1], 0) FreeCAD.ActiveDocument.recompute() Rebar.OffsetStart = f_cover + diameter / 2 Rebar.OffsetEnd = f_cover + diameter / 2 if amount_spacing_check: Rebar.Amount = amount_spacing_value FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = True else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length Rebar.Amount = get_rebar_amount_from_spacing(size, diameter, amount_spacing_value) FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = False Rebar.FrontCover = f_cover Rebar.RightTopCover = rt_cover Rebar.LeftBottomCover = lb_cover Rebar.CoverAlong = coverAlong[0] Rebar.Cover = coverAlong[1] Rebar.TrueSpacing = amount_spacing_value Rebar.Diameter = diameter Rebar.Orientation = orientation FreeCAD.ActiveDocument.recompute() return Rebar
def makeStraightRebar( f_cover, coverAlong, rt_cover, lb_cover, diameter, amount_spacing_check, amount_spacing_value, orientation="Horizontal", structure=None, facename=None, ): """Adds the straight reinforcement bar to the selected structural object. Case I: When orientation of straight rebar is 'Horizontal': makeStraightRebar(FrontCover, CoverAlong, RightCover, LeftCover, Diameter, AmountSpacingCheck, AmountSpacingValue, Orientation = "Horizontal", Structure, Facename) Note: Type of CoverAlong argument is a tuple. Syntax: (<Along>, <Value>). Here we have horizontal orientation so we can pass Top Side and Bottom Side to <Along> arguments. For eg. ("Top Side", 20) and ("Bottom Side", 20) Case II: When orientation of straight rebar is 'Vertical': makeStraightRebar(FrontCover, CoverAlong, TopCover, BottomCover, Diameter, AmountSpacingCheck, AmountSpacingValue, Orientation = "Horizontal", Structure, Facename) Note: Type of CoverAlong argument is a tuple. Syntax: (<Along>, <Value>). Here we have vertical orientation so we can pass Left Side and Right Side to <Along> arguments. For eg. ("Left Side", 20) and ("Right Side", 20) """ if not structure and not facename: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] structure = selected_obj.Object facename = selected_obj.SubElementNames[0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] # StructurePRM = getTrueParametersOfStructure(structure) FacePRM = getParametersOfFace(structure, facename) if not FacePRM: FreeCAD.Console.PrintError( "Cannot identify shape or from which base object structural " "element is derived\n") return # Get points of Straight rebar points = getpointsOfStraightRebar( FacePRM, rt_cover, lb_cover, coverAlong, orientation, diameter, facenormalDirection(structure, facename), ) import Part import Arch sketch = FreeCAD.activeDocument().addObject("Sketcher::SketchObject", "Sketch") sketch.MapMode = "FlatFace" sketch.Support = [(structure, facename)] FreeCAD.ActiveDocument.recompute() sketch.addGeometry(Part.LineSegment(points[0], points[1]), False) if amount_spacing_check: rebar = Arch.makeRebar( structure, sketch, diameter, amount_spacing_value, f_cover + diameter / 2, name="StraightRebar", ) FreeCAD.ActiveDocument.recompute() else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length rebar = Arch.makeRebar( structure, sketch, diameter, get_rebar_amount_from_spacing(size, diameter, amount_spacing_value), f_cover + diameter / 2, name="StraightRebar", ) # Adds properties to the rebar object rebar.addProperty( "App::PropertyEnumeration", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"), ).RebarShape = RebarTypes.tolist() rebar.RebarShape = "StraightRebar" rebar.setEditorMode("RebarShape", 2) rebar.addProperty( "App::PropertyDistance", "FrontCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar"), ).FrontCover = f_cover rebar.setEditorMode("FrontCover", 2) rebar.addProperty( "App::PropertyDistance", "RightTopCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Right/Top Side cover of rebar"), ).RightTopCover = rt_cover rebar.setEditorMode("RightTopCover", 2) rebar.addProperty( "App::PropertyDistance", "LeftBottomCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Left/Bottom Side cover of rebar"), ).LeftBottomCover = lb_cover rebar.setEditorMode("LeftBottomCover", 2) rebar.addProperty( "App::PropertyString", "CoverAlong", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Cover along"), ).CoverAlong = coverAlong[0] rebar.setEditorMode("CoverAlong", 2) rebar.addProperty( "App::PropertyDistance", "Cover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Cover of rebar along user selected side"), ).Cover = coverAlong[1] rebar.setEditorMode("Cover", 2) rebar.addProperty( "App::PropertyBool", "AmountCheck", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked"), ) rebar.setEditorMode("AmountCheck", 2) rebar.addProperty( "App::PropertyDistance", "TrueSpacing", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars"), ).TrueSpacing = amount_spacing_value rebar.setEditorMode("TrueSpacing", 2) rebar.addProperty( "App::PropertyString", "Orientation", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"), ).Orientation = orientation rebar.setEditorMode("Orientation", 2) if amount_spacing_check: rebar.AmountCheck = True else: rebar.AmountCheck = False rebar.TrueSpacing = amount_spacing_value FreeCAD.ActiveDocument.recompute() return rebar
def makeBentShapeRebar( f_cover, b_cover, l_cover, r_cover, diameter, t_cover, bentLength, bentAngle, rounding, amount_spacing_check, amount_spacing_value, orientation="Bottom Left", structure=None, facename=None, ): """makeBentShapeRebar(FrontCover, BottomCover, LeftCover, RightCover, Diameter, TopCover, BentLength, BentAngle, Rounding, AmountSpacingCheck, AmountSpacingValue, Orientation, Structure, Facename): Adds the Bent-Shape reinforcement bar to the selected structural object. It takes four different orientations input i.e. 'Bottom', 'Top', 'Left', 'Right'. """ if not structure and not facename: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] structure = selected_obj.Object facename = selected_obj.SubElementNames[0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] # StructurePRM = getTrueParametersOfStructure(structure) FacePRM = getParametersOfFace(structure, facename) if not FacePRM: FreeCAD.Console.PrintError( "Cannot identify shape or from which base object structural " "element is derived\n") return # Get points of L-Shape rebar points = getpointsOfBentShapeRebar( FacePRM, l_cover, r_cover, b_cover, t_cover, bentLength, bentAngle, orientation, diameter, facenormalDirection(structure, facename), ) import Part import Arch sketch = FreeCAD.activeDocument().addObject("Sketcher::SketchObject", "Sketch") sketch.MapMode = "FlatFace" sketch.Support = [(structure, facename)] FreeCAD.ActiveDocument.recompute() sketch.addGeometry(Part.LineSegment(points[0], points[1]), False) sketch.addGeometry(Part.LineSegment(points[1], points[2]), False) sketch.addGeometry(Part.LineSegment(points[2], points[3]), False) sketch.addGeometry(Part.LineSegment(points[3], points[4]), False) sketch.addGeometry(Part.LineSegment(points[4], points[5]), False) if amount_spacing_check: rebar = Arch.makeRebar( structure, sketch, diameter, amount_spacing_value, f_cover + diameter / 2, name="BentShapeRebar", ) FreeCAD.ActiveDocument.recompute() else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length rebar = Arch.makeRebar( structure, sketch, diameter, get_rebar_amount_from_spacing(size, diameter, amount_spacing_value), f_cover + diameter / 2, name="BentShapeRebar", ) rebar.Rounding = rounding # Adds properties to the rebar object rebar.addProperty( "App::PropertyEnumeration", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"), ).RebarShape = RebarTypes.tolist() rebar.RebarShape = "BentShapeRebar" rebar.setEditorMode("RebarShape", 2) rebar.addProperty( "App::PropertyDistance", "FrontCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar"), ).FrontCover = f_cover rebar.setEditorMode("FrontCover", 2) rebar.addProperty( "App::PropertyDistance", "LeftCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Left Side cover of rebar"), ).LeftCover = l_cover rebar.setEditorMode("LeftCover", 2) rebar.addProperty( "App::PropertyDistance", "RightCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Right Side cover of rebar"), ).RightCover = r_cover rebar.setEditorMode("RightCover", 2) rebar.addProperty( "App::PropertyDistance", "BottomCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bottom cover of rebar"), ).BottomCover = b_cover rebar.setEditorMode("BottomCover", 2) rebar.addProperty( "App::PropertyBool", "AmountCheck", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked"), ) rebar.setEditorMode("AmountCheck", 2) rebar.addProperty( "App::PropertyDistance", "TopCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar"), ).TopCover = t_cover rebar.setEditorMode("TopCover", 2) rebar.addProperty( "App::PropertyDistance", "TrueSpacing", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars"), ).TrueSpacing = amount_spacing_value rebar.addProperty( "App::PropertyString", "Orientation", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"), ).Orientation = orientation rebar.setEditorMode("Orientation", 2) rebar.setEditorMode("TrueSpacing", 2) rebar.addProperty( "App::PropertyDistance", "BentLength", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "BentLength cover of rebar"), ).BentLength = bentLength rebar.setEditorMode("BentLength", 2) rebar.addProperty( "App::PropertyDistance", "BentAngle", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bent Angle of rebar"), ).BentAngle = bentAngle rebar.setEditorMode("BentAngle", 2) if amount_spacing_check: rebar.AmountCheck = True else: rebar.AmountCheck = False rebar.TrueSpacing = amount_spacing_value FreeCAD.ActiveDocument.recompute() return rebar
def editStirrup( Rebar, l_cover, r_cover, t_cover, b_cover, f_cover, bentAngle, bentFactor, diameter, rounding, amount_spacing_check, amount_spacing_value, structure=None, facename=None, ): sketch = Rebar.Base if structure and facename: sketch.Support = [(structure, facename)] # Check if sketch support is empty. if not sketch.Support: showWarning( "You have checked: 'Remove external geometry of base sketches when " "needed.'\nTo uncheck: Edit->Preferences->Arch.") return # Assigned values facename = sketch.Support[0][1][0] structure = sketch.Support[0][0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] # StructurePRM = getTrueParametersOfStructure(structure) # Get parameters of the face where sketch of rebar is drawn FacePRM = getParametersOfFace(structure, facename, False) FaceNormal = face.normalAt(0, 0) # FaceNormal = face.Placement.Rotation.inverted().multVec(FaceNormal) # Calculate the coordinates value of Stirrup rebar points = getpointsOfStirrup( FacePRM, l_cover, r_cover, t_cover, b_cover, bentAngle, bentFactor, diameter, rounding, FaceNormal, ) Rebar.Base.Points = points FreeCAD.ActiveDocument.recompute() Rebar.Direction = FaceNormal.negative() Rebar.OffsetStart = f_cover + diameter / 2 Rebar.OffsetEnd = f_cover + diameter / 2 Rebar.BentAngle = bentAngle Rebar.BentFactor = bentFactor Rebar.Rounding = rounding Rebar.Diameter = diameter if amount_spacing_check: Rebar.Amount = amount_spacing_value FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = True else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length Rebar.Amount = get_rebar_amount_from_spacing(size, diameter, amount_spacing_value) FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = False Rebar.FrontCover = f_cover Rebar.LeftCover = l_cover Rebar.RightCover = r_cover Rebar.TopCover = t_cover Rebar.BottomCover = b_cover Rebar.TrueSpacing = amount_spacing_value FreeCAD.ActiveDocument.recompute() return Rebar
def makeStirrup( l_cover, r_cover, t_cover, b_cover, f_cover, bentAngle, bentFactor, diameter, rounding, amount_spacing_check, amount_spacing_value, structure=None, facename=None, ): """makeStirrup(LeftCover, RightCover, TopCover, BottomCover, FrontCover, BentAngle, BentFactor, Diameter, Rounding, AmountSpacingCheck, AmountSpacingValue, Structure, Facename): Adds the Stirrup reinforcement bar to the selected structural object.""" if not structure and not facename: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] structure = selected_obj.Object facename = selected_obj.SubElementNames[0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] # StructurePRM = getTrueParametersOfStructure(structure) FacePRM = getParametersOfFace(structure, facename, False) FaceNormal = face.normalAt(0, 0) # FaceNormal = face.Placement.Rotation.inverted().multVec(FaceNormal) if not FacePRM: FreeCAD.Console.PrintError( "Cannot identify shape or from which base object structural " "element is derived\n") return # Calculate the coordinate values of Stirrup points = getpointsOfStirrup( FacePRM, l_cover, r_cover, t_cover, b_cover, bentAngle, bentFactor, diameter, rounding, FaceNormal, ) import Draft line = Draft.makeWire(points, closed=False, face=True, support=None) import Arch line.Support = [(structure, facename)] if amount_spacing_check: rebar = Arch.makeRebar( structure, line, diameter, amount_spacing_value, f_cover + diameter / 2, name="Stirrup", ) else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length rebar = Arch.makeRebar( structure, line, diameter, get_rebar_amount_from_spacing(size, diameter, amount_spacing_value), f_cover + diameter / 2, name="Stirrup", ) rebar.Direction = FaceNormal.negative() rebar.Rounding = rounding # Adds properties to the rebar object rebar.addProperty( "App::PropertyEnumeration", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"), ).RebarShape = RebarTypes.tolist() rebar.RebarShape = "Stirrup" rebar.setEditorMode("RebarShape", 2) rebar.addProperty( "App::PropertyDistance", "LeftCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Left Side cover of rebar"), ).LeftCover = l_cover rebar.setEditorMode("LeftCover", 2) rebar.addProperty( "App::PropertyDistance", "RightCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Right Side cover of rebar"), ).RightCover = r_cover rebar.setEditorMode("RightCover", 2) rebar.addProperty( "App::PropertyDistance", "TopCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Top Side cover of rebar"), ).TopCover = t_cover rebar.setEditorMode("TopCover", 2) rebar.addProperty( "App::PropertyDistance", "BottomCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bottom Side cover of rebar"), ).BottomCover = b_cover rebar.setEditorMode("BottomCover", 2) rebar.addProperty( "App::PropertyDistance", "FrontCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar"), ).FrontCover = f_cover rebar.setEditorMode("FrontCover", 2) rebar.addProperty( "App::PropertyInteger", "BentAngle", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bent angle between at the end of rebar"), ).BentAngle = bentAngle rebar.setEditorMode("BentAngle", 2) rebar.addProperty( "App::PropertyInteger", "BentFactor", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bent Length is the equal to BentFactor * Diameter"), ).BentFactor = bentFactor rebar.setEditorMode("BentFactor", 2) rebar.addProperty( "App::PropertyBool", "AmountCheck", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked"), ) rebar.setEditorMode("AmountCheck", 2) rebar.addProperty( "App::PropertyDistance", "TrueSpacing", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars"), ).TrueSpacing = amount_spacing_value rebar.setEditorMode("TrueSpacing", 2) if amount_spacing_check: rebar.AmountCheck = True else: rebar.AmountCheck = False rebar.TrueSpacing = amount_spacing_value FreeCAD.ActiveDocument.recompute() return rebar
def editLShapeRebar( Rebar, f_cover, b_cover, l_cover, r_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None, ): sketch = Rebar.Base if structure and facename: sketch.Support = [(structure, facename)] # Check if sketch support is empty. if not sketch.Support: showWarning( "You have checked: 'Remove external geometry of base sketches when " "needed.'\nTo uncheck: Edit->Preferences->Arch.") return # Recompute sketch to resolve issue as discussed here: # https://forum.freecadweb.org/viewtopic.php?f=3&t=6989#p335986 sketch.recompute() # Assigned values facename = sketch.Support[0][1][0] structure = sketch.Support[0][0] face = structure.Shape.Faces[getFaceNumber(facename) - 1] # StructurePRM = getTrueParametersOfStructure(structure) # Get parameters of the face where sketch of rebar is drawn FacePRM = getParametersOfFace(structure, facename) # Get points of L-Shape rebar points = getpointsOfLShapeRebar( FacePRM, l_cover, r_cover, b_cover, t_cover, orientation, diameter, facenormalDirection(structure, facename), ) sketch.movePoint(0, 1, points[0], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(0, 2, points[1], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(1, 1, points[1], 0) FreeCAD.ActiveDocument.recompute() sketch.movePoint(1, 2, points[2], 0) FreeCAD.ActiveDocument.recompute() Rebar.OffsetStart = f_cover + diameter / 2 Rebar.OffsetEnd = f_cover + diameter / 2 if amount_spacing_check: Rebar.Amount = amount_spacing_value FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = True else: size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length Rebar.Amount = get_rebar_amount_from_spacing(size, diameter, amount_spacing_value) FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = False Rebar.Diameter = diameter Rebar.FrontCover = f_cover Rebar.LeftCover = l_cover Rebar.RightCover = r_cover Rebar.BottomCover = b_cover Rebar.TopCover = t_cover Rebar.Rounding = rounding Rebar.TrueSpacing = amount_spacing_value Rebar.Orientation = orientation FreeCAD.ActiveDocument.recompute() return Rebar