This way the attribute is defined: group -em -name 'plumbergrp' addAttr -dt 'stringArray' -ln 'parts' Ok so far, then I try to add a string. Whatever kind of format I use it does not start working. MAYA PYTHON SETATTR UPDATEThe final code # Import maya commands library Hi everyone, I try to use setAttr to update a custom attribute I defined on a group node of type stringArray. , lock=True = This is the new value of the attribute.+”.translate” = This is the attribute are we modifying.cubeShape = We’ve stored our object name in this already (pCube1).Let’s break this command down, see what’s going on: And lastly, if you want to perform the entire process before writing to a file, and. 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. image om.MImage () view 3dView () view.readColorBuffer (image, True) image.writeToFile ('viewport.png', 'png') But again, you will need to perform the cropping using your own lib. 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 Ioc éLocator0 import maya.cmds as cmds all or selected for mySelect input. The -typeflag is only required when setting a non-numeric attribute. No value for the theattribute is needed when the -l/-k/-s flags are used. Sets the value of a dependency node attribute. Syntax: setattr (object, name, value) where, object object whose attribute has to be set. def importFBX (filepath): defines importFBX as a file directory. setAttr is undoable, queryable, and editable. 1) getAttr and setAttr import maya.cmds loc ()0 //create a new locator and store the name of its transform mode in a variable called loc sx (loc+ '. Similarly, we have something to set the attribute values of an object, setattr (). import os importing operate system preferences. 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. import maya.cmds as mc imports MEL commands as Python wrapper. 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: MAYA PYTHON SETATTR HOW TOHow to set attributes on objects in Maya using Python scripting.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |