### https://www.student.tugraz.at/denial.spahic/dm2/UE03/HU_03.py ### grabbed: 2024-10-23 18:05:58 ################################# ############################## ### DM2_w24 hu_03_setUp ### ### _diag / 2024 10 17 ### ############################## 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/deni2000") ### add path where "DM_lib.py" can be found !!! import DM_lib as dm ### reload(dm) ############################## #alleObjekte =rs.AllObjects() #rs.DeleteObjects( alleObjekte ) dm.newEmptyLayer( "HU03::lines", [138,102,66]) dm.newEmptyLayer( "HU03::spherePoints", [233,202,173]) dm.newEmptyLayer( "HU03::points", [255,255,255]) rs.EnableRedraw( 0 ) dm.eA() rs.Redraw() dm.PointRadius(displayModeX=1, rad=2, styl=1, verbose=1) ##(displayModeX=0, rad=3, styl=3, verbose=0) dm.PointRadius(displayModeX=0, rad=3, styl=2, verbose=1) ##(displayModeX=0, rad=3, styl=3, verbose=0) # untere Decke coord_1 = [] anz_x = 80 anz_y = 50 anz_z = 5 xVal = 8 + random.randint(1,5) yVal = 5 zVal = 5 for d in range(anz_x): for a in range(anz_y): for s in range(anz_z): x = d if d > anz_x*0.5: x += xVal y = a if a > anz_y*0.5: y += yVal z= s if s > anz_z*0.5: z += zVal co = [x,y,z] coord_1.append(co) point_1 = rs.AddPoints(coord_1) #obere Decke coord_2 = [] anz_x = 80 anz_y = 50 anz_z = 5 xVal = 8 + random.randint(1,5) yVal = 5 zVal = 5 for d in range(anz_x): for a in range(anz_y): for s in range(anz_z): x = d if d > anz_x*0.5: x += xVal y = a if a > anz_y*0.5: y += yVal z= s + 40 if s > anz_z*0.5: z += zVal co = [x,y,z] coord_2.append(co) point_2 = rs.AddPoints(coord_2) rs.Redraw() rs.ObjectColor(point_1,[46,50,52]) rs.ObjectColor(point_2,[86,7,12]) rs.Redraw() rs.AddCurve(coord_1,1) rs.AddCurve(coord_2,1) allCoords = coord_1 + coord_2 center = dm.pntCentroid( allCoords ) #rs.AddPoint( center ) #crv = rs.AddLine(coord_1[0], coord_2[-1] ) #crv = rs.AddLine(coord_2[0], coord_1[-1] ) centerX = coord_1[0][0]+(coord_1[-1][0] - coord_1[0][0])*0.5 centerY = coord_1[0][1]+(coord_1[-1][1] - coord_1[0][1])*0.5 centerZ = coord_1[-1][2] + (coord_2[0][2] - coord_1[-1][2])*0.5 center = [centerX, centerY, centerZ] #rs.AddPoint( center ) fac = 2.5 rad = (coord_2[0][2] - coord_1[-1][2])*fac coords = [] for i in range(8000): pX = random.choice( coord_1+coord_2 ) vecPx = rs.VectorSubtract( pX, center ) vecPx = rs.VectorUnitize( vecPx ) vecPx = rs.VectorScale( vecPx, rad ) vecPx = rs.VectorAdd(center, vecPx) coords.append( vecPx ) if random.randint(0,100) < 10: crv = rs.AddLine (pX, vecPx ) rs.ObjectLayer( crv, "HU03::lines") points = rs.AddPoints( coords ) rs.ObjectName( points, "spherePoints") rs.ObjectLayer( points, "HU03::spherePoints") rs.Command("-SetObjectDisplayMode -selName \"spherePoints\" enter \"wireframe\" enter", 0) rs.Redraw() rs.CurrentLayer("Default")