Hey,
I was wondering if anybody can script (or knows of an existing script) to hotkey a toggle of the Trajectory button. I need the yellow motion trail to track arcs and movement but at times I need my mouse in a different location and simultaneously need the ability to quickly toggle it on and off.
If anybody can whip up a Python script for this or has any idea of an existing one I'd greatly appreciate the help. I have searched high and low for this and it doesn't seem to exist. Of course, in Maya, this would be no great task at all, but the MoBu community is significantly smaller in regards to tool and script creation.
Thanks in advance!
Kenny
I couldn't find any python command in MotionBuilder that would expose the Trajectories button directly. But scene components have a property for the trajectory visibility that can be changed with Python. So I whipped up a small script to do just that.
https://github.com/OlafHaag/MoBu-TrajectoriesToggle
In order to use it:
Since I don't know what you're doing while you would want to use the toggling, I just set it up to work on the currently selected objects.
Is that of any help?
Hey! Thank you so very much for taking the time to not just write back but help out! That's awesome. I am swamped today - and probably tomorrow - but I will check this as soon as possible and try to implement.
Again, sorry I can't immediately say if this is what I need or if I got it to work, but please know I greatly appreciate your time and your help.
Sincerely,
Kenny
In the meantime I added a second short script to disable the ShowTrajectory flags on all scene components.
You said you need to track some arcs. If you wanted to work on those arcs directly, you could use the motionpath workflow. Check it out, if you haven't already: Rigging Dojo Animation Tips from Twitter and GDC Tricks of the Trade
There's probably a way to change the visibility of the motionpaths via python as well.
It was still bugging me, that there isn't a more direct approach. I found a snippet that lets me find the widget in the gui, but I found no means to toggle it, or find out which function it actually calls. Maybe someone else has a better solution.
from PySide import QtCore, QtGui
# Find the main window.
parent = QtGui.QApplication.activeWindow()
while True:
parent_widget = parent.parentWidget()
if parent_widget:
parent = parent_widget
else:
break
main_win = parent
# Look thru all the QDockWidget to find the one with window title 'Viewer'.
for dock_widget in main_win.findChildren(QtGui.QDockWidget):
if dock_widget.windowTitle()=='Viewer':
viewer_ctrl_widget = dock_widget.widget()
break
# Find the trajectories widget.
for widget in viewer_ctrl_widget.findChildren(QtGui.QWidget):
if widget.accessibleName() == 'Trajectories':
trajectories_btn = widget
break
I'm keeping an eye on this thread as you muscle through all of this, and I have to say I'm amazed at your knowledge and at your interest in this.
I will take everything in on Monday, but right now I'm watching from 10k ft while I try to get some deliverables finished.
Thanks
I noticed that there's already a keyboard mapper script that comes with MotionBuilder which you can use to assign shortcuts:
from Qt.QtTest import QTest
QTest.mouseClick(widget, QtCore.Qt.LeftButton)
Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.