I am writing tools in Maya and trying to retrieve information from the Shotgun API. But I don't see a way to get the current context or entity in Maya. The Work Area Info works fine and showing me the current project and shot so I wonder how that works. I have looked through the API and there are functions like context_from_path(),context_from_entity(), context.entity. But how do I get the path in the first place?
It would be easy to store the work area path as environment variable when maya is launching or use the current file path as the path. But there are exceptions which may make these methods unreliable. So I am wondering what is the recommended method to achieve this.
This question seems very fundamental but I am unable to find any information on this forum. I apologize if this has been asked before and please point me to the forum page. Thank you.