In automating maya to do some custom job, the maya installation folder is usually needed. Though one can hard code this as, for example, path=”C:\\Program Files\\Autodesk\\Maya2014\\”, this is not the best way as users may not install maya to the default directory.
To extract the maya installation folder, one can use registry in windows platform, as shown below:
Given this fact, it is not very hard to get the maya root folder, either in Python or C#:
Line 1-4 are for test purposes, and when we run this code:
The output is:
The C# code is also similar and easy:
In this way, one can easily remove the hard-coded maya path with runtime checking. For brevity, only demo python code is offered, download it here.