Update Maya fileDialog's start-dir when task changed#340
Conversation
|
One thing that I am not sure of is, should we reset back to previous context when Avalon says new context's workspace not exists ? To me, I think it should, and the workspace check should implement in What do you think ? |
We have on task changed callback that creates the workspace if it does not exist yet (in Colorbleed config). So for us it's fine if it does not exist yet. :) Does that help? Could port that somehow to core? (Thinking of it... that might even be in our core repo, but I am not sure) |
|
Oh I see~ Then I think I will remove the prompt dialog in this PR.
I think we can ship that logic to core in next PR, take Maya for example: # avalon/pipeline.py
...
def on_task_changed(*args):
"""Wrapped function of app initialize and maya's on task changed
(copied from Colorbleed config)
"""
# Inputs (from the switched session and running app)
session = avalon.Session.copy()
app_name = os.environ["AVALON_APP_NAME"]
# Find the application definition
app_definition = pipeline.lib.get_application(app_name)
App = type("app_%s" % app_name,
(avalon.Application,),
{"config": app_definition.copy()})
# Initialize within the new session's environment
app = App()
env = app.environ(session)
app.initialize(env)# avalon/maya/pipeline.py
from .. import pipeline
...
def _on_task_changed(*args):
pipeline.on_task_changed()
# Do something app specific action..
_update_menu_task_label()
workdir = api.Session["AVALON_WORKDIR"]
if os.path.exists(workdir):
_set_project()
...Then
I'll go there and sniff around for good stuff :D |
| # Update file dialog starting dir | ||
| # (NOTE) using `mel.eval` because this `workspace` Python cmd failed | ||
| # in Maya 2017 + | ||
| frule_scene = mel.eval("workspace -q -fileRuleEntry \"scene\"") |
There was a problem hiding this comment.
I think in Python it somehow is:
import maya.cmds as cmds
cmds.workspace(fileRuleEntry="scene")Thus without the query. I think it was different in older versions of Maya where it would actually need the query flag, but haven't tested it.
Thanks for the comment here.
There was a problem hiding this comment.
So this is the command that fit to all version...
I gave it a test run, and all passed
I will change to this cmd, much simpler.
Sure do! ;) This Maya browser fix is already really good - nice work! |
|
Thanks @BigRoy :) |
|
The warning message might still be conflicting with our "solution" to ensuring the workspace actually exists in our config. Because I think ours will do it directly after this callback - so the user gets warned for no apparent reason? Can we avoid the pop-up but just have it log a sensical message? |
On the contrary, I believe it's initializing workspace before this callback, cause I just stealing your "solutions". :P But since you have mentioned, I will remove that for good, I now aware it's a bit redundant for the future development heading. |
|
Done. I leave the logger warning massage as is, should be fine right ? |
|
Sure is! Thanks again. Feel free to merge! |
|
Merging this. Thanks @BigRoy :) |
…n_library_loader
Before:
FileDialog's start-dir will stay at previous opened folder path after task changed.
After:
Now it will point to the scenes folder of that task after task changed.
And, this is not recorded in GIF, but it will prompt a confirm dialog to notify artist to use Launcher, due to the workspace of that task is un-initialized (folder not exists).