Jump to content

Hexbob

Regular Member
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Noble Beginner

Profile Information

  • First Name
    Sam
  • Last Name
    Walker
  • C4D Version
    R20.026 Studio
  1. I can indeed, that explains why I couldn't access the site for a few minutes!
  2. Brilliant, thanks for the speedy reply and heads-up, @Igor!
  3. I am writing a small script that will serve as a quick-access popup dialog for certain functions in C4D, using Python (relevant documentation). These functions include adding primitives, etc, and the popup itself is imported as a user script and bound to a keyboard shortcut for ease-of-use. As the script is growing I am wanting to add a method to quickly add tags to selected objects when an option from the popup is selected, however I am having trouble executing the commands/functions necessary from within the script. Here is a stripped back example of the script: import c4d from c4d import gui # Define Menu Item IDs IDM_MENU_TITLE = c4d.FIRST_POPUP_ID IDM_MENU1 = c4d.FIRST_POPUP_ID+1 IDM_DROPDOWN1 = c4d.FIRST_POPUP_ID+4 # Menu Creation menu = c4d.BaseContainer() menu.InsData(IDM_MENU_TITLE, 'Popup Dialog &d&') menu.InsData(0,'') add_tag_to_objs = c4d.BaseContainer() add_tag_to_objs.InsData(1, 'Add Protection Tag') # This tag is arbitrary dropdown_menu = c4d.BaseContainer() dropdown_menu.InsData(1, 'Add Objects/Mograph') dropdown_menu.InsData(c4d.Ocube, 'CMD') # Adds a Cube Primitive dropdown_menu.InsData(1018544, 'CMD') # Adds a Cloner Object menu.InsData(IDM_MENU1, add_tag_to_objs) menu.InsData(0, '') menu.InsData(IDM_DROPDOWN1, dropdown_menu) # Show Popup Dialog result = gui.ShowPopupDialog(cd=None, bc=menu, x=c4d.MOUSEPOS, y=c4d.MOUSEPOS) print result When executed this returns the following result: Accessing the commands that add a Cloner or Cube was simple, one can simply open the script log, add an object to the scene and then take the resulting .CallCommand() ID outputted in the log and add it to the script with the .InsData() function (as shown above). When adding tags, however, the resulting script log shows several commands being executed, in a way that I can't figure out how to replicate with .InsData() : c4d.CallCommand(5629) # c4d.CallCommand(100004788, 50018) # New Tag As a result, I can see it being necessary to define a function that loops through the selected objects in the scene whilst adding the relevant tags to them. However I cannot figure out firstly what this function should look like, and secondly how to execute it when clicking the 'Add Protection Tag' option from the popup script? I'm still fairly new to Python scripting and C4D in general so detailed/commented answers would be much appreciated- but I'll take all the help I can get! Thanks in advance!
  4. Hi there! I am new to Cinema, having come from a different 3D package, and have been playing around with the Python API to create various scripts replicating certain functionality in my original software. These scripts have been very simple, typically calling/toggling commands (with 'c4d.CallCommand(id)', for example), and I have been binding them to different keyboard shortcuts using the 'Customise Commands' Manager. My issue is that I'm creating a large number of small '.py' script files and assigning them manually to shortcuts, and feel that it would be much more manageable and efficient for me to merge my scripts into one main file and assign shortcuts from within it. As a result, I was wondering if there is an easy way of triggering these individual script commands within the main script file as a result of user-inputted keypresses? For example, the type of thing I'm looking to achieve is: if user_presses_F10_key: c4d.CallCommand(12083) # Change to 'Top' view elif user_presses_CTRL+TAB_keys: c4d.CallCommand(12080) # Change to 'Right' view Any help/detailed answer would be really appreciated as I'm still fairly new to Python in general too! Thanks!

Latest Comments

×
×
  • Create New...