Implementing saveas_prefer_version_up in tk-multi-workfiles2

My goal is to make the Save dialog in Houdini autofill the Name box, because right now our artists have to manually fill in the box with the same name every time to version up. Not only is that tedious, it just leaves a lot of room for errors and confusion so I’m trying to fix it.

I read through the documentation and found “saveas_prefer_version_up”, which sounds like exactly what I want, but I can’t seem to get it to work. I also can’t figure out how it’s working in Maya and Nuke, which already exhibits the correct behavior but don’t have the setting mentioned anywhere in their sections of the .yml…

I’ve tried putting it into my config’s tk-multi-workfiles2 for testing under the asset_step and shot_step (and even our project and global settings), but nothing changes.

Any thoughts on what I’m doing wrong?

Thanks.

2 Likes

Hello –

A couple thoughts here:

  • You can eliminate the Name field in the File Save dialog by removing the {name} key from your houdini_shot_work, houdini_asset_work, etc. templates in config/core/templates.yml. {name} is a special key, which represents what the user inputs into the Name field in the dialog. But if you don’t have that key in your templates, the dialog won’t have that field at all, and file naming will be fully automated.
  • The above seems like the right solution to me, but if you want to go with the saveas_prefer_version_up setting, can you confirm (perhaps by logging its value?) the value of the setting at file save time, to confirm that you’ve set it in the right place?
2 Likes

If you do want to use the {name} key you can use a core hook to provide a better default.
I usually want the entity name filled in by default.

I think I got this off the old google group. I have a couple of these for different engines.

In the workfiles config add
saveas_default_name: hook:workfiles_saveas_name:entity_name

add this as {config}/core/hooks/workfiles_saveas_name.py

from tank import Hook
import os


class ProceduralNameFromContext(Hook):
    """

    """
    def execute(self, setting, bundle_obj, extra_params, **kwargs):
        """
        Get a name from the current context

        :param setting: The name of the setting for which we are evaluating
                        In our example above, it would be template_snapshot.

        :param bundle_obj: The app, engine or framework object that the setting
                           is associated with.

        :param extra_params: List of options passed from the setting. If the settings
                             string is "hook:hook_name:foo:bar", extra_params would
                             be ['foo', 'bar']

        returns: needs to return the name of the file, as a string
        """

        resolve_mode = extra_params[0]
        # the mode is basically the parameter passed from the config value - in this case task_name
        try:
            if resolve_mode == "task_name":
                ctx_task = bundle_obj.context.task
                return ctx_task["name"] if ctx_task else "scene"
            elif resolve_mode == "entity_name":
                ctx_entity = bundle_obj.context.entity
                return ctx_entity["name"] if ctx_entity else "scene"
            else:
                return "scene"
        except:
            return 'scene'
3 Likes

Thank you both for your suggestions.

It turns out the answer was that someone had modified the scene_operation.py hook in such a way that it was interfering with the setting.

Reverting to the default hook fixed the issue.

1 Like