import rhinoscriptsyntax as rs import math # Clear existing objects rs.DeleteObjects(rs.AllObjects()) def create_london_city_hall(): # Define parameters for the ellipsoid semi_major = 10 # Semi-major axis (X-direction) semi_minor = 10 # Semi-minor axis (Y-direction) vertical_stretch = 15 # Vertical axis (Z-direction) tilt_angle = 20 # Tilt angle in degrees # Adjust the center to ensure intersection with the ground plane center = (0, 0, vertical_stretch * 0.4) # Move center slightly below Z = vertical_stretch # Create a unit sphere at the adjusted center radius = 1 # Initial radius of the sphere sphere = rs.AddSphere(center, radius) if not sphere: print("Failed to create sphere.") return # Scale the sphere to form an ellipsoid rs.ScaleObject(sphere, center, (semi_major, semi_minor, vertical_stretch)) # Rotate the ellipsoid to tilt it rs.RotateObject(sphere, center, tilt_angle, rs.VectorCreate((0, 1, 0), (0, 0, 0))) # Add a cutting plane at Z = 0 plane = rs.AddPlaneSurface(rs.WorldXYPlane(), 30, 30) # Large enough to intersect ellipsoid rs.MoveObject(plane, (-15,-15,0)) if not plane: print("Failed to create cutting plane.") return # Split the ellipsoid with the plane split_result = rs.SplitBrep(sphere, plane, delete_input=False) if not split_result: print("Failed to split the ellipsoid with the plane.") return # Keep only the top half of the ellipsoid kept_part = None for part in split_result: bbox = rs.BoundingBox(part) if bbox and bbox[0][2] >= 1: # Check if the part is above the ground plane kept_part = part break if kept_part: rs.DeleteObject(plane) # Cleanup: Delete the cutting plane # Delete all other parts except the top part for part in split_result: if part != kept_part: rs.DeleteObject(part) # Delete unwanted parts print("Simplified London City Hall created with ground floor.") else: print("No suitable part of the ellipsoid found above the ground plane.") # Run the function create_london_city_hall()