Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / Python / Getting and Setting Attributes?
  RSS 2.0 ATOM  

Getting and Setting Attributes?
Rate this thread
 
41092
 
Permlink of this thread  
avatar
  • Herculis
  • Posted: 24 March 2010 07:46 AM
  • Location: London
  • Total Posts: 3
  • Joined: 01 March 2010 06:29 AM

Hello,

I am still relatively new to Maya programming in Python. I have the problem that I created a modelPanal using

panel cmds.modelPanel()

Now I want to get the name of the modelEditor that is in the modelPanel. How do I do that?

Or to give another example how do I get the radius of a sphere? The approach should be the same for both of them.

For setting attributes I use

cmds.setAttr()

so I tried

cmds.getAttr()

but didn’t succeed in solving the issue.

Thank you very much!



Replies: 0
avatar
  • rasto
  • Posted: 24 March 2010 08:48 AM

cmds.getPanel()
cmds.getAttr('polySphere1.radius')


CG Artist
http://www.toxik.sk

Replies: 0
avatar
  • Herculis
  • Posted: 15 April 2010 05:14 AM

Thanks Rasto!

For the cmds.getAttr() case I always forgot the apostrophes, which is the reason why it didn’t work.

However, as far as I can tell cmds.getPanel() returns a panel and not the modelEditor inside the panel. I would like to know how to get the name of the modelEditor rather than the panel itself.

Thanks again!



Replies: 1
/userdata/avatar/avatar_1601.png
import maya.cmds as cmds
unknownPanel 
cmds.getPanelwithFocus=True )
modelEditor cmds.modelPanelunknownPanelquery=Truelabel=True )
Author: rasto

Replied: 20 February 2011 07:40 AM  
avatar
  • Void
  • Posted: 07 January 2011 03:06 AM

If I may ask, is it possible to get the attributes of an object when using variables ?

for obj in selectedObj :
 print 
obj
 cmd
.getAttrobj.translate ##Error

I’d like to get some attributes of all my selected objects in the scene, but I cannot find a way to achieve that.



Replies: 1
/img/forum/dark/default_avatar.png

cmd.getAttr( obj + “.translate” )

Author: rdms

Replied: 10 January 2011 07:36 AM  
avatar
  • Void
  • Posted: 11 January 2011 12:29 AM

thank you sir :)



Replies: 0