How to load icons from Resource (RCC) file

How to load icons from Resource (RCC) file

atelierbump
Contributor Contributor
2,153 Views
5 Replies
Message 1 of 6

How to load icons from Resource (RCC) file

atelierbump
Contributor
Contributor

According to 3ds Max Help: (https://knowledge.autodesk.com/support/3ds-max/learn-explore/caas/CloudHelp/cloudhelp/2019/ENU/3DSMa...)

 

"Custom icons compiled into .rcc resource files placed in <3ds Max>\UI_ln\Icons\. Any .rcc file found in this location is loaded by 3ds Max on startup. These files must be compiled with the Qt resource compiler; see Qt RCC Compiler. You should include both light and dark versions to support both themes, and four resolutions to support high-DPI displays. As with baseline icons, these are referred to by <internal_path>/<base_name>. For more information on creating your own .rcc files, see the Using Multi-Res Icons in Max and Qt topic in the Developer's Guide."

 

But this doesn't seems to be the case. I've tryed put a compiled rcc file in all the possible locations, but it isn't loaded.

 

Anybody have an idea how to do this, or it is another broken feature?

 

Thanks.

 

0 Likes
Accepted solutions (1)
2,154 Views
5 Replies
Replies (5)
Message 2 of 6

drew_avis
Autodesk
Autodesk

Can you post your code and rcc file so we can try it?

 

I can load images from the default Max rcc files without issue.  You can quickly test loading icons from an rcc file using the "iconName:" parameter for bitmaps:

 

rollout test_icons "Testing icons" (
bitmap the_icon iconName:"AnimationLayer/AddAnimLayer"
)
createDialog test_icons

Drew



Drew Avis
Content Experience Designer
0 Likes
Message 3 of 6

atelierbump
Contributor
Contributor

You can use the ones available as an example in the SDK:

C:\Program Files\Autodesk\3ds Max 2020 SDK\maxsdk\howto\ui\qtIconsDemo

It should be accesed with "qtIconsDemo/Icons/Array" or "qtIconsDemo/Array".

I've tryed Copying the rcc file to:

UI_ln/

UI_ln/Icons

UI_ln/Icons/[Dark|Light]

UI_ln/IconsDark

None of this options gets the file loaded at startup, so I'm assumign it must be registered as a Qt resource via plugin, really cumberstone and unpractical to implement.

 

0 Likes
Message 4 of 6

drew_avis
Autodesk
Autodesk

Ok, I can reproduce this, and you're right, the icons are not loading from those locations.  I will dig into this a bit further and report back.

 

Drew



Drew Avis
Content Experience Designer
0 Likes
Message 5 of 6

drew_avis
Autodesk
Autodesk
Accepted solution

Ok, I have confirmed that Max is *not* actually automatically opening custom RCC files on startup.  I've opened a defect, and we will either change the loading behaviour, or update the documentation to reflect reality.

In the meantime, there is a work-around where you manually register your RCC file as a resource using PySide2/Qt.  Here's the sample using the QtIconsDemo RCC file (in this case the qtIconsDemo_Dark.rcc file placed in <max>\UI_ln\IconsDark:

pyside = Python.Import "PySide2"
rcc_path = GetDir #ui_ln
rcc_path = rcc_path + "IconsDark\\qtIconsDemo_Dark.rcc"
pyside.QtCore.QResource.registerResource rcc_path

rollout test_icons "Testing icons" (
bitmap the_icon iconName:":qtIconsDemo/Icons/Array"
)

createDialog test_icons

Note the relative path ":" symbol used to specify the iconName parameter.

 

Hope this helps,

Drew



Drew Avis
Content Experience Designer
0 Likes
Message 6 of 6

atelierbump
Contributor
Contributor

Just to note; this can't be used in a startup script. Icons/UI are loaded before scripts, it seems.

Resource files seemed like a better way to distribute and quickly load lots of icons. i.e.: between ribbon icons (dark & light), dark, light icons, plus BMP version, I end up with 810 PNG files on my plugin.

0 Likes