###################################################### ######## ANImate Marilyn Monroe & Turnerinnen ######## ###################################################### ############################## import rhinoscriptsyntax as rs import random, time, sys, math, os ### #from itertools import combinations #from itertools import permutations import itertools sys.path.append("P:/") ### sys.path.append("L:/") ### import DM_lib as dm ### reload(dm) ############################## rs.UnitSystem(4) # meters = 4, cm = 3 etc rs.ShowGrid(None, 0) # grid > 0 = off rs.ShowGridAxes(None, 0) # y/y/z axen display > 0/1 = off/on rs.ViewDisplayMode(rs.CurrentView(), "wireframe") rs.Command("cplane w t enter", 0) dm.PointRadius(displayModeX=0, rad=3, styl=3) dm.printDisplay(0) rs.EnableRedraw(0) ### not used here: def makeFigure( pnts=[], crv_degree=1, pos=[30.0, 0,0], divis=64, show=1, delIt=1, crv_name="singt", obj_color=[0,200,0]): coords = [ rs.VectorAdd(cor, pos) for cor in pnts ] crvID = rs.AddCurve(coords, crv_degree) rs.ObjectColor( crvID, obj_color ) rs.ObjectName( crvID, crv_name ) coords = rs.DivideCurve( crvID, divis, show ) if delIt: rs.DeleteObject( crvID ) return coords ### USAge #coords_1 = makeFigure( pnts=pnts_singt, crv_degree=deg, pos=[50.0, 10.0,0], divis=anz, show=showPts, delIt=delIt, crv_name="MM_singt", obj_color=[0,200,0]) #coords_2 = makeFigure( pnts=pnts_wind, crv_degree=deg, pos=[00.0, 10.0,0], divis=anz, show=showPts, delIt=delIt, crv_name="MM_wind", obj_color=[210,0,120]) def setCrvStartPoint( crvID, set2point ): if not rs.IsCurveClosed(crvID): print "!!! curve ist not closed" return param=rs.CurveClosestPoint(crvID,set2point) rs.CurveSeam(crvID,param) ### tst print rs.CurveStartPoint(crvID), "\n", rs.EvaluateCurve(crvID,param) return rs.CurveStartPoint(crvID) ### USAge / tst #setCrvStartPoint( "4444c0c9-9046-49b9-b2ad-368c5a61b83f", [2145.759,649.485,228.098] ) #setCrvStartPoint( "c55be39a-2484-4251-99ec-9359de807a44", [2790.027,649.485,411.627] ) #MM #rs.AddPoint(setCrvStartPoint( "05df7669-d708-4c6b-9f64-788086024ac1", [6.809,1.728,4.808] )) #rs.AddPoint(setCrvStartPoint( "6070313a-fdc5-4005-accc-0f67757c4917", [10.931,1.918,4.717] )) #rs.AddPoint(setCrvStartPoint( "8dcac52f-b68a-434e-95e7-6f789eef11e5", [15.053,3.167,4.750] )) anz = 16*4 showPts = 0 deg = 1 delIt = 0 dm.newEmptyLayer("TST") #dm.setCameraTarget( [3041.31517563, -2800.26096912, 607.17679033], [-502.90614144, -445.42106446, -343.98856543], lens=50.0, rota=0, upVec=[-0.18169718703862137,0.12072264915897345,0.9759160692407373] ) # ... danke, andi ! #rs.LayerVisible("turn_figuren", 1) if 0: rs.LayerVisible("Marilyn", 1) MM_0 = rs.ObjectsByName("spagat")[0] MM_1 = rs.ObjectsByName("pose_0")[0] MM_2 = rs.ObjectsByName("spagat_1")[0] MM_3 = rs.ObjectsByName("pose_1")[0] coords_0 = rs.DivideCurve(MM_0, anz, 0) coords_1 = rs.DivideCurve(MM_1, anz, 0) coords_2 = rs.DivideCurve(MM_2, anz, 0) coords_3 = rs.DivideCurve(MM_3, anz, 0) dm.exportCoordLists(list2export=[coords_0,coords_1,coords_2,coords_3], exportedListName='allCoords', path='P:/', fileName='TURN_coords') rs.LayerVisible("Marilyn", 0) rs.LayerVisible("turn_figuren", 0) rs.LayerVisible("Default", 0) ###################### import TURN_coords as TU reload(TU) ###################### #print mm.allCoords[0][0] coords_0 = TU.allCoords[0] coords_1 = TU.allCoords[1] coords_2 = TU.allCoords[2] coords_3 = TU.allCoords[3] anz = 164 coords_0 = rs.DivideCurve(rs.ObjectsByName("MM_arme")[0], anz, 0 ) coords_1 = rs.DivideCurve(rs.ObjectsByName("MM_schlank")[0], anz, 0 ) coords_2 = rs.DivideCurve(rs.ObjectsByName("MM_breit")[0], anz, 0 ) #anz = len(coords_0) if 0: ### just tst for coords in TU.allCoords: rs.AddCurve( coords, 1 ) rs.Redraw() rs.Sleep(00) rs.AddPoint( coords[0] ) rs.Redraw() dm.getCameraTarget() #dm.setCameraTarget( [-77.48685689, 11.77273249, 12.05421199], [17.20711797, 25.7546931, 14.05896983], lens=49.99999999, rota=0, upVec=[-0.020714654726424725,-0.003058605226544303,0.999780749971529] ) # ... danke, andi ! ## cam 1 #dm.setCameraTarget( [925.90405877, -1632.869047, 173.64306014], [3286.86038367, 1581.09795362, 6.48599166], lens=49.99999999, rota=0, upVec=[0.024793245818494996,0.03375101566197099,0.9991226971216142] ) # ... danke, andi ! allCoords = [coords_0, coords_2, coords_1, coords_0 , coords_1 ]#, coords_3, coords_0]#, coords_0] if 1: captureIt = 0 keepFrames = 8 framesProFigur = 25*1 path = "D:/animatzi/TU_tst/" if not os.path.exists(path): os.makedirs(path) fac = 1/framesProFigur #allCoords = [] for i in range(0, len(allCoords)-1): framNumber = 0 coords_A = allCoords[i][:] coords_B = allCoords[i+1][:] #rs.AddLine( coords_A[0], coords_B[0] ) for fram in range(0, framesProFigur+1): coords = [ dm.pntInbetween( coords_A[j], coords_B[j], fac*framNumber ) for j in range(anz) ] ### anz = points pro figur frameCrvs = rs.ObjectsByName("frameCrv") if len(frameCrvs) == keepFrames: rs.DeleteObjects(frameCrvs[-1:]) coords.append(coords[0]) crv = rs.AddCurve(coords, deg) rs.ObjectName(crv, "frameCrv") rs.Redraw() nam = dm.makeName("TU", frameNumber=framNumber+i*framesProFigur, anzahl=4, format='jpg') if captureIt: rs.Command("-viewCaptureToFile Width=960 Height=540 Scale=2 DrawCPlaneAxes=No TransparentBackground=No "+path+nam+" ", 0) framNumber +=1 #print nam dm.esc() #s.Redraw() rs.LayerVisible("Default", 1) rs.CurrentLayer("Default") dm.printDisplay(1) #print round(48/11, 2) #print 48 - round(48/11, 2) #print (48 - round(48/11, 2)) + round(48/11, 2)