def editXDirRebars( xdir_rebars_list, l_cover_of_tie, r_cover_of_tie, t_cover_of_tie, b_cover_of_tie, dia_of_tie, dia_of_main_rebars, xdir_rebars_t_offset, xdir_rebars_b_offset, xdir_rebars_type, xdir_hook_orientation, xdir_hook_extension, l_xdir_rebar_rounding, xdir_rebars_number_diameter, facename, structure, ): # Find parameters of selected face FacePRM = getParametersOfFace(structure, facename) facename_for_xdir_rebars = getFacenameforRebar( "y-axis", facename, structure ) # find list of tuples of number and diameter of xdir rebars xdir_rebars_number_diameter_list = gettupleOfNumberDiameter( xdir_rebars_number_diameter ) xdir_rebars_number_diameter_list.reverse() # Calculate spacing between xdir-rebars xdir_span_length = ( FacePRM[0][0] - l_cover_of_tie - r_cover_of_tie - 2 * dia_of_tie - 2 * dia_of_main_rebars ) req_space_for_xdir_rebars = sum( x[0] * x[1] for x in xdir_rebars_number_diameter_list ) xdir_rebars_number = sum( number for number, _ in xdir_rebars_number_diameter_list ) spacing_in_xdir_rebars = (xdir_span_length - req_space_for_xdir_rebars) / ( xdir_rebars_number + 1 ) # Set parameter values for Straight/LShape xdir_rebars list_coverAlong = ["Right Side", "Left Side"] if xdir_rebars_type == "StraightRebar": r_cover = t_cover_of_tie + dia_of_tie l_cover = b_cover_of_tie + dia_of_tie rl_cover = [r_cover, l_cover] index = 0 for i, coverAlong in enumerate(list_coverAlong): for j, (number, dia) in enumerate(xdir_rebars_number_diameter_list): if j == 0: f_cover_of_xdir_rebars = ( r_cover_of_tie + dia_of_tie + dia_of_main_rebars + spacing_in_xdir_rebars ) rear_cover_of_xdir_rebars = ( FacePRM[0][0] - f_cover_of_xdir_rebars - number * dia - (number - 1) * spacing_in_xdir_rebars ) editStraightRebar( xdir_rebars_list[index], f_cover_of_xdir_rebars, (coverAlong, rl_cover[i]), xdir_rebars_t_offset, xdir_rebars_b_offset, dia, True, number, "Vertical", structure, facename_for_xdir_rebars, ) xdir_rebars_list[index].OffsetEnd = ( rear_cover_of_xdir_rebars + dia / 2 ) f_cover_of_xdir_rebars += ( number * dia + number * spacing_in_xdir_rebars ) index += 1 elif xdir_rebars_type == "LShapeRebar": face_length = getParametersOfFace(structure, facename_for_xdir_rebars)[ 0 ][0] l_rebar_orientation_cover_list = [] for i, (number, dia_of_rebars) in enumerate( xdir_rebars_number_diameter_list ): l_rebar_orientation_cover_list.append( getLRebarOrientationLeftRightCover( xdir_hook_orientation, xdir_hook_extension, "y-axis", l_cover_of_tie, r_cover_of_tie, t_cover_of_tie, b_cover_of_tie, dia_of_tie, dia_of_rebars, l_xdir_rebar_rounding, face_length, ) ) list_orientation = l_rebar_orientation_cover_list[0]["list_orientation"] l_cover_list = [] for l_rebar_orientation_cover in l_rebar_orientation_cover_list: l_cover_list.append(l_rebar_orientation_cover["l_cover"]) r_cover_list = [] for l_rebar_orientation_cover in l_rebar_orientation_cover_list: r_cover_list.append(l_rebar_orientation_cover["r_cover"]) index = 0 for i, orientation in enumerate(list_orientation): for j, (number, dia) in enumerate(xdir_rebars_number_diameter_list): if j == 0: f_cover_of_xdir_rebars = ( r_cover_of_tie + dia_of_tie + dia_of_main_rebars + spacing_in_xdir_rebars ) rear_cover_of_xdir_rebars = ( FacePRM[0][0] - f_cover_of_xdir_rebars - number * dia - (number - 1) * spacing_in_xdir_rebars ) editLShapeRebar( xdir_rebars_list[index], f_cover_of_xdir_rebars, xdir_rebars_b_offset, l_cover_list[j][i], r_cover_list[j][i], dia, xdir_rebars_t_offset, l_xdir_rebar_rounding, True, number, orientation, structure, facename_for_xdir_rebars, ) xdir_rebars_list[index].OffsetEnd = ( rear_cover_of_xdir_rebars + dia / 2 ) f_cover_of_xdir_rebars += ( number * dia + number * spacing_in_xdir_rebars ) index += 1 FreeCAD.ActiveDocument.recompute()
def makeYDirRebars( l_cover_of_tie, r_cover_of_tie, t_cover_of_tie, b_cover_of_tie, dia_of_tie, dia_of_main_rebars, ydir_rebars_t_offset, ydir_rebars_b_offset, ydir_rebars_type, ydir_hook_orientation, ydir_hook_extension, l_ydir_rebar_rounding, ydir_rebars_number_diameter, facename, structure, ): """Adds the rebars along y-direction to the structural column object.""" ydir_rebars = [] facename_for_ydir_rebars = getFacenameforRebar( "x-axis", facename, structure ) # Find parameters of selected face FacePRM = getParametersOfFace(structure, facename) # find list of tuples of number and diameter of ydir rebars ydir_rebars_number_diameter_list = gettupleOfNumberDiameter( ydir_rebars_number_diameter ) # Calculate spacing between ydir-rebars ydir_span_length = ( FacePRM[0][1] - t_cover_of_tie - b_cover_of_tie - 2 * dia_of_tie - 2 * dia_of_main_rebars ) req_space_for_ydir_rebars = sum( x[0] * x[1] for x in ydir_rebars_number_diameter_list ) ydir_rebars_number = sum( number for number, _ in ydir_rebars_number_diameter_list ) spacing_in_ydir_rebars = (ydir_span_length - req_space_for_ydir_rebars) / ( ydir_rebars_number + 1 ) # Set parameter values for Straight/LShape ydir_rebars list_coverAlong = ["Right Side", "Left Side"] if ydir_rebars_type == "StraightRebar": # Set parameter values for Straight ydir_rebars r_cover = r_cover_of_tie + dia_of_tie l_cover = l_cover_of_tie + dia_of_tie rl_cover = [r_cover, l_cover] # Create Straight rebars along y-direction for i, coverAlong in enumerate(list_coverAlong): for j, (number, dia) in enumerate(ydir_rebars_number_diameter_list): if j == 0: f_cover_of_ydir_rebars = ( b_cover_of_tie + dia_of_tie + dia_of_main_rebars + spacing_in_ydir_rebars ) rear_cover_of_ydir_rebars = ( FacePRM[0][1] - f_cover_of_ydir_rebars - number * dia - (number - 1) * spacing_in_ydir_rebars ) ydir_rebars.append( makeStraightRebar( f_cover_of_ydir_rebars, (coverAlong, rl_cover[i]), ydir_rebars_t_offset, ydir_rebars_b_offset, dia, True, number, "Vertical", structure, facename_for_ydir_rebars, ) ) ydir_rebars[-1].OffsetEnd = rear_cover_of_ydir_rebars + dia / 2 f_cover_of_ydir_rebars += ( number * dia + number * spacing_in_ydir_rebars ) elif ydir_rebars_type == "LShapeRebar": face_length = getParametersOfFace(structure, facename_for_ydir_rebars)[ 0 ][0] l_rebar_orientation_cover_list = [] for i, (number, dia_of_rebars) in enumerate( ydir_rebars_number_diameter_list ): l_rebar_orientation_cover_list.append( getLRebarOrientationLeftRightCover( ydir_hook_orientation, ydir_hook_extension, "x-axis", l_cover_of_tie, r_cover_of_tie, t_cover_of_tie, b_cover_of_tie, dia_of_tie, dia_of_rebars, l_ydir_rebar_rounding, face_length, ) ) list_orientation = l_rebar_orientation_cover_list[0]["list_orientation"] l_cover_list = [] for l_rebar_orientation_cover in l_rebar_orientation_cover_list: l_cover_list.append(l_rebar_orientation_cover["l_cover"]) r_cover_list = [] for l_rebar_orientation_cover in l_rebar_orientation_cover_list: r_cover_list.append(l_rebar_orientation_cover["r_cover"]) # Create LShape rebars along y-direction for i, orientation in enumerate(list_orientation): for j, (number, dia) in enumerate(ydir_rebars_number_diameter_list): if j == 0: f_cover_of_ydir_rebars = ( r_cover_of_tie + dia_of_tie + dia_of_main_rebars + spacing_in_ydir_rebars ) rear_cover_of_ydir_rebars = ( FacePRM[0][1] - f_cover_of_ydir_rebars - number * dia - (number - 1) * spacing_in_ydir_rebars ) ydir_rebars.append( makeLShapeRebar( f_cover_of_ydir_rebars, ydir_rebars_b_offset, l_cover_list[j][i], r_cover_list[j][i], dia, ydir_rebars_t_offset, l_ydir_rebar_rounding, True, number, orientation, structure, facename_for_ydir_rebars, ) ) ydir_rebars[-1].OffsetEnd = rear_cover_of_ydir_rebars + dia / 2 f_cover_of_ydir_rebars += ( number * dia + number * spacing_in_ydir_rebars ) FreeCAD.ActiveDocument.recompute() return ydir_rebars
def makeSingleTieFourRebars( l_cover_of_tie, r_cover_of_tie, t_cover_of_tie, b_cover_of_tie, offset_of_tie, bent_angle, extension_factor, dia_of_tie, number_spacing_check, number_spacing_value, dia_of_rebars, t_offset_of_rebars, b_offset_of_rebars, rebar_type="StraightRebar", hook_orientation="Top Inside", hook_extend_along="x-axis", l_rebar_rounding=None, hook_extension=None, structure=None, facename=None, ): """makeSingleTieFourRebars(LeftCoverOfTie, RightCoverOfTie, TopCoverOfTie, BottomCoverOfTie, OffsetofTie, BentAngle, ExtensionFactor, DiameterOfTie, NumberSpacingCheck, NumberSpacingValue, DiameterOfRebars, TopOffsetOfRebars, BottomOffsetOfRebars, RebarType, LShapeHookOrientation, HookExtendAlong, LShapeRebarRounding, LShapeHookLength, Structure, Facename): Adds the Single Tie Four Rebars reinforcement to the selected structural column object. It takes two different inputs for rebar_type i.e. 'StraightRebar', 'LShapeRebar'. It takes eight different orientations input for L-shaped hooks i.e. 'Top Inside', 'Top Outside', 'Bottom Inside', 'Bottom Outside', 'Top Left', 'Top Right', 'Bottom Left', 'Bottom Right'. It takes two different inputs for hook_extend_along i.e. 'x-axis', 'y-axis'. """ if not structure and not facename: if FreeCAD.GuiUp: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] structure = selected_obj.Object facename = selected_obj.SubElementNames[0] else: showWarning("Error: Pass structure and facename arguments") return None # Calculate common parameters for Straight/LShaped rebars t_cover = t_offset_of_rebars b_cover = b_offset_of_rebars rebar_number_spacing_check = True rebar_number_spacing_value = 2 # Create Straight Rebars if rebar_type == "StraightRebar": hook_extend_along == "x-axis" facename_for_rebars = getFacenameforRebar( hook_extend_along, facename, structure ) f_cover = b_cover_of_tie + dia_of_tie r_cover = r_cover_of_tie + dia_of_tie l_cover = l_cover_of_tie + dia_of_tie orientation = "Vertical" list_coverAlong = ["Right Side", "Left Side"] rl_cover = [r_cover, l_cover] main_rebars = [] for i, coverAlong in enumerate(list_coverAlong): main_rebars.append( makeStraightRebar( f_cover, (coverAlong, rl_cover[i]), t_cover, b_cover, dia_of_rebars, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, ) ) main_rebars[i].OffsetEnd = ( t_cover_of_tie + dia_of_tie + dia_of_rebars / 2 ) # Create L-Shaped Rebars elif rebar_type == "LShapeRebar": facename_for_rebars = getFacenameforRebar( hook_extend_along, facename, structure ) FacePRM = getParametersOfFace(structure, facename_for_rebars) face_length = FacePRM[0][0] if hook_extend_along == "x-axis": f_cover = b_cover_of_tie + dia_of_tie else: f_cover = r_cover_of_tie + dia_of_tie # Implement hook extension values from here: # https://archive.org/details/gov.in.is.sp.16.1980/page/n207 if not hook_extension: hook_extension = 4 * dia_of_rebars if not l_rebar_rounding: l_rebar_rounding = ( float(dia_of_tie) / 2 + dia_of_rebars / 2 ) / dia_of_tie l_rebar_orientation_cover = getLRebarOrientationLeftRightCover( hook_orientation, hook_extension, hook_extend_along, l_cover_of_tie, r_cover_of_tie, t_cover_of_tie, b_cover_of_tie, dia_of_tie, dia_of_rebars, l_rebar_rounding, face_length, ) list_orientation = l_rebar_orientation_cover["list_orientation"] l_cover = l_rebar_orientation_cover["l_cover"] r_cover = l_rebar_orientation_cover["r_cover"] t_cover = t_offset_of_rebars b_cover = b_offset_of_rebars main_rebars = [] for i, orientation in enumerate(list_orientation): main_rebars.append( makeLShapeRebar( f_cover, b_cover, l_cover[i], r_cover[i], dia_of_rebars, t_cover, l_rebar_rounding, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, ) ) if hook_extend_along == "x-axis": main_rebars[i].OffsetEnd = ( t_cover_of_tie + dia_of_tie + dia_of_rebars / 2 ) else: main_rebars[i].OffsetEnd = ( l_cover_of_tie + dia_of_tie + dia_of_rebars / 2 ) # Calculate parameters for Tie rounding = (float(dia_of_tie) / 2 + dia_of_rebars / 2) / dia_of_tie f_cover = offset_of_tie # Create Tie ties = makeStirrup( l_cover_of_tie, r_cover_of_tie, t_cover_of_tie, b_cover_of_tie, f_cover, bent_angle, extension_factor, dia_of_tie, rounding, number_spacing_check, number_spacing_value, structure, facename, ) # Create SingleTieFourRebars group object SingleTieFourRebars = _SingleTieFourRebars() if FreeCAD.GuiUp: _ViewProviderRebarGroup(SingleTieFourRebars.Object.ViewObject) # Add created tie and rebars to SingleTieFourRebars group SingleTieFourRebars.addTies(ties) SingleTieFourRebars.addMainRebars(main_rebars) # Set properties values for ties in Ties group object properties_values = [] properties_values.append(("TiesConfiguration", "SingleTie")) properties_values.append(("LeftCover", l_cover_of_tie)) properties_values.append(("RightCover", r_cover_of_tie)) properties_values.append(("TopCover", t_cover_of_tie)) properties_values.append(("BottomCover", b_cover_of_tie)) setGroupPropertiesValues(properties_values, SingleTieFourRebars.ties_group) # Set properties values for rebars in MainRebars group object properties_values = [] properties_values.append(("RebarType", rebar_type)) properties_values.append(("TopOffset", t_offset_of_rebars)) properties_values.append(("BottomOffset", b_offset_of_rebars)) properties_values.append(("HookOrientation", hook_orientation)) properties_values.append(("HookExtendAlong", hook_extend_along)) if not hook_extension: hook_extension = "0.00 mm" properties_values.append(("HookExtension", hook_extension)) setGroupPropertiesValues( properties_values, SingleTieFourRebars.main_rebars_group ) FreeCAD.ActiveDocument.recompute() return SingleTieFourRebars
def editSingleTieFourRebars( rebar_group, l_cover_of_tie, r_cover_of_tie, t_cover_of_tie, b_cover_of_tie, offset_of_tie, bent_angle, extension_factor, dia_of_tie, number_spacing_check, number_spacing_value, dia_of_rebars, t_offset_of_rebars, b_offset_of_rebars, rebar_type="StraightRebar", hook_orientation="Top Inside", hook_extend_along="x-axis", l_rebar_rounding=None, hook_extension=None, structure=None, facename=None, ): """editSingleTieFourRebars(RebarGroup, LeftCoverOfTie, RightCoverOfTie, TopCoverOfTie, BottomCoverOfTie, OffsetofTie, BentAngle, ExtensionFactor, DiameterOfTie, NumberSpacingCheck, NumberSpacingValue, DiameterOfRebars, TopOffsetofRebars, BottomOffsetofRebars, RebarType, LShapeHookOrientation, HookExtendAlong, LShapeRebarRounding, LShapeHookLength, Structure, Facename): Edit the Single Tie reinforcement for the selected structural column object. It takes two different inputs for rebar_type i.e. 'StraightRebar', 'LShapeRebar'. It takes eight different orientations input for L-shaped hooks i.e. 'Top Inside', 'Top Outside', 'Bottom Inside', 'Bottom Outside', 'Top Left', 'Top Right', 'Bottom Left', 'Bottom Right'. It takes two different inputs for hook_extend_along i.e. 'x-axis', 'y-axis'. """ Tie = rebar_group.RebarGroups[0].Ties[0] prev_rebar_type = ( rebar_group.RebarGroups[1].MainRebars[0].ViewObject.RebarShape ) if not structure and not facename: structure = Tie.Base.Support[0][0] facename = Tie.Base.Support[0][1][0] # Check if main rebar_type changed or not if prev_rebar_type == rebar_type: change_rebar_type = False else: change_rebar_type = True # Edit Tie rounding = (float(dia_of_tie) / 2 + dia_of_rebars / 2) / dia_of_tie f_cover = offset_of_tie ties = editStirrup( Tie, l_cover_of_tie, r_cover_of_tie, t_cover_of_tie, b_cover_of_tie, f_cover, bent_angle, extension_factor, dia_of_tie, rounding, number_spacing_check, number_spacing_value, structure, facename, ) # Calculate common parameters for Straight/LShaped rebars t_cover = t_offset_of_rebars b_cover = b_offset_of_rebars rebar_number_spacing_check = True rebar_number_spacing_value = 2 # Create/Edit Straight Rebars if rebar_type == "StraightRebar": hook_extend_along == "x-axis" facename_for_rebars = getFacenameforRebar( hook_extend_along, facename, structure ) f_cover = b_cover_of_tie + dia_of_tie r_cover = r_cover_of_tie + dia_of_tie l_cover = l_cover_of_tie + dia_of_tie orientation = "Vertical" list_coverAlong = ["Right Side", "Left Side"] rl_cover = [r_cover, l_cover] if change_rebar_type: # Delete previously created LShaped rebars for Rebar in rebar_group.RebarGroups[1].MainRebars[:2]: base_name = Rebar.Base.Name FreeCAD.ActiveDocument.removeObject(Rebar.Name) FreeCAD.ActiveDocument.removeObject(base_name) main_rebars = [] for i, coverAlong in enumerate(list_coverAlong): main_rebars.append( makeStraightRebar( f_cover, (coverAlong, rl_cover[i]), t_cover, b_cover, dia_of_rebars, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, ) ) main_rebars[i].OffsetEnd = ( t_cover_of_tie + dia_of_tie + dia_of_rebars / 2 ) rebar_group.RebarGroups[1].addObjects(main_rebars) else: main_rebars = [] for Rebar in rebar_group.RebarGroups[1].MainRebars[:2]: main_rebars.append(Rebar) for i, coverAlong in enumerate(list_coverAlong): editStraightRebar( main_rebars[i], f_cover, (coverAlong, rl_cover[i]), t_cover, b_cover, dia_of_rebars, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, ) main_rebars[i].OffsetEnd = ( t_cover_of_tie + dia_of_tie + dia_of_rebars / 2 ) # Create L-Shaped Rebars elif rebar_type == "LShapeRebar": facename_for_rebars = getFacenameforRebar( hook_extend_along, facename, structure ) FacePRM = getParametersOfFace(structure, facename_for_rebars) face_length = FacePRM[0][0] if hook_extend_along == "x-axis": f_cover = b_cover_of_tie + dia_of_tie else: f_cover = r_cover_of_tie + dia_of_tie # Implement hook extension values from here: # https://archive.org/details/gov.in.is.sp.16.1980/page/n207 if not hook_extension: hook_extension = 4 * dia_of_rebars if not l_rebar_rounding: l_rebar_rounding = ( float(dia_of_tie) / 2 + dia_of_rebars / 2 ) / dia_of_tie l_rebar_orientation_cover = getLRebarOrientationLeftRightCover( hook_orientation, hook_extension, hook_extend_along, l_cover_of_tie, r_cover_of_tie, t_cover_of_tie, b_cover_of_tie, dia_of_tie, dia_of_rebars, l_rebar_rounding, face_length, ) list_orientation = l_rebar_orientation_cover["list_orientation"] l_cover = l_rebar_orientation_cover["l_cover"] r_cover = l_rebar_orientation_cover["r_cover"] t_cover = t_offset_of_rebars b_cover = b_offset_of_rebars if change_rebar_type: # Delete previously created Straight rebars for Rebar in rebar_group.RebarGroups[1].MainRebars[:2]: base_name = Rebar.Base.Name FreeCAD.ActiveDocument.removeObject(Rebar.Name) FreeCAD.ActiveDocument.removeObject(base_name) main_rebars = [] for i, orientation in enumerate(list_orientation): main_rebars.append( makeLShapeRebar( f_cover, b_cover, l_cover[i], r_cover[i], dia_of_rebars, t_cover, l_rebar_rounding, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, ) ) if hook_extend_along == "x-axis": main_rebars[i].OffsetEnd = ( t_cover_of_tie + dia_of_tie + dia_of_rebars / 2 ) else: main_rebars[i].OffsetEnd = ( l_cover_of_tie + dia_of_tie + dia_of_rebars / 2 ) rebar_group.RebarGroups[1].addObjects(main_rebars) else: main_rebars = [] for Rebar in rebar_group.RebarGroups[1].MainRebars[:2]: main_rebars.append(Rebar) for i, orientation in enumerate(list_orientation): editLShapeRebar( main_rebars[i], f_cover, b_cover, l_cover[i], r_cover[i], dia_of_rebars, t_cover, l_rebar_rounding, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, ) if hook_extend_along == "x-axis": main_rebars[i].OffsetEnd = ( t_cover_of_tie + dia_of_tie + dia_of_rebars / 2 ) else: main_rebars[i].OffsetEnd = ( l_cover_of_tie + dia_of_tie + dia_of_rebars / 2 ) # Set properties values for ties in ties_group object ties_group = rebar_group.RebarGroups[0] ties_group.LeftCover = l_cover_of_tie ties_group.RightCover = r_cover_of_tie ties_group.TopCover = t_cover_of_tie ties_group.BottomCover = b_cover_of_tie # Set properties values for main_rebars in main_rebars_group object main_rebars_group = rebar_group.RebarGroups[1] main_rebars_group.MainRebars = main_rebars main_rebars_group.RebarType = rebar_type main_rebars_group.TopOffset = t_offset_of_rebars main_rebars_group.BottomOffset = b_offset_of_rebars main_rebars_group.HookOrientation = hook_orientation main_rebars_group.HookExtendAlong = hook_extend_along if not hook_extension: hook_extension = "0.00 mm" main_rebars_group.HookExtension = hook_extension FreeCAD.ActiveDocument.recompute() return rebar_group
def editMainRebars( main_rebar_group, l_cover_of_ties, r_cover_of_ties, t_cover_of_ties, b_cover_of_ties, dia_of_ties, dia_of_main_rebars, t_offset_of_rebars, b_offset_of_rebars, main_rebars_type, hook_orientation, hook_extend_along, hook_extension, l_rebar_rounding, structure, facename, ): prev_main_rebars_type = main_rebar_group.RebarType prev_hook_extend_along = main_rebar_group.HookExtendAlong if prev_main_rebars_type == main_rebars_type: recreate_main_rebars = False else: recreate_main_rebars = True main_rebars = [] if recreate_main_rebars: for rebar in main_rebar_group.MainRebars[2:]: base_name = rebar.Base.Name FreeCAD.ActiveDocument.removeObject(rebar.Name) FreeCAD.ActiveDocument.removeObject(base_name) main_rebars = makeMainRebars( l_cover_of_ties, r_cover_of_ties, t_cover_of_ties, b_cover_of_ties, dia_of_ties, dia_of_main_rebars, t_offset_of_rebars, b_offset_of_rebars, main_rebars_type, hook_orientation, hook_extend_along, hook_extension, l_rebar_rounding, structure, facename, ) else: for rebar in main_rebar_group.MainRebars[2:]: main_rebars.append(rebar) # Calculate common parameters for Straight/LShaped rebars t_cover = t_offset_of_rebars b_cover = b_offset_of_rebars rebar_number_spacing_check = True # Edit Straight Rebars if main_rebars_type == "StraightRebar": hook_extend_along = "x-axis" facename_for_rebars = getFacenameforRebar(hook_extend_along, facename, structure) f_cover = b_cover_of_ties + dia_of_ties r_cover = r_cover_of_ties + dia_of_ties orientation = "Vertical" rebar_number_spacing_value = 2 editStraightRebar( main_rebars[-1], f_cover, ("Right Side", r_cover), t_cover, b_cover, dia_of_main_rebars, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, ) main_rebars[-1].OffsetEnd = (t_cover_of_ties + dia_of_ties + dia_of_main_rebars / 2) # Edit L-Shaped Rebars elif main_rebars_type == "LShapeRebar": facename_for_rebars = getFacenameforRebar(hook_extend_along, facename, structure) FacePRM = getParametersOfFace(structure, facename_for_rebars) face_length = FacePRM[0][0] if hook_extend_along == "x-axis": f_cover = b_cover_of_ties + dia_of_ties else: f_cover = r_cover_of_ties + dia_of_ties # Implement hook extension values from here: # https://archive.org/details/gov.in.is.sp.16.1980/page/n207 if not hook_extension: hook_extension = 4 * dia_of_main_rebars if not l_rebar_rounding: l_rebar_rounding = (float(dia_of_ties) / 2 + dia_of_main_rebars / 2) / dia_of_ties l_rebar_orientation_cover = getLRebarOrientationLeftRightCover( hook_orientation, hook_extension, hook_extend_along, l_cover_of_ties, r_cover_of_ties, t_cover_of_ties, b_cover_of_ties, dia_of_ties, dia_of_main_rebars, l_rebar_rounding, face_length, ) list_orientation = l_rebar_orientation_cover["list_orientation"] l_cover = l_rebar_orientation_cover["l_cover"] r_cover = l_rebar_orientation_cover["r_cover"] t_cover = t_offset_of_rebars b_cover = b_offset_of_rebars if hook_extend_along == "x-axis": if prev_hook_extend_along == "y-axis": rebar = main_rebars.pop() base_name = rebar.Base.Name FreeCAD.ActiveDocument.removeObject(rebar.Name) FreeCAD.ActiveDocument.removeObject(base_name) rebar_number_spacing_value = 2 orientation = list_orientation[1] editLShapeRebar( main_rebars[-1], f_cover, b_cover, l_cover[1], r_cover[1], dia_of_main_rebars, t_cover, l_rebar_rounding, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, ) main_rebars[-1].OffsetEnd = (t_cover_of_ties + dia_of_ties + dia_of_main_rebars / 2) elif hook_extend_along == "y-axis": rebar_number_spacing_value = 1 orientation = list_orientation[1] for i, orientation in enumerate(list_orientation): if len(main_rebars) > i: editLShapeRebar( main_rebars[i], f_cover, b_cover, l_cover[i], r_cover[i], dia_of_main_rebars, t_cover, l_rebar_rounding, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, ) else: main_rebars.append( makeLShapeRebar( f_cover, b_cover, l_cover[i], r_cover[i], dia_of_main_rebars, t_cover, l_rebar_rounding, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, )) main_rebars[i].OffsetEnd = (l_cover_of_ties + dia_of_ties + dia_of_main_rebars / 2) FreeCAD.ActiveDocument.recompute() return main_rebars
def makeMainRebars( l_cover_of_ties, r_cover_of_ties, t_cover_of_ties, b_cover_of_ties, dia_of_ties, dia_of_main_rebars, t_offset_of_rebars, b_offset_of_rebars, main_rebars_type, hook_orientation, hook_extend_along, hook_extension, l_rebar_rounding, structure, facename, ): # Calculate common parameters for Straight/LShaped rebars t_cover = t_offset_of_rebars b_cover = b_offset_of_rebars rebar_number_spacing_check = True main_rebars = [] # Create Straight Rebars if main_rebars_type == "StraightRebar": hook_extend_along = "x-axis" facename_for_rebars = getFacenameforRebar(hook_extend_along, facename, structure) f_cover = b_cover_of_ties + dia_of_ties r_cover = r_cover_of_ties + dia_of_ties orientation = "Vertical" rebar_number_spacing_value = 2 main_rebars.append( makeStraightRebar( f_cover, ("Right Side", r_cover), t_cover, b_cover, dia_of_main_rebars, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, )) main_rebars[-1].OffsetEnd = (t_cover_of_ties + dia_of_ties + dia_of_main_rebars / 2) # Create L-Shaped Rebars elif main_rebars_type == "LShapeRebar": facename_for_rebars = getFacenameforRebar(hook_extend_along, facename, structure) FacePRM = getParametersOfFace(structure, facename_for_rebars) face_length = FacePRM[0][0] if hook_extend_along == "x-axis": f_cover = b_cover_of_ties + dia_of_ties else: f_cover = r_cover_of_ties + dia_of_ties # Implement hook extension values from here: # https://archive.org/details/gov.in.is.sp.16.1980/page/n207 if not hook_extension: hook_extension = 4 * dia_of_main_rebars if not l_rebar_rounding: l_rebar_rounding = (float(dia_of_ties) / 2 + dia_of_main_rebars / 2) / dia_of_ties l_rebar_orientation_cover = getLRebarOrientationLeftRightCover( hook_orientation, hook_extension, hook_extend_along, l_cover_of_ties, r_cover_of_ties, t_cover_of_ties, b_cover_of_ties, dia_of_ties, dia_of_main_rebars, l_rebar_rounding, face_length, ) list_orientation = l_rebar_orientation_cover["list_orientation"] l_cover = l_rebar_orientation_cover["l_cover"] r_cover = l_rebar_orientation_cover["r_cover"] t_cover = t_offset_of_rebars b_cover = b_offset_of_rebars if hook_extend_along == "x-axis": rebar_number_spacing_value = 2 orientation = list_orientation[1] main_rebars.append( makeLShapeRebar( f_cover, b_cover, l_cover[1], r_cover[1], dia_of_main_rebars, t_cover, l_rebar_rounding, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, )) main_rebars[-1].OffsetEnd = (t_cover_of_ties + dia_of_ties + dia_of_main_rebars / 2) elif hook_extend_along == "y-axis": rebar_number_spacing_value = 1 orientation = list_orientation[1] for i, orientation in enumerate(list_orientation): main_rebars.append( makeLShapeRebar( f_cover, b_cover, l_cover[i], r_cover[i], dia_of_main_rebars, t_cover, l_rebar_rounding, rebar_number_spacing_check, rebar_number_spacing_value, orientation, structure, facename_for_rebars, )) main_rebars[i].OffsetEnd = (l_cover_of_ties + dia_of_ties + dia_of_main_rebars / 2) FreeCAD.ActiveDocument.recompute() return main_rebars