Page 1 of 1

Access to Start / End Frame in Expression

Unread postPosted: Tue Jul 16, 2019 4:38 pm
by briansilva
Hello!

I'm a bit of a newbie, so I apologise if this is naive -- but is there a way to access the project/timeline Start and End frames in an SeExpr expression? For example the values in the project Preferences and seen in the timeline widget?

Thank you!

Re: Access to Start / End Frame in Expression

Unread postPosted: Tue Jul 16, 2019 5:03 pm
by dcourtois
Hi,

It's not so naive, and unfortunately it's not possible for the moment. Would you mind telling why you need that ? (there might be some workarounds)

Re: Access to Start / End Frame in Expression

Unread postPosted: Tue Jul 23, 2019 10:54 am
by briansilva
I'd like to write an expression that rotates my model 360 degrees across whatever I have the timeline set to. I can do this by hand of course, but I'd like to create something reusable.

More generally, this would be handy for managing a scene in a shot context. I can imagine referencing this in the First/Last Frame parameters of an Image, adjusting timings for Alembic files, etc. I know I could do this through shell env variables but on production I've very often found use for constructing expressions from the timeline.

Re: Access to Start / End Frame in Expression

Unread postPosted: Wed Jul 24, 2019 11:13 am
by dcourtois
Ok, understood.

A partial solution is to use the variable editor and create a `start_frame` and `end_frame` variables: then you'll be able to use their values directly in any expressions.
Note that it will even work if you reference another project: the expressions of the referenced project will use the `start_frame` value of the current one.

Edit: if you need to start and end frame values to stay local to a project even if it's referenced in another one with different start and end frame values, you can put the values in custom attributes of a locator somewhere in the scene, and get the values using get_double("project://path/to/the/locator.start_frame") ...

To summarize: you can create "global" control variables in 2 ways:
- in the variable editor: those are real globals. They apply to every expression, no matter where the expression comes from.
- create a settings object with custom attributes, and use get_*() methods to access them. When a project using this is referenced in another one, the expression will stay the same, even if the "parent" project has its own settings object with different values.

Regards,
Damien.