So to be clear, I should be using the parser and the database classes?  If 
I try the following, I still get an internal error:

arg_data = om.MArgDatabase(self.syntax(), args)

assets = om.MSelectionList()
success = arg_data.getObjects(assets)


When it comes to getting the values of specific flags, I've got the value 
with help from examples, doing this:

        if arg_data.isFlagSet(kShortCamName):
            # We use the '0' to index the flag's first and only parameter.
            cam_name = arg_data.flagArgumentString(kShortCamName, 0)

But when I try similarly to use arg_data.commandArgumentString(0), I get an 
error.  I've gone and done the follow syntax command also:

syntax = om.MSyntax()
syntax.setObjectType(om.MSyntax.kStringObjects, 1)

Is there no way for me to get the list of strings passed to my command?  
This problem got me stumped.


On Saturday, 15 June 2019 20:18:51 UTC-4, Justin Israel wrote:
>
>
>
> On Sun, Jun 16, 2019, 8:52 AM Russel Rehmund <russel...@gmail.com 
> <javascript:>> wrote:
>
>> Hi there,
>>
>> I'm trying to write a command plugin for maya, which I'd like to give a 
>> list of assets from the scene:
>>
>> cmds.ls(selection=True)
>>
>>
>> I'd like to then accept this list into my command either as an argument 
>> or give it to a flag, but this is where my knowledge stops.  I'd like to be 
>> able to do one of the following:
>>
>> (As an argument)
>> assets = cmds.ls(selection=True)
>> cmds.my_command(assets, some_flags=True)
>>
>> (To a flag)
>> assets = cmds.ls(selection=True)
>> cmds.my_command(asset_flag=assets, some_flags=True)
>>
>>
>> My first attempt was trying to use a flag, but getting a list from a flag 
>> wasn't trivial, so I'm now trying to get it as an argument using:
>>
>> arg_parser_data = om.MArgParser(self.syntax(), args)
>>
>> assets = om.MSelectionList()
>> success = arg_parser_data.getObjects(assets)
>>
>> However I keep getting an unhelpful "Internal Failure Error" from maya.  
>> Any help or indications would be great!
>>
>
> If you want to make it work like many of the existing Maya commands that 
> take either objects as arguments, or falls back to the selection list, then 
> you likely want to look at using MSyntax with an object list, and 
> MArgDatabase:
>
> http://help.autodesk.com/view/MAYAUL/2018/ENU/?guid=__cpp_ref_class_m_syntax_html
>
> This would hand you the selection automatically. 
>
>
>> Thanks,
>>
>> Russ
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to python_inside_maya+unsubscr...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/3df69889-f6d6-4164-b01f-7c1b0b0ecf46%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/3df69889-f6d6-4164-b01f-7c1b0b0ecf46%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/0ad72954-68a7-4826-abeb-87e90e844ac3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to