Drop Down Menu

On 19/03/2014 at 12:48, xxxxxxxx wrote:

How would you add a python plugin to Cinemas top menu? Is it possible to make a drop down for multiple custom plugins?

On 20/03/2014 at 01:37, xxxxxxxx wrote:

Take a look in the Python docs under "Plugin structure" -> "Enhancing the main menu". Just place the example in your pyp, PluginMessage is a function called automatically by C4D.

Cheers, s_rath

On 23/03/2014 at 09:14, xxxxxxxx wrote:

Is this a new feature that was added recently Sebastien?
The example in the docs isn't working for me in R13.

C4DPL_COMMANDLINEARGS: works
C4DPL_BUILDMENU:  Does not work

  
#The main.cpp file in C++ is where plugins get registered and other things get loaded when C4D starts up  
#In Python we can also write some of the C++ functions used in the main.cpp file to do things when C4D opens  
#We can also add new menus to C4D here  
#Note: If menus are modified from outside C4DPL_BUILDMENU message, gui.UpdateMenus() needs to be called.  
  
import c4d  
import sys,os  
from c4d import gui,plugins  
  
#This is a custom method that will insert a new menu into C4D when it starts up  
def EnhanceMainMenu() :  
  mainMenu = gui.GetMenuResource("M_EDITOR")                    # Get main menu resource  
  pluginsMenu = gui.SearchPluginMenuResource()                  # Get 'Plugins' main menu resource  
  
  menu = c4d.BaseContainer()                                    # Create a container to hold a new menu information  
  menu.InsData(c4d.MENURESOURCE_SUBTITLE, "Scott")              # Set the name of the menu  
  menu.InsData(c4d.MENURESOURCE_COMMAND, "New Scene")           # Add registered default command 'New Scene' to the menu  
  menu.InsData(c4d.MENURESOURCE_SEPERATOR, True)                # Add a separator  
  menu.InsData(c4d.MENURESOURCE_COMMAND, PLUGIN_CMD_5159)       # Add command 'Cube' with ID 5159 to the menu  
  
  submenu = c4d.BaseContainer()                                 # Create a new submenu container  
  submenu.InsData(c4d.MENURESOURCE_SUBTITLE, "Submenu")         # This is a submenu  
  submenu.InsData(c4d.MENURESOURCE_COMMAND, "IDM_SAVE")         # Add registered default command 'Save' to the menu  
  
  menu.InsData(c4d.MENURESOURCE_SUBMENU, submenu)               # Add the submenu  
  
  if pluginsMenu:  
      #Insert menu after 'Plugins' menu  
      mainMenu.InsDataAfter(c4d.MENURESOURCE_STRING, menu, pluginsMenu)  
  else:  
      #Insert menu after the last existing menu ('Plugins' menu was not found)  
      mainMenu.InsData(c4d.MENURESOURCE_STRING, menu)  
  
  
  
def PluginMessage(id, data) :  
  
  #The console can be accessed upon start up with this method  
  if id==c4d.C4DPL_COMMANDLINEARGS:  
      print sys.argv #print arguments  
      print "Hello World"   
      return True  
  
  return False  #<-- Notice that the method itself must return False(Not True)  
    
  #This is where we check the build status of the menus. And also inserts any new ones  
  if id==c4d.C4DPL_BUILDMENU:  
      EnhanceMainMenu()

-ScottA

On 23/03/2014 at 20:24, xxxxxxxx wrote:

Hi Scott,

1. Wrap the PLUGIN_CMD_5159 in quotes
2. remove the return statement from the PluginMessage function

-Niklas

On 24/03/2014 at 08:00, xxxxxxxx wrote:

Thanks Niklas.

The Enhance The Main Menu example in the docs doesn't have a return False line in it. So looking at the CL example directly above it. I thought the CL method needed to return False.
But now I see that it's the PluginMessage() method that's the one that needs to return False.

-ScottA