maya

Maya Python: takes exactly 1 argument (2 given)

江枫思渺然 提交于 2019-12-13 05:29:48
问题 I'm really quite new to scripting in Maya. I've been working on a relatively simple tool that creates a simple UI that a user can use to constrain one object to another, but still have the freedom to move that object once its constrained. This is done using nested locators. If I run the following code I get the error msg: "# Error: attachObject() takes exactly 1 argument (2 given) # " import maya.cmds as mc from functools import partial #Class to hold UI methods class UI(): def __init__(self)

importing “pyc” into existing python script

纵饮孤独 提交于 2019-12-13 04:42:33
问题 I'm trying to add a directory where I can throw some pyc files and call them from my script. Basically it's an independent python script with a bunch of def's in it, I want the name of the pyc file to be the command executed. so far this works ok except for one thing, my GUI buttons are calling defs as they are and python doesn't recognize them since the name space is wrong. How can I import it in from the script as if it was imported like : from Module import as * I'm running this code to

How to print the value of intField in Maya python

被刻印的时光 ゝ 提交于 2019-12-13 04:21:39
问题 I want to print the value of intField given by user in maya using python. code import maya.cmds as cmds def fun(number): print(number) cmds.window() cmds.columnLayout() num = cmds.intField(changeCommand = 'fun()') cmds.showWindow() User will enter value in intField and i want to print that value 回答1: You have to use lambda or partial : import maya.cmds as cmds from functools import partial # Here is how i layout this kind of case : # First the function that is not related to the ui def

Using Sliders in Maya with Python to control Shapes - intSliderGrp

…衆ロ難τιáo~ 提交于 2019-12-13 03:58:00
问题 I am trying to use the following sliders for the Colour, Translate, Rotate and Scale for the shapes I have in this code. Is there a way I can control all the shapes with these sliders? I can't seem to figure it out I've tried everything that I could. I would like to do this with maybe a function but any solution is helpful Any help would be appreciated, thank you. #Importing all Maya commands to Python import maya.cmds as cmds from functools import partial class CreateUI(): def __init__(self)

In unity, use maya exported animation and other anim make animator transition will reset object position

痴心易碎 提交于 2019-12-13 03:24:57
问题 here is my unity project here is my maya project here is my old question in my old question, I use paid unity asset animation occurs same problem, so I make similar animation with maya and reproduce it with free asset see my gif the bug is when ClimbReachTop finish and play Standing, the object position will be auto reset when i use similar ClimbReachTop in this asset, the object position will not be reset so how to make animator transition not reset object position I'm sure it's not because

Maya transform node not appearing in list

时光怂恿深爱的人放手 提交于 2019-12-13 00:54:23
问题 The Maya python code below gives a nurbs boolean surface by first taking the difference of two nurbs spheres, nurbsSphere1 and nurbsSphere2, to give the nurbs surface nurbsBooleanSurface1. It then takes the difference of this surface and a third sphere, nurbsSphere3. The result, as seen in the outliner, is the three nurbs spheres plus a surfaceVarGroup, nurbsBooleanSurface1, which 'parents' three transform nodes nurbsBooleanSurface1_1, nurbsBooleanSurface1_2 and nurbsBooleanSurface1_3. import

How to check if instance exists if variable not existing?

妖精的绣舞 提交于 2019-12-13 00:29:16
问题 I have a button which imports a module with a class. The class (varClass) creates a window. If i click the button once again, i try this: if var: var.toggleUI() else : var = varClass() But var doesn' exist the first time you create the window after opening Maya. How can i get this working? 回答1: You could catch the NameError exception: try: var.toggleUI() except NameError: var = varClass() If you needed call toggleUI the first time too, just try the name itself: try: var except NameError: var

Freeze scale transform on a parent object with animated child (MAYA MEL/Python script)

两盒软妹~` 提交于 2019-12-12 20:38:09
问题 I have hierarchy of objects with animation on translation and rotation, the scale xyz are equal and static but not 1. When I freeze scale on a parent mesh it's children's animation goes wild. Is there any way to prevent this from happening? I have found a workaround, but it's not perfect yet. Let's say we have simple setup like this: parentObject=>childObject I put childObject in a group "childObjectGroup" parent childObjectGroup to the world and zero out it's transforms excluding scale. Bake

How do I parent new, user-created buttons inside the Graph Editor window?

China☆狼群 提交于 2019-12-12 09:27:16
问题 I'd like to add some new buttons to the Maya Graph editor -- particularly on top of the Channel list with all the attributes in the left of the window. However I'd rather not muck around with the Maya Startup scripts for the Graph Editor itself. Is there a way to "parent" the new buttons I want inside every new Graph Editor window using a separate script? Ideally this could be all Python. 回答1: TL;DR; if cmds.window("GE_ui_window", exists=True): #If the window exists cmds.deleteUI("GE_ui

Eclipse environment for Maya's python modules

孤者浪人 提交于 2019-12-12 08:13:35
问题 I'm trying to set up the Eclipse IDE to recognize the maya.cmds module, an all modules associated with the maya module. The following code are tests run in Eclipse, and Maya's script editor. import maya print 'maya:\n', dir(maya) from maya import cmds print 'cmds:\n', len(dir(cmds)) # too many to print print 'sphere: ', cmds.sphere In Maya's script editor the code results in maya: ['OpenMaya', '_OpenMaya', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'app',