import rhinoscriptsyntax as rs rs.DeleteObjects(rs.AllObjects()) def create_double_hanging_truss(): # Parameters for the roof structure """roof_length = rs.GetReal("Enter the roof length", 30.0) roof_height = rs.GetReal("Enter the roof height", 5.0) roof_span = rs.GetReal("Enter the roof span (width)", 18.0) truss_spacing = rs.GetReal("Enter the spacing between trusses", 4.0)""" roof_length = 30.0 roof_height = 6 roof_span = 16 truss_spacing = 4.0 if not all([roof_length, roof_height, roof_span, truss_spacing]): print("Invalid input parameters.") return # Proportional dimensions based on diagram lower_chord_length = 0.4 * roof_length side_chord_length = 0.3 * roof_length ridge_position = roof_length / 2 num_trusses = int(roof_length / truss_spacing) + 1 trusses = [] for i in range(num_trusses): x_offset = i * truss_spacing # Bottom of the truss (lower chord) left_base = (x_offset, 0, 0) right_base = (x_offset, roof_span, 0) # Top of the truss (ridge point) ridge_point = (x_offset, roof_span / 2, roof_height) # Create the main triangular truss truss_lines = [ rs.AddLine(left_base, ridge_point), # Left rafter rs.AddLine(right_base, ridge_point), # Right rafter rs.AddLine(left_base, right_base), # Bottom chord ] # Add the collar tie (horizontal beam) collar_tie_start = (x_offset, roof_span * 0.3, roof_height * 0.5) collar_tie_end = (x_offset, roof_span * 0.7, roof_height * 0.5) truss_lines.append(rs.AddLine(collar_tie_start, collar_tie_end)) # Add vertical hangers (suspenders) hanger_top = (x_offset, roof_span / 2, roof_height * 0.5) hanger_bottom = (x_offset, roof_span / 2, 0) truss_lines.append(rs.AddLine(hanger_top, hanger_bottom)) # Add Vertical carrier hanger left_hanger_start = (x_offset, roof_span * 0.3, roof_height * 0.6) left_hanger_end = (x_offset, roof_span * 0.3, 0) right_hanger_start = (x_offset, roof_span * 0.7, roof_height * 0.6) right_hanger_end = (x_offset, roof_span * 0.7, 0) truss_lines.append(rs.AddLine(left_hanger_start, left_hanger_end)) truss_lines.append(rs.AddLine(right_hanger_start, right_hanger_end)) # Add diagonal braces (struts) left_brace_start = (x_offset, roof_span * 0.3, roof_height * 0.5) left_brace_end = (x_offset, roof_span * 0.05, 0) right_brace_start = (x_offset, roof_span * 0.7, roof_height * 0.5) right_brace_end = (x_offset, roof_span * 0.95, 0) truss_lines.append(rs.AddLine(left_brace_start, left_brace_end)) truss_lines.append(rs.AddLine(right_brace_start, right_brace_end)) trusses.extend(truss_lines) """ roof_length = 30.0 lower_chord_length= 0.4 * roof_length chord_height=0.4 chord_width=0.24""" """def make_lowerchord(insertion=[0,0,0], xsize=10, ysize=10, zsize=10): corners_lowerchord=[[0,0,0], [lower_chord_length,0,0], [lower_chord_length,chord_width,0], [0,chord_width,0], [0,0,chord_height], [lower_chord_length,0,chord_height], [lower_chord_length,ysize,zsize], [0,chord_width,chord_height]] box = rs.AddBox(corners) rs.MoveObjects(box, (-xsize/2, -ysize/2, 0)) rs.MoveObject(box,insertion) return(box)""" """def make_box(insertion=[0,0,0], xsize=10, ysize=10, zsize=10): corners = [[0,0,0], [xsize,0,0], [xsize,ysize,0], [0,ysize,0], [0,0,zsize], [xsize,0,zsize], [xsize,ysize,zsize], [0,ysize,zsize]] box = rs.AddBox(corners) rs.MoveObjects(box, (-xsize/2, -ysize/2, 0)) rs.MoveObject(box,insertion) return(box) corners_lowerchord=[[0,0,0], [lower_chord_length,0,0], [lower_chord_length,chord_width,0], [0,chord_width,0], [0,0,chord_height], [lower_chord_length,0,chord_height], [lower_chord_length,chord_width,chord_height], [0,chord_width,chord_height]] make_box(corners_lowerchord)""" #Lowerchord Variables """# Group all trusses rs.AddGroup("Trusses") rs.AddObjectsToGroup(trusses, "Trusses") print("Double hanging truss structure completed.") """ if __name__ == "__main__": create_double_hanging_truss()