Skip to content

Update Maya fileDialog's start-dir when task changed#340

Merged
davidlatwe merged 4 commits into
getavalon:masterfrom
davidlatwe:maya-set-workdir
Sep 20, 2018
Merged

Update Maya fileDialog's start-dir when task changed#340
davidlatwe merged 4 commits into
getavalon:masterfrom
davidlatwe:maya-set-workdir

Conversation

@davidlatwe
Copy link
Copy Markdown
Collaborator

Before:

task_before

FileDialog's start-dir will stay at previous opened folder path after task changed.

After:

task_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).

@davidlatwe davidlatwe requested a review from BigRoy September 18, 2018 06:16
@davidlatwe
Copy link
Copy Markdown
Collaborator Author

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 avalon.api.update_current_task, right before emitting taskChanged, raise error if not exists, and the prompt dialog should be implement in context manager.

What do you think ?

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Sep 18, 2018

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 ?

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)

@davidlatwe
Copy link
Copy Markdown
Collaborator Author

Oh I see~
I found the implementation of workspace initialization in Colorbleed config, you use avalon.Application to initialize it, which making more sense ! Nice :P

Then I think I will remove the prompt dialog in this PR.

Could port that somehow to core?

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 avalon.maya.install() will register this chained callback for us !

(Thinking of it... that might even be in our core repo, but I am not sure)

I'll go there and sniff around for good stuff :D

Comment thread avalon/maya/pipeline.py Outdated
# 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\"")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Sep 18, 2018

I'll go there and sniff around for good stuff :D

Sure do! ;)

This Maya browser fix is already really good - nice work!

@davidlatwe
Copy link
Copy Markdown
Collaborator Author

Thanks @BigRoy :)
I'll leave it as is and merge in next couple day if no further objections.

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Sep 18, 2018

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?

@davidlatwe
Copy link
Copy Markdown
Collaborator Author

Because I think ours will do it directly after this callback

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.

@davidlatwe
Copy link
Copy Markdown
Collaborator Author

Done. I leave the logger warning massage as is, should be fine right ?

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Sep 19, 2018

Sure is! Thanks again. Feel free to merge!

@davidlatwe
Copy link
Copy Markdown
Collaborator Author

Merging this. Thanks @BigRoy :)

@davidlatwe davidlatwe merged commit cca39bc into getavalon:master Sep 20, 2018
@davidlatwe davidlatwe deleted the maya-set-workdir branch September 20, 2018 10:45
tokejepsen pushed a commit to bumpybox/core that referenced this pull request Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants