0

python return active source in session manager?

Hi,

I am working on a Maya version of the nuketools that you have with creating check points and restoring checkpoints. I have looked through the rvNuke_mode, rvNuke_process and maya_tools. I am a python guy myself and I am a little bit "not wanting" to get too deep into mu scripting. No offience...  Could someone point me in the right direction to simply return the active source in the session manager. In Python...

When you double click the source it is active and recieve's a check.I see in maya_tools it adds a property then when you say do something it returns the source with the corresponding property.

thx for you help,
David

1 条评论

  • 0
    Avatar
    Alan Trombla

    Hi David,

    There's one subtle point here in that the SessionManager there is (1) traditional selection (highlighting), where one, none, or many views may be selected and (2) the "current view", IE the thing you're looking at.  (2) is available in python through the rv.commands.viewNode() command,  but the state for (1) is held by the SessionManager itself, so you have to ask it (and it's written in mu).  From python, you can use the rv.runtime.eval backdoor though:

    rv.runtime.eval ('{ let m = session_manager.theMode(); if (m neq nil && m._active) then m.selectedNodes() else string[](); }', ["session_manager", "commands"])

    This will return something like 'string[] { "sourceGroup000000" }'  where 'sourceGroup000000' is the name of the view selected in the session manager.

    Hope that helps,

    Alan

请先登录再写评论。