Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

max2018: maxscript menu with icons

20 REPLIES 20
SOLVED
Reply
Message 1 of 21
Kreaction
5786 Views, 20 Replies

max2018: maxscript menu with icons

Hi,

In max 2014 I have a custom menu (in main toolbar) with internal tools that is defined at startup with maxscript.

Editing MaxActionItemsOverlay.xml file, with enhanced menus all my customs icons are there.

 

In max 2018, I can't get this to work. Via interface or maxscript or manually editing MaxActionItemsOverlay.xml, I can't get those icons appearing with my custom menu.

Default max UI template just after install, how can we ad some custom icons in our customs menus/menuitems ?

We heavily rely on such custom menus full of custom tools, and seeing a list of text isnt very efficient...

 

I do it with maxscript at startup (basically deleting menu and recreating it) due to often updates in these tools. I guess I could also save a menu file just for this menu, if there is a maxscript command to merge a menu into the main toolbar without destroying each one customization. But actually, I can't see how to it, even the python example doesn't have anything regarding icons, even in the sdk doc.

20 REPLIES 20
Message 2 of 21
drew.avis
in reply to: Kreaction

Hi Nicolas, since 3ds Max changed to using Qt for the main menu system in 2018, the way icons are loaded has changed as well.  For the macroScript approach, declare the icon using "iconName" (instead of "icon"), and specify a path under <3dsmax>\UI_ln\.  Here's a very simple example that uses one of the layer action icons, it relies on an existing "TestMenu" existing on the main menu bar:

 

macroScript demo_icon_menu category: "mxs docs" tooltip:"Demo Icon Menu"
IconName:"Layers/CreateNewLayer"
(
	print "I don't do anything yet..."
)

myTestMenu = menuMan.findMenu "TestMenu"
myAction = menuMan.createActionItem "demo_icon_menu" "mxs docs"
myTestMenu.addItem myAction (myTestMenu.numItems()+1)
menuMan.updateMenuBar()

If you prefer Python, you can access the main menu using MaxPlus.GetQMaxMainWindow().menuBar(), and use Pyside2 to add new QMenus and QActions.

 

 



Drew Avis
Content Experience Designer
Message 3 of 21
Kreaction
in reply to: drew.avis

Ah !!! Many thanks ! I saw IconName in some ui files but though it was for default menu only.

Will try both ways, if python works it would be a dream comes true 😉

 

Testing tomorrow, will let you know. Thanks again

Message 4 of 21
drew.avis
in reply to: Kreaction

Let me know how it goes.  The documentation needs some updating around this topic, with maybe a tutorial or blog post.  One other detail you need to know when using iconName:

- your icon should be located under UI_ln\Icons\[Dark|Light]\[yourpluginname] (that is, you need both Light and Dark versions to support both themes).

- to support high DPI monitors, a best practice is to include multiple resolutions at 24x24, 30x30, 36x36, 48x48, named 'iconname_24' (for 24x24 eg), and Max will select the best one for the display.

 



Drew Avis
Content Experience Designer
Message 5 of 21
Kreaction
in reply to: drew.avis

Yes, seems we can't use icons on a network share ? This is what I use in max2014. I have a maxscript file that load the menu and icons from a network path so I can just update it in one place for everyone.

 

With QAction and QIcon I should be able to set whatever path I want so I will look at this. Will try with triggered.connect to start external ms file (all my menu items are loading external (network) maxscript files. Should be easier with pyqt/pyside.

 

Do you know if we can put a py file into script/startup or plugins/ path so it is automatically executed at startup ? Or should we set a ms file as usual that load the py file ?

Message 6 of 21
Kreaction
in reply to: Kreaction

Ok, tried both, will go python way I guess.

 

Pyside menu:

Pros:

- Run fine, fast, fully customizable, support tearoff etc.

Cons:

- Menu doesn't appear in Customize UI / Menus

- If a user customize UI and change menus, the created menu disappear

- macroscripts are indeed not created, so no shortcuts or button in toolbars customization. For that, need a maxscript defining all entries as macroscripts

 

maxscript:

Pros:

- Old way support, define macroscripts

Cons:

- Can't set icon from another path than max/UL_ln

- Naming convension for icon files is... cumbersome!

 

 

Message 7 of 21
Kreaction
in reply to: Kreaction

Ok, all works nice now but one thing.

 

I have a python script that create the Qt menu with QActions, all works nice loading other ms or py script files.
I have also set a function that define macroscripts, so each entry is also accessible for toolbars, shortcuts and such.

 

There is just one annoying thing, the custom Qt menu is not registered in the main toolbar, so each time you go into CustomizeUI and change a menu, it disappear. I have set an entry with maxscript menu manager so users can re-generate it on the fly when needed, but it's not 'perfect' then.

 

Do you know a way to register this custom Qt menu so when max change/reload its maintoolbar, it does keep it ?

I have try garbagecollector class tricks, but does nothing.

Actually, I parent my Qmenus to the MaxPlus.GetQMaxMainWindow().menuBar(), should I parent to the MainWindow itself or something other ?

 

Thanks,

Nic

Message 8 of 21
drew.avis
in reply to: Kreaction

Hi Nic, I'm looking into this, I'll get back to you when I have an answer.



Drew Avis
Content Experience Designer
Message 9 of 21
Kreaction
in reply to: drew.avis

Thanks Drew.

I've seen three py files in the max2018 root folder, which seems to extends maxplus functions, maybe there is some related stuff. Didn't find anything in documentation anyway.

Message 10 of 21
drew.avis
in reply to: Kreaction

Hi Nic, so there is no way to make a menu persistent through the PySide approach, unfortunately.  In MaxPlus there is an ActionItem and MenuBuilder that provide a mechanism to create persistent menus, but they do not support icons (yet).  I've opened an issue to get this fixed.

 

Drew



Drew Avis
Content Experience Designer
Message 11 of 21
Kreaction
in reply to: drew.avis

Ok, thanks for clarification and reporting it.

I will have a look at directly editing menu file within python, but at least the maxscript menu item to reload the qt menu does the trick 😕

Customizing max UI become more and more cumbersome with each release, especially now that we can qt-ing lot of thing but still rely on menumanager ...

Message 12 of 21
Kreaction
in reply to: Kreaction

Not fixed in 2018.2 ...

Message 13 of 21
malcomarmstrong
in reply to: Kreaction

I too create a menu with items that I wish to have icons for, but the locations in the docs do not match what I have available. The menu loads fine, its just the icons.

 

I have .png files ranging from 16x16 up to 30x30 which are in a folder I created and named (mcr_script_file_16.png) in the manner described.

The locations I have available are:

 

C:\Program Files\Autodesk\3ds Max 2018\UI_ln\Icons

C:\Program Files\Autodesk\3ds Max 2018\UI_ln\IconsDark

C:\Program Files\Autodesk\3ds Max 2018\UI_ln\Resources\Dark\Icons

C:\Program Files\Autodesk\3ds Max 2018\UI_ln\Resources\Light\Icons

 

I placed a copy of the icons folder I made in each of these locations and when I loaded Max, the menu and entries were the, just not the icons. So where are they supposed to go in max 2018?

 

I do want to do it with PySide2 in 2019, but as there is no current support for icons, I will wait and see.

 

thanks

Message 14 of 21
Anonymous
in reply to: malcomarmstrong

Just bumping this as I really need an answer as to where I can put custom icons for the menu items I have created. As said above, the locations in the docs ARE NOT what is in the max folder. Its this sort of poor documentation that holds up development. With so many different places to go for "information", is this even the right forum? Get fed up of being told to place a post on the facebook page which then says to post here and then you get little to no response within a timeframe that is helpful. I copied icons into every folder, edited the macros, but still no icons show.

 

Anyone managed to do this in Max 2019?

Message 15 of 21
Anonymous
in reply to: Anonymous

So far, I have had to traverse through 6 different pages relating to menus and icons. It really is a joke to have to go back and forth on pages that have contradicting information. Do I use .bmp or .png? DO I add i to the bmp or png files. The 16x15 icon size is confusing.

 

Farcical. There are no real examples, just blase generic descriptions of places and functionality that does not exist.

Message 16 of 21
Anonymous
in reply to: Anonymous

This is the docs info which points to locations I do not have in max, so where am I supposed to put them? This menu system forms part of our startup, so would want icons elsewhere as different users log on and I dont want to have to copy the icons over and over into the appdata folder.

 

Icons
In 3ds Max 2017 a new method of loading icons was introduced to support high-DPI display scaling. The iconName: argument uses this method. This argument can specify an icon in one of these locations:

Baseline 3ds Max icons located in the compiled resource files IconsDark.rcc and IconsLight.rcc (for the dark and light themes, respectively), located under <3ds Max>\UI_ln\. See the Icon Reference Guide in the 3ds Max Developer's Guide for full paths to these icons. All icons are loaded by 3ds Max on startup, and are referred to by <internal_path>/<base_name>, where internal_path is the path to the icon inside the rcc file (see the Icon Reference) and the base_name is the icon name minus the _xx.png suffix, where _xx is the resolution of the icon. Typically 4 resolutions are supplied, and the system picks the best one for the current display resolution.
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.
PNG files from disk located in the <3ds Max>\UI_ln\Icons\Dark|Light\ - depending on the active theme (you need a copy of the icon in each location). For example, an icon with four resolutions (my_icon_24.png, my_icon_30.png, my_icon_36.png, my_icon.48.png) placed in both <3ds Max>\UI_ln\Icons\Dark\MyIcons\ and <3ds Max>\UI_ln\Icons\Light\MyIcons\ would be referred to in the macroScript as iconName: "MyIcons/my_icon".
The location pointed to by #userIcons, and the current theme name under #userIcons, a directory named "Light" or "Dark". See 3ds Max System Directories for information about #userIcons.

 

Its just nonsense and frustrating. 

Message 17 of 21
Anonymous
in reply to: Anonymous

Here is an image of the folders I have with icons upon icons in them. You can also see the macroscript icon definition as set out in one of the pages I had to go to to try and get this to work. I cant believe that it is so conveluted. Combined with the ambiguous and inaccurate documentation, what are people supposed to do?

It should be a simple case of putting icons in a folder for menus and toolbars to find.iconseverywhere.jpg

Message 18 of 21
mail
in reply to: Anonymous

Did you get this working? I'm also unable to get icons to appear in my custom toolbar.

Patrick Macdonald
Lighting TD
http://patrick.reformstudios.com

Developer of Mission Control , the spreadsheet editor for 3ds Max
http://mcontrol.reformstudios.com
Message 19 of 21
drew.avis
in reply to: mail

Hi Patrick, I believe the previous poster did get this working.  The key piece of information that was missing from the documentation, is that you need to create the "Light" and "Dark" directories yourself.

You need a path like this:

c:\[max install path]\UI_ln\Icons\Dark\[additional_path]\icon_name.png

Where you create the "Dark" path onward.  The "additional_path" is specified in code like this:

iconName: "additional_path/icon_name.png"

It can be the name of your plug-in, for example.

 

The documentation has been updated to reflect this.

Hope that helps,

Drew



Drew Avis
Content Experience Designer
Message 20 of 21
mail
in reply to: drew.avis

Thanks Drew, I'll try that out.
Patrick Macdonald
Lighting TD
http://patrick.reformstudios.com

Developer of Mission Control , the spreadsheet editor for 3ds Max
http://mcontrol.reformstudios.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report