What is the proper use of sgtk_from_path()?

I’m trying to unregister folders from an event driven script.

I found an excellent example of something very similar to what I was trying to do here:

I’ve read the documentation for the Core Sgtk commands, but still don’t quite understand. In the above example in the call to “get_command” there is an argument passed called “tk”
My research indicates that “tk” is a API handle, and this API handle can be obtained in this manner:

tk = sgtk.sgtk_from_path("/studio/project_root")

What is the path in this line pointing to?

Hi @clint.thorne !

The path can point to any file or folder of the project that you want to create the handle for. So you can take “studio/project_root” quite literally as the base folder where your project lives in. If it is easier for you, you can also use sgtk.sgtk_from_entity("Project", 123) # with the correct project id.
Hope that helps :slightly_smiling_face:

That actually helps a great deal. @Fabian Thank you very much! sgtk_from_entity() seems much easier in this context…

1 Like