da_am 1 Posted November 11, 2015 Report Share Posted November 11, 2015 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 post Share on other sites
da_am 1 Posted November 11, 2015 Author Report Share Posted November 11, 2015 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. Link to post Share on other sites
Solution tokejepsen 55 Posted November 11, 2015 Solution Report Share Posted November 11, 2015 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: raiseProblem 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. Carl Claesson 1 Link to post Share on other sites
da_am 1 Posted November 11, 2015 Author Report Share Posted November 11, 2015 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: raiseProblem 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 post Share on other sites
da_am 1 Posted November 11, 2015 Author Report Share Posted November 11, 2015 That worked perfectly! Thanks again! Carl Claesson 1 Link to post Share on other sites
tokejepsen 55 Posted November 11, 2015 Report Share Posted November 11, 2015 Great? Carl Claesson 1 Link to post Share on other sites
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now