Also if there is a simpler way to dynamically change attributes in maya do
tell :)

On Fri, Dec 2, 2011 at 5:27 PM, rfsf <[email protected]> wrote:

> I was wondering if anyone has used multiple scriptJobs to alter
> attributes on a control
> to give allow presets for settings on a control? this is my first time
> really integrating scriptNodes and
> scriptJobs so I may be approaching this wrong.
>
> Below is some code that would control on attribute I named
> 'Jiggle_Presets' which is an enum attribute
> that I use to fire the scriptJob.
>
> My current problem is that I need to alter several enums to control
> presets for 6 other regions of the rig. Currently I'm storing these in
> scriptNodes that evaluate when the rig file opens. However the
> presetValues
> don't seem to update their specific values listed in their
> corresponding scriptNode. So one set of presetValues
> overrides and updates all the attributes for all the scriptNodes,
> instead of respecting their unique values listed in their scriptNode
>
>
>
> import maya.cmds as mc
>
> presetValues = {"No Jiggle":[0, 2], "Fast Run":[0.2, 2.5],"Medium
> Walk":[0.5, 5],
>                            "Slow Movement":[1, 10] }
>
> presets  = ["No Jiggle","Fast Run", "Medium Walk", "Slow Movement"]
>
> attributesList = ["Jiggle", "Dampen"]
>
> def createScriptJob():
>
>        name = getNameSpace()
>        namespace = name[0].rstrip('RN')
>
>
>        if namespace == 'None':
>
>            scriptJob =
> mc.scriptJob( ac=["Muscles_0_CON.Jiggle_Presets","setValues()"])
>
>        else:
>            print "namespace found"
>            scriptJob = mc.scriptJob( ac=[str(namespace)
> +':'+"Muscles_0_CON.Jiggle_Presets","setValues()"])
>
>
> def getNameSpace():
>    namespace = []
>    many = []
>
>    try:
>        refNodes = mc.ls(type='reference')
>        for ref in refNodes:
>            if ref.find('_rig_') == -1:
>                namespace = 'None'
>            else:
>                namespace = ref.split(':')
>                many.append(namespace)
>                print namespace
>
>    except:
>        print 'no reference nodes'
>
>
>    return namespace
>
>
> #curName = getNameSpace()
> #namespace = curName[0].rstrip('RN')
>
> def getEnumValue():
>
>    name = whatIsSelected()[0]
>    val = mc.getAttr(name+".Jiggle_Presets")
>
>    return val
>
> #getVal = getEnumValue()
>
>
> #mc.scriptJob(attributeChange=['Jiggle_Presets', 'whatIsSelected()'])
> #mc.scriptJob(attributeChange=['Jiggle_Presets', 'whatIsSelected()'])
> def whatIsSelected():
>
>    sel = mc.ls(sl=1)
>    if sel[0].find(':') == True:
>        name = sel.split(':')
>        name = name[0]
>    else:
>        name = sel
>    return name
>
>
>
> #selected = whatIsSelected()[0]
>
>
>
>
> def setValues():
>    indicie = 0
>    enum = getEnumValue()
>    name = whatIsSelected()[0]
>
>    if enum != 0:
>        indicie = enum
>    preset = presets[indicie]
>    selectedPreset = presets[enum]
>    if selectedPreset in presetValues:
>        pValues=[]
>        pValues.append(presetValues[selectedPreset][0])
>        pValues.append(presetValues[selectedPreset][1])
>        #pValues.append(presetValues[selectedPreset][2])
>        for i in range(len(attributesList)):
>
>            mc.setAttr(name + '.' + attributesList[i],pValues[i])
>
>
>
>
>
> createScriptJob()
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to