############################## import rhinoscriptsyntax as rs import random, time, sys ### sys.path.append("P:\WWW\halil2003\DM2") ### add path where "DM_lib.py" can be found !!! sys.path.append("P:\WWW\halil2003\DM2") ### add path where "DM_lib.py" can be found !!! sys.path.append("P:\WWW\halil2003\DM2") ### add path where "DM_lib.py" can be found !!! import DM_lib as dm ### reload(dm) ############################## rs.UnitSystem(3) rs.ShowGrid(view=None, show=0) rs.ShowGridAxes(view=None, show=0) rs.ViewDisplayMode(view=None, mode="Wireframe") rs.EnableRedraw(0) dm.PointRadius(displayModeX=0, rad=3, styl=1) rs.DeleteObjects(rs.AllObjects()) strong_yellow_color = [255, 255, 0] spehere_1_cen = [10, 10, 10] spehere_2_cen = [100, 10, 10] radius = 30 coords_spehere_1 = [] for distance in range(radius): scalVec = [distance, 0, 0] for i in range(1001): scalVec = rs.VectorRotate( scalVec, random.uniform(-90,90), [random.uniform(-1,1) for i in range(3)]) coords_spehere_1.append( rs.VectorAdd( spehere_1_cen, scalVec ) ) rs.AddPoints( coords_spehere_1 ) coords_spehere_2 = [] for distance in range(radius): scalVec = [distance, 0, 0] for i in range(1001): scalVec = rs.VectorRotate( scalVec, random.uniform(-90,90), [random.uniform(-1,1) for i in range(3)]) coords_spehere_2.append( rs.VectorAdd( spehere_2_cen, scalVec ) ) rs.AddPoints( coords_spehere_2 ) top_left = [0, 15, 15] top_right = [0, -15, 15] bottom_left = [0, 15, -15] bottom_right = [0, -15, -15] offsets = [top_left, top_right, bottom_left, bottom_right] side_1_pts = [] for offset in offsets: side_1_pt = rs.VectorAdd( spehere_1_cen, offset) side_1_pts.append(side_1_pt) side_2_pts = [] for offset in offsets: side_2_pt = rs.VectorAdd( spehere_2_cen, offset) side_2_pts.append(side_2_pt) side_2_pts_id = rs.AddPoints(side_2_pts) rs.ObjectColor(side_2_pts_id, strong_yellow_color) cube_pts = [] left_x = int(side_1_pts[0][0]) right_x = int(side_2_pts[0][0]) closer_y = int(side_1_pts[1][1]) further_y = int(side_1_pts[0][1]) bottom_z = int(side_1_pts[2][2]) top_z = int(side_1_pts[0][2]) for x in range(left_x, right_x + 1): for y in range(closer_y, further_y + 1): for z in range(bottom_z, top_z + 1): pt = [x, y, z] diff_1 = rs.VectorSubtract(pt, spehere_1_cen) if rs.VectorLength(diff_1) < radius: # if it belongs to the first spehere # then skip it i.e. do not visualize it continue diff_2 = rs.VectorSubtract(pt, spehere_2_cen) if rs.VectorLength(diff_2) < radius: # if it belongs to the second spehere # then skip it i.e. do not visualize it continue cube_pts.append(pt) cube_pts_id = rs.AddPoints(cube_pts) rs.ObjectColor(cube_pts_id, strong_yellow_color) rs.ZoomExtents()