How to: Plugin parent folder on extensions menu
-
Hello!
I want to ask if someone knows how to add a "parent" plugin folder into the Extensions menu like this example:
I saw the CV-ArtSmart .pyp but I didn't understand how to put that parent and all the plugins inside of it.
I discovered if I create one folder on the plugins folder, and them each children plugin as folders it will appears as I want but that's not the most efficient way to do it if the plugins will share data that I need to duplicate on each sub folder, what's why I'm trying to get a solution similar to this example.
Thanks!
-
Hi @cybor09,
Thanks for reaching out to us. You can achieve such grouping by simply registering your plugins in a regular way (please find a code snippet below). It's a default behavior that organizes all your plugins under a folder named after your plugin folder.
Let me know if you have any further questions.
Cheers,
Ilia*.pyp file content:
import c4d, os from c4d import gui PLUGIN1_ID = 999121031 PLUGIN2_ID = 999121032 PLUGIN3_ID = 999121033 class PC_12103_1(c4d.plugins.CommandData): def Execute(self, doc): print("Execute the 1st command") return True class PC_12103_2(c4d.plugins.CommandData): def Execute(self, doc): print("Execute the 2nd command") return True class PC_12103_3(c4d.plugins.CommandData): def Execute(self, doc): print("Execute the 3rd command") return True def loadIconBMP(iconName: str) -> c4d.bitmaps.BaseBitmap: directory, _ = os.path.split(__file__) fn = os.path.join(directory, "res", iconName) # Creates a BaseBitmap bmp = c4d.bitmaps.BaseBitmap() if bmp is None: raise MemoryError("Failed to create a BaseBitmap.") # Init the BaseBitmap with the icon if bmp.InitWith(fn)[0] != c4d.IMAGERESULT_OK: raise MemoryError("Failed to initialize the BaseBitmap.") return bmp if __name__ == "__main__": c4d.plugins.RegisterCommandPlugin(PLUGIN1_ID, "1st Cmd", 0, loadIconBMP("icon1.tif"), "", PC_12103_1()) c4d.plugins.RegisterCommandPlugin(PLUGIN2_ID, "2nd Cmd", 0, loadIconBMP("icon2.png"), "", PC_12103_2()) c4d.plugins.RegisterCommandPlugin(PLUGIN3_ID, "3rd Cmd", 0, loadIconBMP("icon3.png"), "", PC_12103_3())
Plugin folder structure:
-
That's great, thanks a lot for your answer @i_mazlov , may I ask if is possible to add also an Icon to the parent folder? and if is possible to add subfolders too like on the scripts?
Thanks again.
-
Hi @cybor09,
You can group your plugins the way you described in your thread-starting posting. Another option is to build your custom menu using c4d.C4DPL_BUILDMENU.
Adding icon to the parent folder doesn't seem to be possible unless using custom menu approach that I mentioned above.
Let me know if you have any further questions.
Cheers,
Ilia -
Hello @cybor09 ,
without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly.
Thank you for your understanding,
Maxon SDK Group