import rhinoscriptsyntax as rs import random def delete_previous_objects(): """ Deletes all existing objects in the Rhino document. """ objects = rs.AllObjects() if objects: rs.DeleteObjects(objects) def create_dome_with_organic_shapes(radius=20, rows=30, cols=30, max_height=5): """ Creates a dome-like structure with organic shapes arranged on a grid. Parameters: radius (float): Radius of the dome. rows (int): Number of rows in the grid. cols (int): Number of columns in the grid. max_height (float): Maximum height of the shapes. """ for i in range(rows): for j in range(cols): # Calculate the grid position x = i - rows / 2 y = j - cols / 2 distance_from_center = (x**2 + y**2)**0.5 # Check if the point lies within the dome's radius if distance_from_center <= radius: # Calculate the dome height at this point dome_height = (radius**2 - distance_from_center**2)**0.5 # Add randomness to the shape height shape_height = random.uniform(1, max_height) # Calculate the base center point base_point = (x, y, dome_height - shape_height / 2) # Create an organic shape create_organic_shape(base_point, random.uniform(0.5, 1.5), shape_height) def create_organic_shape(base_point, size, height): """ Creates an organic shape (e.g., a tapered or rounded extrusion). Parameters: base_point (tuple): The (x, y, z) coordinates of the base center. size (float): The base diameter of the shape. height (float): The height of the shape. """ x, y, z = base_point base_circle = rs.AddCircle((x, y, z), size) # Create a circle as the base top_point = (x, y, z + height) # Top point of the shape # Create a more organic form using loft or extrusion offset_circle = rs.CopyObject(base_circle, (0, 0, height * 0.8)) rs.ScaleObject(offset_circle, (x, y, z + height * 0.8), [random.uniform(0.5, 0.8)] * 3) loft = rs.AddLoftSrf([base_circle, offset_circle])[0] # Delete temporary objects to keep the scene clean rs.DeleteObject(base_circle) rs.DeleteObject(offset_circle) # Optionally apply a smooth random taper to the shape rs.MoveObject(loft, (0, 0, random.uniform(-0.5, 0.5))) # Run the script delete_previous_objects() create_dome_with_organic_shapes(radius=20, rows=30, cols=30, max_height=6)