PDM customize RMB menu with sub menus

Discuss SolidWorks PDM
User avatar
mp3-250
Posts: 630
Joined: Tue Sep 28, 2021 4:09 am
Answers: 20
Location: Japan
x 704
x 347

PDM customize RMB menu with sub menus

Unread post by mp3-250 »

I am lookIng for a way to reduce the size oF the RMB menu inside the vault.

I have already moved all our tasks inside a sub menu and I would like to move the vault add-ins in a "add-in" sub folder but I cannot find a way to do it. Any idea?

as reference:
https://www.cati.com/blog/configuring-m ... pdm-users/
User avatar
bnemec
Posts: 1944
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2548
x 1400

Re: PDM customize RMB menu with sub menus

Unread post by bnemec »

how many add-ins do you have?!

I haven't touched the right click menu since I messed it all up for the Design group. I opened the setting from the group settings dialog and it was completely blank. Thought, "that's strange, oh well, I'll add the item I came here to add and move on." Well, everyone in the group now had just that one item in the right click menu. Too me a while to rebuild it; I couldn't figure out how to just set back to default. Found out that if a user is in more than one group the settings GUI just throws up its hands and starts carte blanche. It was like biting into a moldy sandwich, so I haven't gone back to that fridge.
User avatar
JSculley
Posts: 646
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 9
x 878

Re: PDM customize RMB menu with sub menus

Unread post by JSculley »

mp3-250 wrote: Tue Nov 15, 2022 3:30 pm I am lookIng for a way to reduce the size oF the RMB menu inside the vault.

I have already moved all our tasks inside a sub menu and I would like to move the vault add-ins in a "add-in" sub folder but I cannot find a way to do it. Any idea?
The menu structure for commands added by an add-in is controlled in the source code of the add-in itself. In the IEdmAddin5::GetAddinInfo method, commands are added via AddCmd, like this:

Code: Select all

poCmdMgr.AddCmd(CMD_ADJUST, "Test Addin\\Submneu\\Adjust Properties", (int)(EdmMenuFlags.EdmMenu_OnlyInContextMenu | EdmMenuFlags.EdmMenu_OnlyFiles), "Adjust Custom Properties", "Adjust Custom Properties", -1, 0);
poCmdMgr.AddCmd(CMD_GET_REV_DATA, "Test Addin\\Submneu\\Get Revision Data", (int)(EdmMenuFlags.EdmMenu_OnlyInContextMenu | EdmMenuFlags.EdmMenu_OnlyFiles), "Get Revision Data", "Get Revision Data", -1, 0);
The menu structure is created by separating the menu names with a backslash character '\' which in the source code has to be escaped and is written '\\'. The above code gives a result like this:
image.png
If you have access to the add-in source code, change it there. If not, you can try disassembling the add-in(s), tweaking the strings and then re-assembling it. I just did that to add the third item shown here:
image.png
so it is possible, as long as the DLL file isn't obfuscated or encrypted or signed.
User avatar
mp3-250
Posts: 630
Joined: Tue Sep 28, 2021 4:09 am
Answers: 20
Location: Japan
x 704
x 347

Re: PDM customize RMB menu with sub menus

Unread post by mp3-250 »

@JSculley thank you very much!

Did you disassemble the dll with resource editor or do you have some other tool you could kindly suggest me?
User avatar
mp3-250
Posts: 630
Joined: Tue Sep 28, 2021 4:09 am
Answers: 20
Location: Japan
x 704
x 347

Re: PDM customize RMB menu with sub menus

Unread post by mp3-250 »

@bnemec
the problem is one "huge" add in the maker didn't care to organize in sub menus... I have requested an improvement in that regard.

my Understanding is the setting of the menu is a per user base, but you can overwrite ALL users from the setup window at the users root iirc.
User avatar
JSculley
Posts: 646
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 9
x 878

Re: PDM customize RMB menu with sub menus

Unread post by JSculley »

mp3-250 wrote: Thu Dec 22, 2022 3:55 am @JSculley thank you very much!

Did you disassemble the dll with resource editor or do you have some other tool you could kindly suggest me?
If you have Visual Studio, you can use ILDASM.EXE and ILASM.EXE to do the disassembly and reassembly. From a Visual Studio command prompt:
image.png
launch the ildasm tool and open the DLL file (make a backup copy in case you make a mistake or it doesn't work for some reason):
image.png
From the file menu, select Dump', use the default settings and save the file:
image.png
Depending on how the original DLL was built, you may end up with a single .il file, or a .il file and one or more .res files.
You can open the files with a text editor. You then search for the text of your menus, and you will find code like this for each menu item:
image.png
Change the first string to have the menu structure you want, using double backslashes to separate them:
image.png
Once you have changed them all, you use ILASM.EXE from the developer command prompt to reassemble the code.

Code: Select all

E:\SOLIDWORKS Files>ilasm /DLL CustomPropertyCleaner.il

===========================================================
Microsoft (R) .NET Framework IL Assembler.  Version 4.8.3761.0
Copyright (c) Microsoft Corporation.  All rights reserved.
Assembling 'CustomPropertyCleaner.il'  to DLL --> 'CustomPropertyCleaner.dll'
Source file is UTF-8
...
...
...
...
Class 89
Method Implementations (total): 2
Resolving local member refs: 0 -> 0 defs, 0 refs, 0 unresolved
Writing PE file
Operation completed successfully

E:\SOLIDWORKS Files>
If there were one or more .res files, you have to include them as well, so the command would be:

Code: Select all

E:\SOLIDWORKS Files>ilasm /DLL /RES=res1.res /RES=res2.res /CustomPropertyCleaner.il
Once this is done, you should have a new DLL file. The tricky part is getting the new DLL into the system and it depends on how your add-in was originally installed. If the vendor just gave you a DLL file and instructions, you should be able to remove the existing add-in DLL and reload the modified DLL using the vendor's instructions.

If it works, you should see your new menu structure, like this:
image.png
Also, this will only work for .NET DLL files. If the add-in was written in plain C++, none of this will work. All my tests were done using a C# DLL.
User avatar
mp3-250
Posts: 630
Joined: Tue Sep 28, 2021 4:09 am
Answers: 20
Location: Japan
x 704
x 347

Re: PDM customize RMB menu with sub menus

Unread post by mp3-250 »

@JSculley thank you for the explaination, but the add-in I got is signed and encrypted apparently.
Post Reply