Hello good day I coded all may code in the Shotgun python console and would like to move it over two maya now i got Shotgun Desktop installed and going
I did realize if i start maya with shotgun i can do (import sgtk)
But i would like to do the command imports without doing this so even if someone opens maya without shotgun that this script can still work please it would be appreciated
So basically i want all the commands that work in the Shotgun python console to work in maya aswel please
Hi @WakaKrazyBunBun, I’ve moved this post to the “Pipeline Integrations” category so that it will get seen by some of our Pipeline/Toolkit folks. Just letting you know!
Hello – you’ll want to add the path to Toolkit Core API to your sys.path in Python; then you should be able to import sgtk. If you have a centralized Toolkit pipeline configuration, by default it should have its own copy of the Core API in the install/core/ directory, and within that, we want to get to the python/ directory. So, in my case, my pipeline config is in /sgtk/software/shotgun/goats, so the following works:
This will allow your code to run, but depending on what you’re doing in your script with the Toolkit API, it may require Toolkit’s tk-maya engine to be running and/or for you to have a Toolkit context.
To have this path added to your sys.path every time Maya is launched, you can add it to the PYTHONPATH environment variable via the Maya.env file, or add the above lines of Python to Maya’s user_setup.py file. You can see the sections on Initializing the Maya Environment in and for Python and Adding Items to your Python Path in the Python in Maya page from Maya’s documentation.
So i dont completely understand how to do this so i installed Shotgun desktop and i esentially just want two grab from where it grabs it code for shotgun
So where and how would i path that and import that
Hi @WakaKrazyBunBun, I’ve messaged you privately with a link to some documentation that is in the works, it may help answer some of your questions.
Let us know if not.
i have imported and set the sys.path now and everything and then i am folowing another vedio that says to get sg in u do it like that but i am getting a context error
o btw that line of code works if i open the project with your software but if i open maya on the side it dosent seem to be working
The engine = sgtk.platform.current_engine() will only return an engine, if an engine is running.
If you launched Maya without the Shotgun integration, and then imported sgtk, and then tried to run that, there wouldn’t be an engine present.
If you are using a centralized config, then you can use the sgtk API without bootstrapping the whole configuration. You would usually use one of the factory methods to create your self an Sgtk instance, and access the Shotgun connection through there. Something like:
is this the project id or can it be 1234 sorry very dumb question but just wanne make sure because if this is the project id i will need to start up the Api to set it up ass i understand to get the project id 1st
If you look at the factory methods documentation it details the arguments required for the method, but yes, in this case, the 1234 was representing the project ID.