hi,
I’m designing an urban space and i have created a base model for this but to add up the design through this im stuck with that
and what ever im designing that should be in link to this
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
def create_bridge_with_cylindrical_supports_boxes_roadways_and_top(lat, long, length, width, height, num_supports, box_height, box_width, box_length, top_height, trapezoid_top_width, trapezoid_bottom_width, trapezoid_height, roadway_width, roadway_height, divider_width, divider_height, pedestrian_footpath_width, pedestrian_footpath_height):
# Define bridge deck as a straight polyline
deck_corners = [
rg.Point3d(0, 0, height),
rg.Point3d(length, 0, height),
rg.Point3d(length, width, height),
rg.Point3d(0, width, height)
]
deck = rg.Polyline(deck_corners + [deck_corners[0]]).ToNurbsCurve()
# Create cylindrical supports with solid box structures on top
supports_boxes_and_roadways = []
support_spacing = length / (num_supports + 1)
for i in range(1, num_supports + 1):
support_x = i * support_spacing
support_center = rg.Point3d(support_x, width / 2, 0) # Center the circle under the bridge deck
# Create the base cylinder for the support
support_circle = rg.Circle(support_center, width / 10) # Circle with a radius relative to the bridge width
support_cylinder = rg.Cylinder(support_circle, height).ToBrep(True, True)
# Create the solid box structure on top of the support
box_base_center = rg.Point3d(support_x, width / 2, height)
box_corners = [
rg.Point3d(box_base_center.X - box_length / 2, box_base_center.Y - box_width / 2, box_base_center.Z),
rg.Point3d(box_base_center.X + box_length / 2, box_base_center.Y + box_width / 2, box_base_center.Z + box_height)
]
box_brep = rg.Brep.CreateFromBox(rg.BoundingBox(box_corners))
# Add both the cylinder and the box to the supports list
supports_boxes_and_roadways.append(support_cylinder)
supports_boxes_and_roadways.append(box_brep)
# Create a single solid rectangular structure on top of all the boxes
top_base_z = height + box_height
top_corners = [
rg.Point3d(0, 0, top_base_z),
rg.Point3d(length, 0, top_base_z),
rg.Point3d(length, width, top_base_z + top_height),
rg.Point3d(0, width, top_base_z + top_height)
]
top_brep = rg.Brep.CreateFromBox(rg.BoundingBox(top_corners))
# Add the top rectangular structure to the list
supports_boxes_and_roadways.append(top_brep)
# Create the first trapezoid on one edge of the width
trapezoid_1_base_z = top_base_z + top_height
trapezoid_1_corners = [
rg.Point3d(0, 0, trapezoid_1_base_z),
rg.Point3d(length, 0, trapezoid_1_base_z),
rg.Point3d(length, trapezoid_top_width, trapezoid_1_base_z + trapezoid_height),
rg.Point3d(0, trapezoid_bottom_width, trapezoid_1_base_z + trapezoid_height)
]
trapezoid_1_brep = rg.Brep.CreateFromBox(rg.BoundingBox(trapezoid_1_corners))
# Create the second trapezoid on the other edge of the width
trapezoid_2_base_z = top_base_z + top_height
trapezoid_2_corners = [
rg.Point3d(0, width - trapezoid_bottom_width, trapezoid_2_base_z),
rg.Point3d(length, width - trapezoid_top_width, trapezoid_2_base_z + trapezoid_height),
rg.Point3d(length, width, trapezoid_2_base_z + trapezoid_height),
rg.Point3d(0, width, trapezoid_2_base_z)
]
trapezoid_2_brep = rg.Brep.CreateFromBox(rg.BoundingBox(trapezoid_2_corners))
# Add the trapezoids to the list
supports_boxes_and_roadways.append(trapezoid_1_brep)
supports_boxes_and_roadways.append(trapezoid_2_brep)
# Create roadways along the sides of the bridge
roadway_1_corners = [
rg.Point3d(0, -roadway_width, 0), # Start at the side of the bridge
rg.Point3d(length, -roadway_width, 0),
rg.Point3d(length, 0, 0),
rg.Point3d(0, 0, 0),
rg.Point3d(0, -roadway_width, roadway_height),
rg.Point3d(length, -roadway_width, roadway_height),
rg.Point3d(length, 0, roadway_height),
rg.Point3d(0, 0, roadway_height)
]
roadway_1_brep = rg.Brep.CreateFromBox(rg.BoundingBox(roadway_1_corners))
roadway_2_corners = [
rg.Point3d(0, width, 0), # Start at the other side of the bridge
rg.Point3d(length, width, 0),
rg.Point3d(length, width + roadway_width, 0),
rg.Point3d(0, width + roadway_width, 0),
rg.Point3d(0, width, roadway_height),
rg.Point3d(length, width, roadway_height),
rg.Point3d(length, width + roadway_width, roadway_height),
rg.Point3d(0, width + roadway_width, roadway_height)
]
roadway_2_brep = rg.Brep.CreateFromBox(rg.BoundingBox(roadway_2_corners))
# Add the roadways to the list
supports_boxes_and_roadways.append(roadway_1_brep)
supports_boxes_and_roadways.append(roadway_2_brep)
divider_1_corners = [
rg.Point3d(0, -divider_width, 0), # Place between the first roadway and the bridge
rg.Point3d(length, -divider_width, 0),
rg.Point3d(length, 0, 0),
rg.Point3d(0, 0, 0),
rg.Point3d(0, -divider_width, divider_height),
rg.Point3d(length, -divider_width, divider_height),
rg.Point3d(length, 0, divider_height),
rg.Point3d(0, 0, divider_height)
]
divider_1_brep = rg.Brep.CreateFromBox(rg.BoundingBox(divider_1_corners))
supports_boxes_and_roadways.append(divider_1_brep)
divider_2_corners = [
rg.Point3d(0, width, 0), # Place between the second roadway and the bridge
rg.Point3d(length, width, 0),
rg.Point3d(length, width + divider_width, 0),
rg.Point3d(0, width + divider_width, 0),
rg.Point3d(0, width, divider_height),
rg.Point3d(length, width, divider_height),
rg.Point3d(length, width + divider_width, divider_height),
rg.Point3d(0, width + divider_width, divider_height)
]
divider_2_brep = rg.Brep.CreateFromBox(rg.BoundingBox(divider_2_corners))
supports_boxes_and_roadways.append(divider_2_brep)
# Create the road between divider_1_brep and divider_2_brep
road_corners = [
rg.Point3d(0, 0, 0), # Start at the edge of the first divider
rg.Point3d(length, 0, 0),
rg.Point3d(length, pedestrian_footpath_width, 0), # Width of the road corresponds to the footpath width
rg.Point3d(0, pedestrian_footpath_width, 0),
rg.Point3d(0, 0, pedestrian_footpath_height), # Height of the road corresponds to the footpath height
rg.Point3d(length, 0, pedestrian_footpath_height),
rg.Point3d(length, pedestrian_footpath_width, pedestrian_footpath_height),
rg.Point3d(0, pedestrian_footpath_width, pedestrian_footpath_height)
]
road_brep = rg.Brep.CreateFromBox(rg.BoundingBox(road_corners))
# Add the road to the list
supports_boxes_and_roadways.append(road_brep)
return deck, supports_boxes_and_roadways
def get_float_value(input_value):
if isinstance(input_value, list):
return float(input_value[0])
else:
return float(input_value)
def get_int_value(input_value):
if isinstance(input_value, list):
return int(input_value[0])
else:
return int(input_value)
Grasshopper inputs
lat = get_float_value(xx)
long = get_float_value(yy)
length = get_float_value(x) # Length of the bridge
width = get_float_value(y) # Width of the bridge
height = get_float_value(z) # Height of the bridge and supports
num_supports = get_int_value(s) # Number of supports
box_height = get_float_value(hh) # Height of the box on top of each column
box_width = get_float_value(ww) # Width of the box
box_length = get_float_value(ll) # Length of the box
top_height = get_float_value(th) # Height of the single solid rectangular structure on top
trapezoid_top_width = get_float_value(tw) # Top width of the trapezoid
trapezoid_bottom_width = get_float_value(bw) # Bottom width of the trapezoid
trapezoid_height = get_float_value(thh) # Height of the trapezoid
roadway_width = get_float_value(rw) # Width of the roadway
roadway_height = get_float_value(rh) # Height of the roadway
divider_width = get_float_value(dw) # Width of the road divider
divider_height = get_float_value(dh)
pedestrian_footpath_width = get_float_value(pw)
pedestrian_footpath_height = get_float_value(ph)
Create bridge with cylindrical supports, solid box structures, top structure, trapezoids on the edges, and roadways along the sides
bridge_deck, supports_boxes_and_roadways = create_bridge_with_cylindrical_supports_boxes_roadways_and_top(lat, long, length, width, height, num_supports, box_height, box_width, box_length, top_height, trapezoid_top_width, trapezoid_bottom_width, trapezoid_height, roadway_width, roadway_height, divider_width, divider_height, pedestrian_footpath_width, pedestrian_footpath_height)
Outputs
a = bridge_deck
b = supports_boxes_and_roadways