- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I've been working on a Python script in Maya that adjusts the focal length of a camera in real-time to maintain the apparent size of a selected object, even when the camera or the time range changes.
I'm using `cmds.scriptJob()` to create script jobs for when the time, playback range, or the camera translation (`tx`, `ty`, `tz`) changes. Here's a chunk of my code:
```
scriptJobIds['timeChange'] = cmds.scriptJob(e=("timeChanged", maintainFocalLengthRatio), protected=True)
scriptJobIds['playbackRangeChange'] = cmds.scriptJob(e=("playbackRangeChanged", maintainFocalLengthRatio), protected=True)
scriptJobIds['txChange'] = cmds.scriptJob(attributeChange=(cam + ".tx", maintainFocalLengthRatio), protected=True)
scriptJobIds['tyChange'] = cmds.scriptJob(attributeChange=(cam + ".ty", maintainFocalLengthRatio), protected=True)
scriptJobIds['tzChange'] = cmds.scriptJob(attributeChange=(cam + ".tz", maintainFocalLengthRatio), protected=True)
```
The problem I'm facing is that these script jobs only seem to be triggered when I release the mouse button after making changes to either the time slider or the camera transformation. I want the script job to be executed continuously as the changes are happening (e.g., as the camera is being translated), not just when the mouse button is released.
Does anyone have any ideas for how I could get the script job to trigger in real-time as changes are made, instead of waiting for the mouse release?
Any help or guidance would be much appreciated.
Thanks!
Anson
Solved! Go to Solution.