Create Folder Action help
1 1

6 posts in this topic

Hey all,

it's my first day with Ftrack and I find having the web UI create folders is the easiest (fastest) way to work for me. I've got the sample Create Folder Action working but I want it to pull the sequence name. By defualt it is set up for {project.name}/shots/{shot.name} as the base. What I want is {project.name}/sequences/{sequence.name}/shots/{shot.name}. I've updated the template python file but I need the variable to pass to it. What should I be adding to the python file to make this work?

 

Sorry for the noobish question but I've tried to add the sequence to the action and so far I haven't gotten it to work. 

 

Thanks!

Anthony

Share this post


Link to post
Share on other sites

Whoops, fixed it myself. In the actions python file I added

 

'sequence': {

                    'name': entity.getParent().get('name')
                }
 
and this returns the sequence.name to the template file. 

Share this post


Link to post
Share on other sites

Haven't used the action myself, but I would think you need to modify the data dictionary here; https://bitbucket.org/ftrack/ftrack-example-create-folders-action/src/db62048ee5fd8111cfcb25aa9e91898670a3c12c/source/create_folders_action.py?at=master&fileviewer=file-view-default#create_folders_action.py-89

 

This is not tested, but should give you an idea:

    def createFoldersFromEntity(self, entity):        '''Generate folder structure from *entity*.        Entity is assumed to be either a project, episode, sequence or shot.        '''        # Get all shots on the entity.        shots = entity.getChildren('Shot', depth=None)        # Loop over all shots and generate the data that should be passed to the        # templates.        for shot in shots:            data = {                'project': {                    'name': entity.getProject().get('name')                },                'shot': {                    'name': shot.get('name')                },                'sequence': {                    'name': shot.getParent().get('name')                }            }            # Pass the data to each template and create the folders unless they            # already exist.            for template in self.templates:                try:                    templatePath = template.format(data)                except lucidity.error.FormatError:                    print('Not enough information provided for this template.')                    continue                # Raise error if path is absolute since it will not be joined                # with prefix correctly.                if os.path.isabs(templatePath):                    raise ValueError('Template path should be relative.')                fullPath = os.path.join(self.prefix, templatePath)                try:                    os.makedirs(fullPath)                except OSError as error:                    if error.errno != errno.EEXIST:                        raise

Problem with this is that a parent of a shot could be other entities than a sequence, so to improve this you should probably test to see if the parent is a sequence.

Share this post


Link to post
Share on other sites

Haven't used the action myself, but I would think you need to modify the data dictionary here; https://bitbucket.org/ftrack/ftrack-example-create-folders-action/src/db62048ee5fd8111cfcb25aa9e91898670a3c12c/source/create_folders_action.py?at=master&fileviewer=file-view-default#create_folders_action.py-89

 

This is not tested, but should give you an idea:

    def createFoldersFromEntity(self, entity):        '''Generate folder structure from *entity*.        Entity is assumed to be either a project, episode, sequence or shot.        '''        # Get all shots on the entity.        shots = entity.getChildren('Shot', depth=None)        # Loop over all shots and generate the data that should be passed to the        # templates.        for shot in shots:            data = {                'project': {                    'name': entity.getProject().get('name')                },                'shot': {                    'name': shot.get('name')                },                'sequence': {                    'name': shot.getParent().get('name')                }            }            # Pass the data to each template and create the folders unless they            # already exist.            for template in self.templates:                try:                    templatePath = template.format(data)                except lucidity.error.FormatError:                    print('Not enough information provided for this template.')                    continue                # Raise error if path is absolute since it will not be joined                # with prefix correctly.                if os.path.isabs(templatePath):                    raise ValueError('Template path should be relative.')                fullPath = os.path.join(self.prefix, templatePath)                try:                    os.makedirs(fullPath)                except OSError as error:                    if error.errno != errno.EEXIST:                        raise

Problem with this is that a parent of a shot could be other entities than a sequence, so to improve this you should probably test to see if the parent is a sequence.

 

Thanks, I just realized what I did doesn't work for anything but the shot itself. I'll give yours a test run! Thanks!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
1 1