View Full Version : update viewport when value changed(python)
adamdaly 09-05-2010, 05:00 PM Hi, i've been messing with python a little, creating the usual oscilating square thing. I have a userdata set up for the frequency and the amplitude. These values only update when the timeline returns to 0. Is there anyway to get the values to change in the python script when i change the userdata values while the animation is playing.
thanks
adam
|
|
donelgreeko
09-05-2010, 06:55 PM
Hi adamdaly,
where did you create the new user data from? A script, plugin,...?
Cheers, Sebastian
adamdaly
09-06-2010, 11:20 AM
hi, I just mean changing values in the attribute editor. The user data is added to the python tag.
adam
donelgreeko
09-06-2010, 12:05 PM
When you change the values from a script, just call "c4d.EventAdd()" after you changed all your values of all objects.
Cheers, Sebastian
adamdaly
09-06-2010, 07:39 PM
That doesn't seem to work. Heres my code:
import c4d, math, random
from c4d import bitmaps, documents, gui, modules, plugins, storage, symbols as sy, utils
fps = doc.GetFps()
delta = 1/float(fps)
tag = op
freq = tag[sy.ID_USERDATA, 1]
amp = tag[sy.ID_USERDATA, 2]
def CS_Time(fs):
t = doc.GetTime().Get()
return utils.Clamp(0, 999999, (t-(fs*delta)))
def main():
t = CS_Time(0)#returns time in seconds
ob = op.GetObject()
newPosition = c4d.Vector(0, abs(math.sin(math.radians(t*freq*360)))*amp ,0)
ob.SetPos(newPosition)
c4d.EventAdd()
I've placed the EventAdd at the end but the code doesn't update in real time, only when it gets to frame 0 again.
adam
donelgreeko
09-06-2010, 09:32 PM
Ok, you work with Py4D, not with the current Python integration of R12, right? In some cases, the update process might fail, this was fixed in C4D R12.
Please never use EventAdd() in any expression, just in real Python scripts.
CGTalk Moderation
09-06-2010, 09:32 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.