Maya Python Question - How to change wire attributes on many objects


#1

Hi guys, I’m new in Maya & I’m coming from the Max universe, and I was curious how I can change the wire parameters on a bunch of object.
Basically I created a scripte that wires shapes on curves(based on their names), I was curious how I can change the same wire parameters on all of them through a Python script.
In max as we have modifier for such cases it’s pretty easy to access them through maxscript, in Maya it seems more trickier.
Thanks


#2

I dont know what do you mean by “wire parameters” but to do anything with bunch of objects you need to create list of this object and than apply command to each object with a help of loop.

Open script editor and paste this code in Python tab.

import pymel.core as pm

listOfSelected = pm.ls(sl = True) # Create list from selected objects
for object in listOfSelected:
    print object # Print name of each object in list

Select objects and press Execute All button in script editor. It should print name of each selected object.
You just need to replace print command with command that will “change wire parameters”. Can you post your script here?

I wrote a python for Maya tutorial for peoples who wish to start use it, may be it would help also.


#3

Hi kiryha,the code you gave me I already wrote it, the problem comes with the next step.
You know in the deformers you have Wrap, Lattice, Wire … that’s the wire I’m talking about, he’s applied on bunch of objects and I want to control his attributes on many objects in the same time, but I don’t understand the architecture of maya very well to do so.


#4

You have a wire deformer on several objects and you need to change attributes of each deformer at the same time?
You can do it with Attribute Spread Sheet i guess, but with python

import pymel.core as pm

listOfSelected = pm.ls( typ = 'wire' ) 
for i in listOfSelected:
    i.tension.set(5)

It will set tension attribute of all wire deformers in scene to 5.


#5

Thank you for your help man, but I found a way to do it after surffing on google, this is basically what I wanted to do.


import maya.cmds as cmds
sel = cmds.ls(sl = True)
for each in sel :
    historyList = cmds.listHistory(each , future = True)
    print historyList
    for historyNode in historyList:
        historyNodeType = (cmds.nodeType(historyNode , apiType = True))
        if historyNodeType == 'kWire' :
            myWire = historyNode
            cmds.wire(myWire , edit=True ,  dds =[(0, 100)] )