maya

How to get data from an upstream node in maya?

时光总嘲笑我的痴心妄想 提交于 2019-12-12 06:01:41
问题 I have a maya node myNode , which creates a shadeNode , which inMesh attribute is connected to shapeNode.outMesh and has an attribute distance . myNode.outMesh -> shapeNode.inMesh myNode.distance = 10 Then i have a command, which works on the shape node, but requires the distance argument, which it does by iterating over the inMesh connections: MPlugArray meshConnections; MPlug inMeshPlug = depNodeFn.findPlug("inMesh"); inMeshPlug.connectedTo(meshConnections, true, false); // in connections

Printing the label of a button when clicked

我们两清 提交于 2019-12-12 04:07:34
问题 So I'm trying to output the label of the button as it's pressed (Button label should replace the XXX in the print of the buttonNumber function). I do not know how to retrieve the label data from the button to output. Any thoughts? Thanks in advance import maya.cmds as mc def buttonNumber(*args): print 'Button XXX was pressed' def openWindow(): if mc.window('windowTest', ex=True): mc.deleteUI('windowTest', window=True) mc.window('windowTest', title='', s=True, resizeToFitChildren = True,) mc

Maya Python modules complete documentation?

泄露秘密 提交于 2019-12-12 03:07:03
问题 I've started using Python to script Maya for a school projet but i'm facing a problem with the documentation : I can't find anywhere a complete documentation of all the modules classes and function of the Maya API. I've already foun the Python-style documentation for PyMEL module, but where is the reste of it ? E.g, the maya.cmds module ? Thanks. 回答1: Open the maya help inside of Maya (the F1 key in windows) or go to the online documentation (that link goes to the maya 2015 docs, your copy of

Assigning multiple materials to multiple obj files in Maya

 ̄綄美尐妖づ 提交于 2019-12-12 03:06:25
问题 I'm looking for a script in Phyton or Mel where is can assign different materials to an OBJ imported file from Rhino and the same materials to the next OBJ file also imported from Rhino. Is that possible? Here's what I have tried: import maya.cmds as cmds import glob def importFile(i): cmds.file(i, i=True, groupReference=True, groupName="myobj") def materialFile(): cmds.select("myobj") myMaterial = "blinn2" cmds.sets( e=True, forceElement= myMaterial + 'SG' ) The obj files parts come in

enable or disable a field in maya ui with python

痴心易碎 提交于 2019-12-12 02:53:40
问题 I am trying to enable/disable a float field in the ui of a python script for maya, but I dont know how it is done. Here is an example: import maya.cmds as cmds def createUI(windowTitle): windowID = 'myWindoWID' if cmds.window(windowID, exists = True): cmds.deleteUI(windowID) cmds.window( windowID, title = windowTitle, sizeable = False, resizeToFitChildren = True) cmds.rowColumnLayout(numberOfColumns = 3, columnWidth = [(1,120), (2,120), (3,120)]) cmds.floatField(enable = False) cmds.button

How to add a color to an object in Autodesk Maya 2016 in Python scripts?

允我心安 提交于 2019-12-12 02:36:21
问题 I am new in Autodesk Maya. I looked over the internet to find some details about how can I command in the python scripting , to an object to change it's color when it is selected. I know how to see the selected object, however, I didn't succeed to change the color. I used this function - enter code here 'result = cmds.ls(orderedSelection =True) Trans = result[0] cmds.color(Trans,userDefined =8 ) ' when I press an object, it is being selected, but it's color doesn't change. It will be helpful

Changing python installation for maya

我的梦境 提交于 2019-12-12 02:22:38
问题 I have searched around entire internet. 1. i have 64bit 2014 maya installed, i had 32bit python installed at c:\python27.. as you know maya installs its own python and works with that, i want to change it and make maya work with my own python that is installed in c drive. What i did? 1. i did change the python, first unisntalled and and then installed 64bit version, i copied cv2.pyd to its site-packages and also installed matplotlib,scipy, pandas, numpy. my code in pycharm works just fine but

Maya Python: Unbound Method due to Reload()

拟墨画扇 提交于 2019-12-12 01:49:32
问题 I have two files that import the same object tracking method from a third file. It works something like this file TrackingMethod class Tracker(object): def __init__(self,nodeName=None,dag=None,obj=None): #Does some open maya stuff to get the dag path def fullpath(self): return dag.fullpath() file Shapes #classes that create objects with shape nodes import TrackingMethod as trm reload(trm) class circle(trm.Tracker): def __init__(self,nodeName=None,dag=None,obj-None): #does some shape related

How to measure the time of a Maya script?

巧了我就是萌 提交于 2019-12-12 01:47:36
问题 I have several methods implemented in MEL, and I would like to measure its performance. Is there any way to measure execution time of a fragment of code? Something equivalent to "getCurrentTime" in other languages. 回答1: the timerX() command will give you seconds since Maya was started, so you can grab that and do the math: float $start = timerX(); 回答2: Timer // Example 1: Simple timing // $startTime = `timerX`; // code that is being timed $totalTime = `timerX -startTime $startTime`; print (

time.sleep that allows parent application to still evaluate?

倖福魔咒の 提交于 2019-12-12 00:42:25
问题 I've run into situations as of late when writing scripts for both Maya and Houdini where I need to wait for aspects of the GUI to update before I can call the rest of my Python code. I was thinking calling time.sleep in both situations would have fixed my problem, but it seems that time.sleep just holds up the parent application as well. This means my script evaluates the exact same regardless of whether or not the sleep is in there, it just pauses part way through. I have a thought to run my