Get the locations of points on a curve, pointPosition(), Maya, Python

Posted by:

So Autodesk documentation on this is sparse and a bit inaccurate.

In order to get this function to work you need to separate out the parameters at the ‘.’ (something I am finding is a common thread among many of maya’s library functions)

This is the way to do it:

 

Note that this won’t work:

pointA = cmds.pointPosition(str(selectedCurve.cv[1]), world = True)

Because the .cv[1] is not separated out.

This however will work:

pointA = cmds.pointPosition(str(selectedCurve) + ‘.cv[0]’, world = True)#this is just another way of converting a ...

Continue Reading →
0

Format for getting text from a textField, Maya, GUI, Python

Posted by:

I felt that it wasn’t immediately obvious how you go about doing this and It took a bit of research to figure out how it worked (and how it didn’t — as some tutorials that I followed seemed to maybe not be 100% sure of how it worked either)

 

There are two parts to this, one is in the GUI and the other is in the code that you want to use the info for:

Continue Reading →
0

Create Null Above Object, Constrain Null To Secondary Object, Control Constraint With Attribute on Original Object, Maya, Python Script

Posted by:

I frequently have to have an object follow another object but that original object still has to be able to be controlled in the “local space” of the parent object, but then sometimes be independent of the parent object.  Think an IK hand control.

Anyway, I have to do this so often that I thought I would write a script so I never have to do it again.

Continue Reading →
0

Maya GUI button commands, how they work, Maya Scripting

Posted by:

I was a bit confused on how Maya GUI button command calls work.

It seems that when I was following tutorials they put the variables from the GUI into the parameters for the call which of course meant that they needed to be in the definition too.

After working with Maya GUI interactions for a while I realized that information that is derived from the GUI need not be included in the parameters because they are derived directly from the GUI interface, ...

Continue Reading →
0

Script: Duplicate hierarchy and parent constrain existing hierarchy to duplicate hierarchy, Maya, Python

Posted by:

This script will duplicate the selected hierarchy and parent constrain each child of the first hierarchy to its twin in the new hierarchy.  This script opens a window that allows you to select the root object to duplicate then duplicates, renames the new hierarchy, establishes the parent constraint and sets up a control for all of the parent constraints to be controlled from a single attribute on the original root object.

 

Continue Reading →
0

Passing single objects into functions, getting operations on the name string rather than the object itself

Posted by:

When I first started passing single objects into functions and loops I found that python(maya) was treating them as the strings of the object’s name rather than the object itself.

 

This error depends on how the variable of the object is structured.  If it is a single object in a list then you will get this problem.  The solution is to simply encapsulate the variable in a list:

 

[object] Continue Reading →
0
Page 1 of 2 12