MotionBuilder Forum
Welcome to Autodesk’s MotionBuilder Forums. Share your knowledge, ask questions, and explore popular MotionBuilder topics.
abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 

MotionBuilder Trajectory (Motion Trail) Toggle

7 ANTWORTEN 7
Antworten
Nachricht 1 von 8
Anonymous
1179 Aufrufe, 7 Antworten

MotionBuilder Trajectory (Motion Trail) Toggle

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


 

7 ANTWORTEN 7
Nachricht 2 von 8
Anonymous
als Antwort auf: Anonymous

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:

  • Activate the Trajectories button in the top of the viewer window.
  • Click the small arrow to its right and disable 'Auto Selection'
  • Assigning a keyboard shortcut is easiest with Alex Widener's hotkey editor (forked and modified):
    • https://github.com/OlafHaag/MotionBuilderHotkeyEditor
    • Documentation: http://www.alexwidener.com/MotionBuilderHotkeyEditor/
    • After executing the hotkey editor script, which opens a window, go to File->Reset Hotkeys and choose the one that you typically use for interaction.
    • Then in the left pane scroll down until you find the action.global.script entries.
    • Assign a shortcut command to one of the scripts and in the right pane set the full path to the TrajectoriesToggle.py file for the according script.
    • You have to restart MotionBuilder after saving the changes.

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?

Nachricht 3 von 8
Anonymous
als Antwort auf: Anonymous

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

Nachricht 4 von 8
Anonymous
als Antwort auf: Anonymous

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.

Nachricht 5 von 8
Anonymous
als Antwort auf: Anonymous

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

 

Tags (3)
Nachricht 6 von 8
Anonymous
als Antwort auf: Anonymous

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 

Nachricht 7 von 8
Anonymous
als Antwort auf: Anonymous

I noticed that there's already a keyboard mapper script that comes with MotionBuilder which you can use to assign shortcuts:

  • In the Asset Browser navigate to Scripts->ComplexTools and there you'll find the ActionScriptMgr.py with which you can assign the scripts to these kinds of script-slots.
  • You'll also find the KeyboardMapper.py tool in which you can first select your configuration (3DS Max, Maya, etc.) and then scroll down to the script entries called action.global.script1 and so on to assign a keyboard shortcut to the slots you chose for the scripts.
Nachricht 8 von 8
sholmesUX96W
als Antwort auf: Anonymous

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.

In Foren veröffentlichen  

Autodesk Design & Make Report