It obviously depends what you are doing in your final command (i.e. if you
are not already using an object list or selection), but another option could
be to use objects if your arguments are objects in the DG anyway. Using
objects allows your command to accept either an individual object or an
object list. For instance:

syntax.setObjectType(MSyntax::kSelectionList) // You can also optionally
specify a min and max

If you need multiple objects for this particular case but also need to
operate on a *single* specified node, you could set
syntax.useSelectionAsDefault(false) and then do one of the following
approaches:

   - Get your selection inside the command using
   MGlobal::getActiveSelectionList()
   - Get your selection inside the command using another flag

In either of these cases, you would call the command with the object names
passed as your object list and then have the option of specifying the node
on which you need to operate with these items either assuming it is the
current selection or by passing it as an argument:

   - *MEL:*
      - ngTestCmd persp top // Using getActiveSelectionList() to specify a
      node
      - ngTestCmd -node nodeName persp top // Using another flag to specify
      a node
      - *Python:*
      - cmds.ngTestCmd(["persp","top"]) # Using getActiveSelectionList() to
      specify a node
      - cmds.ngTestCmd(["persp","top"], node="nodeName")# Using another flag
      to specify a node

You could even combine both approaches if you wanted. Again though, this
assumes that you a) need to operate on an object and b) it is only a single
object and not several.

On Fri, Jan 22, 2010 at 1:52 PM, viktoras <[email protected]> wrote:

>
>  Yes, this is unfortunately a known bug.  You can use mel.eval to hack
>> around it.
>>
>>
> thanks!
>
> it's not very good news after spending half a day trying to find out what i
> was doing wrong.
> is this a bug in maya 2008, or is it unresolved in 2010 as well?
>
> mel.eval doesn't look like a best option. i guess i'll go with another
> hacky solution and
> allow passing parameter list in two ways:
>
> python: cmds.myCommand(allParams="param1;param2;param3")
> mel: myCommand -param "param1" -param "param2" -param "param3"
>
> and split "allParams" into multiple ones if "param" is not present.
>
>
> --
> viktoras
> www.neglostyti.com
>
>
> --
> http://groups.google.com/group/python_inside_maya
>

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to