3 posts / 0 new
Last post
ForumImport
Offline
Last seen: 8 years 10 months ago
Joined: 09/22/2009 - 18:47
Scripted nodes: a basic question

Hi people out there (except spammer bots)
I wanted to have a try with scripted nodes. I created a DoubleSourceScript node, and gave it a script whose content is this:
#python
import k3d
context.output = k3d.time
Unfortunately, whatever the time I move to, Output Double always diplays 0. What's the proper way to do this?

ForumImport
Offline
Last seen: 8 years 10 months ago
Joined: 09/22/2009 - 18:47
Scripted nodes: a basic question

I also tried this:
k3d.get_time(k3d.documents()[0])
But I only get this as a result from the Python shell

What's wrong?

ForumImport
Offline
Last seen: 8 years 10 months ago
Joined: 09/22/2009 - 18:47
Scripted nodes: a basic question

OK, so first, the way to get the time property directly is long-winded:
k3d.node.lookup(k3d.documents()[0], 'TimeSource')[0].time
Here, we got the node that tracks time, and get the value of the time property
or, using the get_time method:
k3d.get_time(k3d.documents()[0]).internal_value()
Here, get_time returns the time property object, and we have to call internal_value() to see the value.
This is however NOT the way to go: if you do this, you will just get the value of the time at the moment the script is committed. If you want an updating time, you should follow these steps:
- Click the green + icon on your DoubleSourceScript, and add a Scalar property with name time
- In the User Properties list of the DoubleSourceScript, click the connection icon and connect it to the Time from the TimeSource node
- Replace your script code with:
context.output = context.node.time

Log in or register to post comments