0

SGTK App assistance

I wrote a program in Python to copy entities between projects along with all available media.  It is currently called via the function:

copyItem(entity['type'],entity['id'],new_project)         (ex. copyItem('Asset',4835,'testshow'))

I used the blank app template referenced in the SGTK docs was able to get my custom app to register in the right click menu of the assets page in Chrome and launch a separate window when clicked. Here is where I need help.

- What is the python code to pull the entity type and entity id of the asset(s) that were selected prior to launching the app?  The template contains the code "self._app.context" which displays the string "Asset asetnamehere" but I have not been able to find further documentation to snag the data I need.  I browsed the Core and API docs but am coming up short.

- I would also like to have a drop down menu of projects the artist has access to in order to let them select a new project to copy the entity to.  Any examples of this?

I have built apps in Qt before but am having a bit of trouble transferring that knowledge into sgtk app development.

Thanks in advance for any pointers, examples, assistance you can provide.




20150722_11_56_21.png

3 条评论

  • 0
    Avatar
    Michael Oliver

    So I was able to figure out how to get the ID's and type based on this excellent thread: https://groups.google.com/a/shotgunsoftware.com/forum/#!topic/shotgun-dev/FquiS8BqLu8

    My app uses a shotgun API connection to find versions, upload files, etc..  When I run it in SGTK it throws an error:

    Exception: <type 'exceptions.ImportError'> - No module named shotgun_api3

    Is there a tank command to initiate an api connection? (ie a replacement for sg = Shotgun(SG_SHOTGUN_SERVER, SG_API_NAME, SG_API_KEY))

    I know I can force it by copying the shotgun libs into the app and importing them but that seems sloppy.

  • 0
    Avatar
    Rob Blau

    Hi Michael,

    There is a Shotgun connection object available via the app instance, so this should work:

    self._app.shotgun

    Does that get you what you want?
    You can also find out what is available via the Application interface here:
    https://support.shotgunsoftware.com/entries/95441127

  • 0
    Avatar
    Michael Oliver

    nice thanks Rob.  I just finished running a test with:

    from tank.util import shotgun
    sg = shotgun.get_sg_connection()  

    and that seems to do it for me. Cool stuff!  

    I basically blew away all of the template app stuff and put in my own code which seemed to simplify things for me.  

    Any examples of a GUI wrapper for a drop down box to select a target project?

     

请先登录再写评论。