#DM2_w24 hu_03_setUp# import rhinoscriptsyntax as rs import random, time, sys ### sys.path.append("P:/WWW/cherrycola/DM2") import DM_lib as dm ### reload(dm) ############################## import rhinoscriptsyntax as rs import math # Clean up the workspace rs.DeleteObjects(rs.AllObjects()) # Define colors rectangle_color = [0, 0, 255] # Blue sphere_color = [255, 0, 0] # Red cube_color = [0, 255, 0] # Green # Step 1: sphere data sphere_center = [0, 0, 0] sphere_radius = 10 sphere_pts = [] # Create sphere points using spherical coordinates for theta in range(0, 360, 10): # latitude for phi in range(0, 180, 10): # longitude x = sphere_center[0] + sphere_radius * math.sin(math.radians(phi)) * math.cos(math.radians(theta)) y = sphere_center[1] + sphere_radius * math.sin(math.radians(phi)) * math.sin(math.radians(theta)) z = sphere_center[2] + sphere_radius * math.cos(math.radians(phi)) sphere_pts.append([x, y, z]) # Create sphere points in Rhino sphere_pts_id = rs.AddPoints(sphere_pts) rs.ObjectColor(sphere_pts_id, sphere_color) # Color # Step 2: rectangle data rect_base_point = [0, 0, sphere_radius - 5] rect_width = 15 rect_height = 10 rect_thickness = 3 # Create rectangle points (volume) rect_pts = [] for z in range(rect_thickness + 1): # thickness for x in range(rect_width + 1): # width for y in range(rect_height + 1): # height pt = [rect_base_point[0] + x, rect_base_point[1] + y, rect_base_point[2] + z] rect_pts.append(pt) # Create rectangle points in Rhino rect_pts_id = rs.AddPoints(rect_pts) # Add all rectangle points rs.ObjectColor(rect_pts_id, rectangle_color) # Color # Step 3: Set up cube data to intertwine with the sphere cube_base_point = [0, 0, sphere_center[2] - sphere_radius] cube_size = 10 # Create cube points (volume) cube_pts = [] for z in range(cube_size + 1): # height for x in range(cube_size + 1): # width for y in range(cube_size + 1): # depth pt = [cube_base_point[0] + x, cube_base_point[1] + y, cube_base_point[2] + z] cube_pts.append(pt) # Create cube points in Rhino cube_pts_id = rs.AddPoints(cube_pts) # Add all cube points rs.ObjectColor(cube_pts_id, cube_color) # Color rs.ZoomExtents()