need help in python

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  06 June 2013
need help in python

this is my command :

import maya.cmds as cm
Objects = = True)
for i in Objects:
GetAttr = cm.getAttr(Objects+'.translateY')
for i in GetAttr:
SetAttr = cm.setAttr(GetAttr+'.translateY',5)

and this is the error message:

# Error: line 1: can only concatenate list (not "str") to list
# Traceback (most recent call last):
# File "<maya console>", line 4, in <module>
# TypeError: can only concatenate list (not "str") to list #

please explain this error to me.
best regards.
welcome to the world of imagination
  06 June 2013
The error is because you put the list called Objects inside your loop, when you should have put i. But you have some other syntax errors too, so let me try to simplify it for you.

import maya.cmds as cmds
objs =
for o in objs:
	cmds.setAttr(o+'.ty', 5)

  06 June 2013
so when should i use getAttr?
welcome to the world of imagination
  06 June 2013
Use getAttr when you want to know the value of the attribute. In the following example I will get the translateX and put it on translateY

for o in
 	value = cmds.getAttr(o+'.tx')
 	cmds.setAttr(o+'.ty', value)

  06 June 2013
now i get that.thank you very much.
welcome to the world of imagination
  06 June 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 02:13 AM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.