Hi Justin,

Thanks for the solved! It works now. Regarding the function I didn't get
about createControl function that you mentioned. Can you explaining means
about more growing on every call?! That param will use for the connection
of the constraint also parent later using dictionary as it is :

      if connect:
>             def parentObject(ctrl, obj):
>              mc.parent(obj, ctrl)
>             dic = {'parentCons': mc.parentConstraint,
>                    'pointCons': mc.pointConstraint,
>                    'orientCons': mc.orientConstraint,
>                    'scaleCons': mc.scaleConstraint,
>                    'parent': parentObject}
>             for con in connect:
>                dic[con](parCtrl, obj)



I'm still thinking to make them as function.. :D Thank you!

On Sat, Jun 9, 2018 at 12:50 PM, Justin Israel <justinisr...@gmail.com>
wrote:

>
>
> On Sat, Jun 9, 2018 at 5:38 PM Adynsky <adien.den...@gmail.com> wrote:
>
>> Hi guys,
>>
>> I'm new and starting learning python. I'm trying my self to create anim
>> control using the curve and here I'm stuck to get item of function :
>>
>> def groupParent(groups, prefix, suffix):
>>>
>>>     grps = []
>>>
>>>     for i in range(len(groups)):
>>>
>>>         grps.append(mc.createNode('transform', n="%s%s%s_%s" % (prefix,
>>>> suffix, groups[i], GROUP)))
>>>
>>>         if i > 0:
>>>
>>>             mc.parent(grps[i], grps[i - 1])
>>>
>>>
>>
>>> def matchPosition(objectOri, object):
>>>
>>>     mc.delete(mc.parentConstraint(objectOri, object, mo=False))
>>>
>>>
>>
>>> def createControl(suffix='ctrl',
>>>
>>>                   groups=['zro'],
>>>
>>>                   gimbal=None,
>>>
>>>                   gimbalSize=0.5,
>>>
>>>                   shape=SQUARE,
>>>
>>>                   connect=[]):
>>>
>>>     for obj in mc.ls(sl=1):
>>>
>>>         ctrl    = controller(shape)
>>>
>>>         renCtrl = mc.rename(ctrl, prefixName(obj))
>>>
>>>         grpPrnt = groupParent(groups, renCtrl, suffix.title())
>>>
>>>         mc.parent(renCtrl, grpPrnt)
>>>
>>>         finName = mc.rename(renCtrl, '%s_%s' % (prefixName(obj), suffix))
>>>
>>>
>>>>         doMatch = matchPosition(obj, grpPrnt)
>>>
>>>
>> I run it and have the error "Target list was empty or contained no valid
>> targets." So, how do I do to get item the list on grps[0] in function
>> groupParent and then assigned to grpPrnt variable?! Thanks in advance!
>>
>
>
> Hi. You are missing a return statement in your groupParent function. So
> you end up having grpPrnt=None
>
> def groupParent(groups, prefix, suffix):
>     grps = []
>     for i in range(len(groups)):
>         grps.append(mc.createNode('transform', n="%s%s%s_%s" % (prefix, 
> suffix, groups[i], GROUP)))
>         if i > 0:
>             mc.parent(grps[i], grps[i - 1])
>     return grps
>
> ​
>
> Also, in the createControl function, be careful when passing default list
> values for the function arguments. The groups param is currently being used
> as read-only and the connect isn't being used. But if you ended up using
> them to append, you might find surprising results when the default list
> keeps growing on every call. Its better to use a lit:
>
> def foo(myList=None):
>     if myList is None:
>         myList = ['default']
>
> ​
>
>
>>
>>
>> --
>> 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/4129465e-02e4-4ef6-94fe-
>> 8abf14c225c6%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/4129465e-02e4-4ef6-94fe-8abf14c225c6%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/CAPGFgA1k5CRuC%2B4g9Y2uf3kfsNjqrVZVbgCYBL9ZNu
> 30sos3UQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1k5CRuC%2B4g9Y2uf3kfsNjqrVZVbgCYBL9ZNu30sos3UQ%40mail.gmail.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/CAE5XL93dmFDEcSCDvm%2Brr_XtnSEn_B6ZVc9Z73cyAET5-C6M_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to