How to access plugin icons from cpp?

How to access plugin icons from cpp?

Anonymous
Not applicable
1,139 Views
4 Replies
Message 1 of 5

How to access plugin icons from cpp?

Anonymous
Not applicable

Hi,

I am developping a maya plugin in cpp and store it in the standard structure <resource path>/plug-ins and pictures into <resource path>/icons.

 

However when I want to display a picture (qt/cpp development) and enter just the picture name, the picture is not displayed. I there need to use an absolute path.

But as I plan to put this plugin on different computers, how can I programmatically know when the pictures are located ?

 

Thanks.

0 Likes
Accepted solutions (1)
1,140 Views
4 Replies
Replies (4)
Message 2 of 5

RFlannery1
Collaborator
Collaborator
Accepted solution

One option to consider is to package your plugin into a "module".  It has a pre-defined folder structure.  If you use this method, you will be able to determine the path of the icons relative to the .mll file.  This becomes an even better option if you also have MEL scripts that go along with the plug-in.

Maya documentation: Distributing Multi-File Modules

 

Another option is to embed the icons into a resource file.  I'm not sure exactly how this works, since I haven't done it before, but here is a page describing the general idea: The Qt Resource System

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

You can query default location of user images and icons using MEL command internalVar

 

MString path;
MGlobal::executeCommand( "internalVar -userBitmapsDir",  path);



0 Likes
Message 4 of 5

Anonymous
Not applicable

Unfortunately this mel command gives me the following path:

/Users/<username>/Library/Preferences/Autodesk/maya/2015-x64/prefs/icons/

 

When I was expecting the path where the current plugin is located.

0 Likes
Message 5 of 5

Anonymous
Not applicable
Worked like a charm, thanks.
Used the following cpp command:
MString path;
MGlobal::executeCommand("getModulePath -moduleName MayaTest", path);
0 Likes