ufcoaching.blogg.se

Maya python setattr of list
Maya python setattr of list











maya python setattr of list maya python setattr of list maya python setattr of list

# Get the cube shape from the cube objectĬmds.setAttr(cubeshape+".Python Dictionaries Access Items Change Items Add Items Remove Items Loop Dictionaries Copy Dictionaries Nested Dictionaries Dictionary Methods Dictionary Exercise Python If.Else Python While Loops Python For Loops Python Functions Python Lambda Python Arrays Python Classes/Objects Python Inheritance Python Iterators Python Scope Python Modules Python Dates Python Math Python JSON Python RegEx Python PIP Python Try. The final code # Import maya commands library Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more. , lock=True = This is the new value of the attribute W3Schools offers free online tutorials, references and exercises in all the major languages of the web.+”.translate” = This is the attribute are we modifying.cubeShape = We’ve stored our object name in this already (pCube1).In this tutorial, we will learn about Python setattr() in detail with the help of examples. Let’s break this command down, see what’s going on: The setattr() function sets the value of the attribute of an object.

maya python setattr of list

We can now use this to build our command to set an attribute, for this example lets lock all 3 translate values (X, Y and Z), essentially resulting in a cube object you can’t move. The output would be ‘pol圜ube1’, as this is 2nd in the object list. If we were to change our variable query to: If we print this new variable, we’ll get the output we need: pCube1 Let’s create another variable, and in it we will store the object name: cubeShape = cube While this list can be useful, it’s not really what we want in this case, we only need the ‘pCube1’ bit, as we’ll use this name to apply the attributes in a moment. Learn more about bidirectional Unicode characters. To review, open the file in an editor that reveals hidden Unicode characters. Let’s take a look at how we would do this, firstly we’ll set up our script by importing the maya commands library: from maya import cmdsĪnd we’ll create a cube object: cube = cmds.pol圜ube()īefore we move on we need to get the object name, if we print the cube variable we’ll get the following output: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. How to set attributes on objects in Maya using Python scripting.













Maya python setattr of list