Working with controllers in pymxs requires a different approach than in MAXScript. This is because MAXScript "knows" about nested object properties, and does some extra parsing when it encounters them. The pymxs layer doesn't understand nested object properties, so these properties do not appear to exist.
Here is an example of some MAXScript code:
myTeapot = teapot() myTeapot.pos.controller = noise_position()
In MAXScript, as in Python, myTeapot.pos is a Point3, which doesn't have an associated controller property. Attempting to get myTeapot.pos.controller in Python results in an error such as: AttributeError: 'pymxs.MXSWrapperBase' object has no attribute 'controller'.
But in MAXScript myTeapot.pos.controller is perfectly valid, as it evaluates to an object structure hierarchy. Therefore, to achieve the same thing using pymxs, we must use the same approach and use getPropertyController() / setPropertyController().
Note: In general you can use the same syntax as MAXScript to access properties, but in situations where the property is nested and inaccessible to Python/pymxs, you can use getProperty() / setProperty(). See the topic Class and Object Inspector Functions in the MAXScript Help for more information about these functions.
Here's a complete example where we set the Position XYZ controller of a box, and the X component of the position for a sphere:
from pymxs import runtime as rt # set the transform -> position controller t = rt.teapot() rt.setPropertyController( t.controller, 'Position', rt.noise_position()) print rt.getPropertyController(t.controller, 'Position') # set the transform -> position -> x_position controller s = rt.sphere() sphr_pos_ctrl = rt.getPropertyController(s.controller, 'Position') rt.setPropertyController(sphr_pos_ctrl, 'X Position', rt.noise_float()) print rt.getPropertyController(sphr_pos_ctrl, 'X Position')
Output:
Controller:Noise_Position Controller:Noise_Float