2
$\begingroup$

Is there a way to write python scripts that run at a given framerate while editing? For example, automatically move objects or do more interesting actions based on scene state or external events while editing (not while animation playing).

$\endgroup$
3
  • $\begingroup$ Are you trying to make a game? This sounds really niche and difficult not only to create but to utilize as well. Please clarify what you’re wanting to achieve, as I feel you may be trying to build an elevator in order to get the newspaper off the roof: There’s probably a ladder. $\endgroup$
    – TheLabCat
    Sep 9, 2022 at 14:21
  • 1
    $\begingroup$ No, not game. Just sometimes I need simple scripts, that for example keep symmetry between object. My last question here was how can I achieve metaballs to remain symmetical. Mirror modifier is not working for metaballs, and I don'r know any other trick to do this, but I can write a little script that can transform coordinates / copy properties of the edited metaball primitives. An other example is to use external devices (MIDI, VR, camera) to help editing. $\endgroup$
    – Denatural
    Sep 9, 2022 at 16:32
  • $\begingroup$ Oh, that sounds much more practical than I thought. I thought you wanted to edit the script and have it continuously run or something. $\endgroup$
    – TheLabCat
    Sep 9, 2022 at 21:15

1 Answer 1

4
$\begingroup$

Yes. You can use Application Timers (bpy.app.timers) to run scripts continuously repeating at some time interval.

You can also use Application Handlers (bpy.app.handlers) that are triggered when something happens like something is changed in your scene (bpy.app.handlers.depsgraph_update_post)

See the documentation for examples how they are used. It's quite clear and simple, but don't hesitate to ask if something is unclear.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .