Colorbleed / maya-capture-gui

GUI front-end for maya-capture
MIT License
76 stars 29 forks source link

Saving to empty directory field should result in relative file output #38

Closed BigRoy closed 7 years ago

BigRoy commented 7 years ago

Problem

Saving to a file with an empty directory field specified does not raise an error yet it also doesn't explicitly define where the output is going to end up. This should become more predictable, like default to the images folder. It is currently unclear whether it already does so. We should enforce that behavior, or error out.

Proposal

Whenever a relative path is not os.path.isabs(path) is given in the directory field it should be relative to something static and artist-friendly, I'd recommend the workspace's image folder.

aardschok commented 7 years ago
        # run playblast, copy file to given directory
        # get directory from inputs
        if not use_default:
            path = self.directory_path.text()
        else:
            # get directory from selected folder and given name
            path = lib.default_output() # << here we create a default output when none is returned
def default_output():
    """Generate outpath based on current scenename and set project"""

    workspace = cmds.workspace(query=True, rootDirectory=True)
    folder = cmds.workspace(fileRuleEntry="images")
    scene = get_current_scenename() or "playblast"

    # get current datetime
    timestamp = datetime.datetime.today()
    str_timestamp = timestamp.strftime("%Y-%m-%d_%H-%M-%S")
    filename = "{}_{}".format(scene, str_timestamp)

    return os.path.join(workspace, folder, filename)
BigRoy commented 7 years ago

The above code samples feel slightly out of context without a description of what you're trying to say with these examples. I'm assuming these are currently implemented code? Or are these proposals for new features?

The commented code does not solve the problem with relative paths, but does so only for a completely empty field.

I believe preserving a default for an empty field should be fine, but the empty field should return a default relative output so it resolves similar like any relative field as described here.

As such an empty field would resolve to a filename like scenename_timestamp which would finally get resolved using the default behavior for relative paths.