Named parameters on a long command
Hello, I have a custom command with 10+ parameters and each of these parameters has a name and a default value. Right now I'm forced to use something like MyCommand(cube, 1, 20, , , , , , , true); This approach, however is very cumbersome and error-prone. I was wondering if there is a way to call the command by setting the parameters by name and not by their order. Basically, I would like to be able to do something like this: MyCommand( objName = cube, type = 1, someOtherThing = 20, yetAnotherThing = true); Is it possible to do this in Softimage? Thanks, Mihail
Re: Named parameters on a long command
You can set default values in command definition(plugin registration). But you cannot specify argument name and value when you are calling the command. On Wed, Jul 3, 2013 at 7:43 AM, Mihail Djurev mihail.dju...@chaosgroup.comwrote: Hello, I have a custom command with 10+ parameters and each of these parameters has a name and a default value. Right now I'm forced to use something like MyCommand(cube, 1, 20, , , , , , , true); This approach, however is very cumbersome and error-prone. I was wondering if there is a way to call the command by setting the parameters by name and not by their order. Basically, I would like to be able to do something like this: MyCommand( objName = cube, type = 1, someOtherThing = 20, yetAnotherThing = true); Is it possible to do this in Softimage? Thanks, Mihail --
Re: Named parameters on a long command
Could you wrap the command in a python function? def myFunction(arg1=Default, arg2=1, arg3=True, arg4=String): xsi.myCommand(arg1,arg2,arg3,arg4) myFunction(arg2=3, arg4=String2) Eric Thivierge === Character TD / RnD Hybride Technologies On 03/07/2013 7:43 AM, Mihail Djurev wrote: Hello, I have a custom command with 10+ parameters and each of these parameters has a name and a default value. Right now I'm forced to use something like MyCommand(cube, 1, 20, , , , , , , true); This approach, however is very cumbersome and error-prone. I was wondering if there is a way to call the command by setting the parameters by name and not by their order. Basically, I would like to be able to do something like this: MyCommand( objName = cube, type = 1, someOtherThing = 20, yetAnotherThing = true); Is it possible to do this in Softimage? Thanks, Mihail
Re: Named parameters on a long command
Thanks Eric, that will do. Mihail
Re: Named parameters on a long command
A handy python wrapper I have around on my library, perhaps it's usefull for you too :-) def pywrap(cmd_name, **kwds): cmd = Application.Commands(cmd_name) if not cmd: Application.LogMessage(cmd_name + doesnt found., 4) return for arg in cmd.Arguments: value = kwds.get(arg.Name) if value: arg.Value = value cmd.Execute() pywrap(Select Object, SelectionList=null) On Wed, Jul 3, 2013 at 10:41 AM, Mihail Djurev mihail.dju...@chaosgroup.com wrote: Thanks Eric, that will do. Mihail