0

How do I set the Published File Type for a publish?

Hi

I've been trying to find documentation on PublishedFileTypes entity, but I cant find anything that answers my questions. I'm currently making a publishing tool, and I'm not sure how to set the "published_file_type" field. I tried passing it a string, but it says "expected[hash, NilClass] data type(s)", So I'm not sure how I get the type from shotgun.

my line of code was:

pubType = "Rhino_Scene"
self.sg.update("PublishedFile", 
publishedFile['id'],
{'sg_hash' : sha1_hash,
'published_file_type' : pubType,
'tag_list' : [assType],
'sg_assembly_type':assType} )

 

In addition I'm not to sure what the importance publishedFileType is, where is it used, how are they created? I know I can create them in shotgun by going to the published file type page, but there were already a bunch there, some were duplicates and others that appear to have been created automatically, but I'm not sure.

I apologize if this is documented somewhere, I've been searching for "shotgun publishedFileTypes" and "shotgun published File Types".

4 comments

  • 0
    Avatar
    Permanently deleted user

    Did you create your original publish using the sgtk.util.register_publish() method? This method is a convenience method that tries to do most of the heavy lifting when it comes to creating a new publish, and we would recommend that you pass the file type at this stage if possible. You do this by passing an optional published_file_type argument (as a string), and this will associate that file type with the publish, and create the file type automatically in Shotgun if it does not already exist.

    If you wanted to do it manually afterwards, you need to do it slightly differently - the published file type is an entity in Shotgun, so you would need to create an entity link from your publish to the type. Something along these lines:

    pub_type_name = "Rhino_Scene"
    
    # 1. get the published file type object from Shotgun based on its name
    # This will return a dictionary on the form:
    # {'type': 'PublishedFileType', 'id': 123, 'name': 'Rhino_Scene'}
    sg_pub_type = self.sg.find_one("PublishedFileType", [["code", "is", pub_type_name]])
    
    # 2. Update your publish. Pass in the entity link dictionary 
    # you got in the previous call
    self.sg.update("PublishedFile", publishedFile["id"], { "published_file_type" : sg_pub_type, ... } )
    

     

  • 0
    Avatar
    Philip Scadding

    Of course, I should have known that, thanks.

    However, yes I have now put it in the publish, and it works. Is there a page or any documentation on what publishedfiletype is used for? and how I can avoid duplicates appearing in the list?

    Maybe its simple, but my confusion came about when I went to check out the publishedfiletypes for the first time. Most of the items in the list had duplicates, so i removed the duplicates and added one entry of my own. At that point list dramatically increased in size, not only returning some of the duplicates i had previously removed, but also adding in other ones which i knew nothing about. I have inherited the responsibility of this shotgun setup from someone else but, so perhaps its something they did. But some of those items weren't in the list when i arrived at the page, and creating an entry seemed to trigger the creation of other entries, so i wondered if the list was somehow dynamically created.

    Is it perhaps that I have some items in shotgun that already have a publishedfiletype and that creating an entry has also scanned my project and added in any other ones it needed?

  • 0
    Avatar
    Permanently deleted user

    > Is there a page or any documentation on what Published File Type is used for?

    Great question - check out the following forum post for details: https://support.shotgunsoftware.com/entries/95443368

    > How I can avoid duplicates appearing in the list?

    There should be no duplicates appearing in the list – toolkit's sgtk.util.register_publish() method checks to ensure that it doesn't create duplicate file type entries in Shotgun. It is however possible to manually create duplicate entries in the list - so if you execute sg.create("PublishedFileType", { "code": "Maya File" } ) eight times, you will end up with eight duplicate entries in the table. Hope this helps answer your question!

  • 0
    Avatar
    Philip Scadding

    Thanks for that link, that was useful, as I haven't been through the whole process yet.

    Thanks for the clarification of the duplicates, I'm not sure on how the duplicates I saw got created but hopefully everything should be fine going forwards.

Please sign in to leave a comment.