Jump to content

Jason Evanko

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by Jason Evanko

  1. 9 hours ago, Mattias Seebergs said:

    Not sure I follow with the 'shots = None' variable, shots do have a `children` property if that helps? If you could share a minimal example and explain a bit more what you are aiming to do, then I'd be happy to help further.

    for sure! Heres a snippet of the "launch" function but I might break it up into multiple functions so its cleaner. 

     

     

             def launch(self, event):
           
            selection = event['data']['selection']
            path = 'C:\\project\\test\\'
            if len(selection) == 1:
                entity = selection[0]
                task = None
                shot = None
                projects = None
                try:
                    projects = self.session.query(
                        f'Project where id is \"{entity["entityId"]}\"'
                    ).one()
                    task = self.session.query(
                        f'Task where id is \"{entity["entityId"]}\"'
                    ).one()
                    

                     os.makedirs(path + projects['name'] + shot['name'])
                except Exception as e:
                    return {
                        'success': False,
                        'message': 'An error occurred.'
                    }
                    
                if task:
                    return {
                        'success': True,
                        'message': f'Shot name: {shot["name"]}'
                    }
            return False

     

     

     

    essentially what I'm trying to have it do here is once I select a shot that has a task in it it will create a folder with the name of that shot and task inside of it. Eventually I want to be able to select the project as a whole and have it create a folder for each shot that has a task assigned to it but one step at a time haha

  2. @Mattias Seebergsonce I removed the session and entities arguments that worked perfectly! Thanks so much for the quick answer there! I do have a follow up though, I'm essentially trying to make a little tool that will loop through every shot that has a task on it to create a folder. I tried changing that 'Task where id is' is section to 'Shot...' and adding a shot = None variable however that doesn't quite seem to work. do I need to set the selection to the show before getting the context of the shots since right now its going all the way down to the task level? Or should it be able to back track to the shot level with the task selected? 

     

    Thanks again!

  3. Hey all! I'm trying to write a quick little action that would print out the selected task name at the top of the page when launched and I'm having some trouble getting that variable and was wondering how I would get that specific one? I'm able to loop through all active projects and get that variable with self.sessions and a for loop with projects but I can't seem to isolate just the active project or any of the tasks inside that project. 

     

     

    Thanks so much!

     

×
×
  • Create New...