On Sun, Jun 16, 2019, 8:52 AM Russel Rehmund <russel.rehm...@gmail.com> 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. > 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/CAPGFgA2Jsf5%3DCRuLpA3tF3oTa1SJggW6fYJYrdDBxq8myWkD2g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.