import rhinoscriptsyntax as rs import math # Delete all objects and start from scratch rs.DeleteObjects(rs.AllObjects()) def create_scallop_shell(): if not rs.IsLayer("loft"): rs.AddLayer("loft") if not rs.IsLayer("pipes"): rs.AddLayer("pipes") # Shell parameters shell_width = 12 # Width of the shell shell_height = 10 # Height of the shell curvature_height = 2 # Vertical curvature of the shell rib_count = 30 # Number of radial ribs skip_count = 6 # Number of ribs to skip on each side pipe_radius_2 = 0.25 # Radius of the pipes along each rib pipe_radius_1 = 0.05 # Outer profile curve outer_profile_points = [ (0, 0, 0), (shell_width * 0.2, -shell_height * 0.2), (shell_width * 0.5, -shell_height * 0.5), (shell_width * 0.8, -shell_height * 0.4), (shell_width, 0), (shell_width * 0.8, shell_height * 0.4), (shell_width * 0.5, shell_height * 0.5), (shell_width * 0.15, shell_height * 0.15), (0, 0, 0) ] outer_profile_curve = rs.AddInterpCurve(outer_profile_points) # Create only the middle ribs, skipping the first and last 6 rib_curves = [] for i in range(skip_count, rib_count - skip_count + 1): t = i / rib_count rib_point = rs.EvaluateCurve(outer_profile_curve, rs.CurveParameter(outer_profile_curve, t)) rib_points = [] for j in range(20): # Create points along each rib factor = j / 19 x = rib_point[0] * factor y = rib_point[1] * factor z = curvature_height * math.sin(math.pi * factor) * (1 - factor**0.5) # Smooth transition rib_points.append((x, y, z)) rib_curve = rs.AddInterpCurve(rib_points) rib_curves.append(rib_curve) # Create pipes and add to "pipes" layer pipe = rs.AddPipe(rib_curve, [0, 1], [pipe_radius_1, pipe_radius_2]) if pipe: rs.ObjectColor(pipe, (255, 255, 0)) rs.ObjectLayer(pipe, "pipes") # Create loft surfaces and add to "loft" layer if len(rib_curves) >= 6: loft_curves = rib_curves[:6] loft_surface = rs.AddLoftSrf(loft_curves) if loft_surface: rs.ObjectColor(loft_surface[0], (0, 0, 255)) rs.ObjectLayer(loft_surface[0], "loft") if len(rib_curves) > 18: loft_curves = rib_curves[5:19] loft_surface = rs.AddLoftSrf(loft_curves) if loft_surface: rs.ObjectColor(loft_surface[0], (0, 0, 255)) rs.ObjectLayer(loft_surface[0], "loft") # create loft vorne links last_line_left = rs.AddLine((0, 0, 0), (3.830, -3.417, 0)) if rib_curves: first_rib = rib_curves[0] loft_surface_left = rs.AddLoftSrf([last_line_left, first_rib]) if loft_surface_left: rs.ObjectColor(loft_surface_left[0], (255, 0, 0)) # Red color for visibility rs.ObjectLayer(loft_surface_left[0], "loft") # Add line and create a loft on the right side last_line_right = rs.AddLine((0, 0, 0), (3.686, 3.318, 0)) if rib_curves: last_rib = rib_curves[-1] loft_surface_right = rs.AddLoftSrf([last_line_right, last_rib]) if loft_surface_right: rs.ObjectColor(loft_surface_right[0], (255, 0, 0)) # Green color for visibility rs.ObjectLayer(loft_surface_right[0], "loft") # Add polyline for side things polyline_points = [(0.574,-0.513,0),(0.562,-2.039,0),(2.368,-2.115,0),(0.574,-0.513,0)] rs.AddPolyline(polyline_points) polyline_points_2 =[(0.583,0.524,0),(0.562,2.043,0),(2.368,2.119,0),(0.583,0.524,0)] rs.AddPolyline(polyline_points_2) # add rips as lines rs.AddLine((1.010,0.909,0),(1.010,2.062,0)) rs.AddLine((1.597,2.086,0),(1.595,1.436,0)) rs.AddLine((1.010,-0.902,0),(1.010,-2.057,0)) rs.AddLine((1.597,-1.426,0),(1.595,-2.082,0)) # Run the script create_scallop_shell()