I came across a funny 9gag article (click on the logo to read the article). One of the comments was really funny. It said "If Your Code Runs Every Time, You are Doing Something Wrong".
In reply to another StackOverflow question , I wrote 2 blocks of code that shows 2 UI layouts created with Maya's UI framework. First one looks like this: This is the code that created this first one. import maya . cmds as mc def buildUI (): winName = 'myWindow' winWidth = 200 # set a target width and reference this when you specify width if mc . window ( winName , exists = True ): mc . deleteUI ( winName ) mc . window ( winName , width = winWidth , title = 'Test Window' ) # i always have keep a reference to the main columnLayout mainCL = mc . columnLayout () mc . text ( label = 'text row 1' ) # tmpRowWidth controls the width of my columns in the rowLayout # with reference to winWidth tmpRowWidth = [ winWidth * 0.3 , winWidth * 0.7 ] mc . rowLayout ( numberOfColumns = 2 , columnWidth2 = tmpRowWidth ) # at this point our UI pointer is under the rowLayout mc . text ( label = 'row colu...
In this second video of my Maya Expressions series, I show how use the graph editor to display a visual representation of the value of our expressions with a graph. Then I move on to explain the basics of conditional statements in Maya's expression language, which also works with MEL scripts. A basic conditional statement in MEL and Maya expression language has the structure as such: if (condition) { statement1; statement2; } Condition is a test to see if a comparison between values is true, or false, for most cases. Example 1: if (cube1.translateX > cube2.translateX) { do_something; } In the above example, if cube1's translateX value is greater than cube2's translateX value, then do_something will be performed. Example 2: if (cube1.translateX == cube2.translateX) { do_something; } In the above, we are testing for equality. if both the values are equal, the do_something will be executed. Example 3: if (cube1.scaleX >= cube2.scal...
In the past few days I found myself having to find the position of face centres of a polygon. Looking through the Maya documentations I find no MEL or Python commands that can do this. So I had to do a Google search the answer. The most useful solution I found was from a discussion in Google Groups, in a reply by Justin Israel (who works in Weta Digital according to his Google+ profile ): https://groups.google.com/d/msg/python_inside_maya/UoMVxr0deVo/OJ2K8IpevxQJ Here is an excerpt of Justin's answer: import pymel.core as pm import maya.OpenMaya as OpenMaya face = pm.MeshFace("pCube1.f[64]") pt = face.__apimfn__().center( OpenMaya.MSpace.kWorld) centerPoint = pm.datatypes.Point(pt) Here is another interesting article discussing how we can go about finding the centre position of a face: http://mayastation.typepad.com/maya-station/2009/11/where-is-the-center-of-a-polygon.html
Comments
Post a Comment