############################## ### DM2_w24 hu_03_setUp ### ### _diag / 2024 11 06 ### ############################## import rhinoscriptsyntax as rs import random, time, sys ### sys.path.append("P:/") ### add path where "DM_lib.py" can be found !!! sys.path.append("P:/WWW\\ge84lid\\dm2/") ### add path where "DM_lib.py" can be found !!! sys.path.append("P:/dm2/") ### add path where "DM_lib.py" can be found !!! import DM_lib as dm ### reload(dm) ############################## rs.EnableRedraw(0) alleObjekte = rs.AllObjects() rs.DeleteObjects(alleObjekte) rs.Redraw() if 1: rs.EnableRedraw(0) dm.eA() rad = random.randint(9, 20) def makeSphere( rad=rad, rotaIt=0 ): anz = 4000 deltaAngle = 360/anz # Berechnung der Winkel zwischen den Punkte #rad = random.randint(9, 20) vec = [rad, 0,0] sphereCoords = [] for i in range(anz): # Rotieren der Punkte in zwei Dimensionen, Speichern in Liste vecX = rs.VectorRotate(vec, random.uniform(0,90), [0,0,1]) vecX = rs.VectorRotate(vecX, random.uniform(0,90), [0,1,0]) sphereCoords.append( vecX ) anz = rad+1 # anz ist die Anzahl der Punkte auif dem Wuerfel, +1, weil beginnt bei 0 zu zaehlen cubeCoords = [ [x,y,z-(rad)] for x in range(anz) for y in range(anz) for z in range(anz) if ( [x,y,z].count(0) + [x,y,z].count(anz-1) ) > 1 ] if rotaIt: pass sphereCoords = [ rs.VectorRotate(vec,180,[1,0,0]) for vec in sphereCoords ] sphereCoords = [ rs.VectorRotate(vec,90,[0,0,1]) for vec in sphereCoords ] cubeCoords = [ rs.VectorRotate(vec,180,[1,0,0]) for vec in cubeCoords ] cubeCoords = [ rs.VectorRotate(vec,90,[0,0,1]) for vec in cubeCoords ] return [sphereCoords, cubeCoords] # gibt Liste zurueck die beides enhaelt allCoords = makeSphere() # Aufruf der Funktion makeSphere Speicherung im allCoords # Wuerfel-Rahmen und Kugel-Viertel anz = rad+1 print rad, anz cubeCoords = [ [x,y,z-(rad)] for x in range(anz) for y in range(anz) for z in range(anz) if ( [x,y,z].count(0) + [x,y,z].count(anz-1) ) > 1 ] # Wuerfel-Rahmen verkuerzt geschrieben rad_0 = random.randint(9, 20) rs.ObjectColor(rs.AddPoints( makeSphere( rad_0, rotaIt=0 )[0] ), [69,139,0]) # mit zufaelligem Radius, ohne Rotation rs.ObjectColor(rs.AddPoints( makeSphere( rad_0, rotaIt=0 )[1] ), [200,0,0]) rad_1 = random.randint(9, 20) sphereCoords = makeSphere( rad=rad_1, rotaIt=1 )[0] # mit zufaelligem Radius, mit Rotation. 0 weil erstes aus return cubeCoords = makeSphere( rad=rad_1, rotaIt=1 )[1] # 1 weil zweites aus return cubeCoords = [ rs.VectorAdd( vec, [rad_0-rad_1, 0,0]) for vec in cubeCoords ] # Verschiebung der Punkte des Wuerfels sphereCoords = [ rs.VectorAdd( vec, [rad_0-rad_1, 0,0]) for vec in sphereCoords ] # Verschiebung der Punkte der Sphere #rs.AddPoints( cubeCoords ) #rs.AddPoints( sphereCoords ) rs.ObjectColor(rs.AddPoints( cubeCoords ), [69,139,0]) rs.ObjectColor(rs.AddPoints( sphereCoords ), [200,0,0]) # Kurven so erstellen, dass sie auf den Spheres liegen (teilweise hilfe von chatgpt) pln =rs.PlaneFromNormal([0,0,0], [0,1,1], xaxis=[0,1,0]) verschiebe_vec = [rad_0 - rad_1, 0, 0] ursprung = rs.VectorAdd([0, 0, 0], verschiebe_vec) pln = rs.PlaneFromNormal(ursprung, [0, 1, 1], xaxis=[0, 1, 0]) #chatgpt kurv_1 = rs.AddArc(pln, rad_1, -90) pln_1 =rs.PlaneFromNormal([0,0,0], [0,1,1], xaxis=[0,1,0]) kurv_2 = rs.AddArc(pln_1, rad_0, -90)