Jump to content

Create Folder Action help


da_am

Recommended Posts

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

Link to comment
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.

Link to comment
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!!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...