Variations for saved tool options?


#1

I have a question about setting specific options for tools, and being able to assign those options to a shortcut.

Example:
I use the Set Point Value tool pretty often, especially when setting up geometry to be mirrored.
But every time I go to use it, I have to mess around in the tool options.
Set X to “Set”
Set Val. to 0
Set Y to “Leave”
Make sure coordinate system is global, and change it if it’s not, etc.

I know you can set some options and then save that as the default for the tool, but is there a way to have different variations of those options saved to different commands/buttons?

In this example, I’d want to have 3 different buttons:
One to set value globally to 0 for all selected points on the X axis,
One to set value globally to 0 for all selected points on the Y axis,
etc.

Can this be done?
Thanks


#2

You could script a call through SendModelingCommand() that includes all your settings, and then put the script on the GUI somewhere.


#3

Thanks for the reply Cairyn, unfortunately my scripting skills are abysmal, and I don’t know the order/usage of this command.

Can anyone out there who knows what they’re doing (which is not me) show an example of this and how it would be used?

Thanks!


#4

Well then.

import c4d
from c4d import utils

def main():
    doc.StartUndo()
    doc.AddUndo(c4d.UNDOTYPE_CHANGE, op)
    settings = c4d.BaseContainer()                 # Settings
    settings[c4d.MDATA_SETVALUE_SETX] = c4d.MDATA_SETVALUE_SET_SET  # Dropdown for X
    settings[c4d.MDATA_SETVALUE_SETY] = c4d.MDATA_SETVALUE_SET_LEAVE  # Dropdown for Y
    settings[c4d.MDATA_SETVALUE_SETZ] = c4d.MDATA_SETVALUE_SET_LEAVE  # Dropdown for Z
    settings[c4d.MDATA_SETVALUE_VAL] = c4d.Vector(0.0, 0.0, 0.0)  # X Y Z values
    settings[c4d.MDATA_SETVALUE_SYSTEM] = c4d.MDATA_SETVALUE_SYSTEM_WORLD  # Global system

    res = utils.SendModelingCommand(command = c4d.ID_MODELING_SETVALUE_TOOL,
                                    list = [op],
                                    mode = c4d.MODELINGCOMMANDMODE_POINTSELECTION,
                                    bc = settings,
                                    doc = doc)
    doc.EndUndo()
    c4d.EventAdd()

    if res is False:
      print "Something went wrong."
    elif res is True:
      print "Command successful."
    elif isinstance(res, list):
      print "Here you get the newly created object(s)."

if __name__=='__main__':
    main()

This is the version that will set all selected points to Global X = 0.
For the other two versions, you just need to change the lines with the Dropdown values accordingly.

…I really need to start charging for scripting, ain’t got no hot cocoa in the house anymore sigh


#5

Note that:

  1. If no point is selected, the script changes ALL the points, just like the tool does
  2. The script does NOT change the tool settings, it uses its own local settings. So you don’t involuntarily change anything that you have done in the tool dialog.
  3. The script does NOT change your currently selected tool. So, you can put these scripts on keyboard shortcuts and just apply them without going out of your tool.
  4. The script has a success output in the console. If something is totally wrong, like having no selected object, it will show errors of some kind or the other, but you can ignore these.

#6

Thanks so much Cairyn!

I’m at work now but will check this out when I get home tonight.
Hopefully it will also help if I get brave enough to try some tweaking with other tools as well.


#7

Cairyn, these are working great. Thanks again!

I’m all iconned up and ready to go :smiley:

CINEMA_4D_2019-03-05_21-38-32