Getting maya path programmatically: Python and C# Code

17 Aug

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: -v

The output is:


The C# code is also similar and easy:

imageIn 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.

Happy coding!

Leave a comment

Posted by on August 17, 2013 in CAD, Python


Tags: , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: