Hier is mijn versie waar ik het eerder over had - die wel goed loopt... Het enige is dat je er zelf op moet letten dat je voor de uren en minuten hele getallen invoert, dus niks achter de komma. Voor de tijd ga je naar Klok > Object tab > Custom propertieshttp://blender.zaph.nl/klok-met-drivers.blend
import bpyimport time as tfrom math import pi, degrees, radiansdef get_uur_min_sec(): tim = t.localtime() uur = (tim[3] % 12) * 30 min = tim[4] * 6 sec = tim[5] * 6 return (uur,min,sec) uur,min,sec = get_uur_min_sec()print(uur,min,sec)bpy.context.area.type = 'VIEW_3D'#bpy.ops.view3d.snap_cursor_to_center() ###Crash???!!!Klein = bpy.data.objects['Klein']Groot = bpy.data.objects['Groot']Seconde = bpy.data.objects['Seconde']#werkt maar niet nodig: print(Klein,Groot,Seconde)bpy.context.scene.objects.active = Secondebpy.context.object.rotation_euler[1] = radians(sec)bpy.context.scene.objects.active = Grootbpy.context.object.rotation_euler[1] = -radians(min)bpy.context.scene.objects.active = Kleinbpy.context.object.rotation_euler[1] = radians(uur)bpy.context.area.type = 'TEXT_EDITOR'
import bpy""" voorbeeld van WWWdef driverFunc(val): return val * val # return val squaredbpy.app.driver_namespace['driverFunc'] = driverFunc # add function to driver_namespace"""def set_my_clock(Second = "Seconde", Klein = "Klein", Groot = "Groot"): import bpy import time as t from math import pi, degrees, radians print(bpy.context.area) #bpy.context.area.type = 'VIEW_3D' tim = t.localtime() print("time is " + str(tim[5])) uur = (tim[3] % 12) * 30 min = tim[4] * 6 sec = tim[5] * 6 Klein = bpy.data.objects['Klein'] Groot = bpy.data.objects['Groot'] Seconde = bpy.data.objects['Seconde'] Cube = bpy.data.objects['Cube'] print(Klein.name)# print(uur,min,sec)#bpy.ops.view3d.snap_cursor_to_center()# print(Klein,Groot,Seconde) bpy.context.scene.objects.active = Seconde print("voor") print("active object" + str(bpy.context.scene.objects.active)) print(bpy.context.object.rotation_euler[1]) bpy.context.object.rotation_euler[1] = radians(sec) print(bpy.context.object.rotation_euler[1]) print("na") bpy.context.scene.objects.active = Groot bpy.context.object.rotation_euler[1] = -radians(min) bpy.context.scene.objects.active = Klein bpy.context.object.rotation_euler[1] = radians(uur) #bpy.context.area.type = 'TEXT_EDITOR' tmp = (uur * 3600 + min * 60 + sec) print("tmp = " + str(tmp)) bpy.context.scene.objects.active = Cube return tmpset_my_clock()bpy.app.driver_namespace['set_my_clock'] = set_my_clock # add function to driver_namespace
Zaph, mag ik je *.blend ook aan anderen 'geven'?