0.4.6
A bunch of usability improvements.
- Removed unused
NODE_REUSE
andPLUG_REUSE
environment variables, these were initially proof-of-concept but it's safe to say they were a success and now a fundamental part of cmdx. - Added
Seconds
,Milliseconds
,Minutes
andUiUnit()
as units for plug reading.UiUnits
being a function, since the actual value changes when the user edits Maya's global preferences - Improved
cmdx.Divider
to actually let you control the attribute name (used to be automatic and clever) - Added
plug.writable
for a convenient way of spotting whether you can actually write to a plug - Added
plug.default
to fetch a plug's default value, taking attribute type into account. Similar tocmds.attributeQuery(listDefault=True)
- Added ability to write a 16-tuple as a matrix (rather than having to manually cast it to a
MMatrix
- Added
Node.reset()
andDGModifier.resetAttr()
to reset an attribute to its default value - Added
MatrixType
to handle indexing and future more-granular index manipulation. - Fixed
node["myTimeAttr"].read()
such that it returns a float rather than an int- NOTE: There is a still a discrepancy between what is read and written; read returns a value in the current UI-unit, whereas write takes a value in Seconds. Writing currently doesn't massage the values you put into it so it's a little harder to control at the moment. The same is true for reading of degrees, which takes radians as input. Luckily, both API and UI defaults to centimeters for distance-type attributes.
- Added
cmdx.DagNode.boundingBox
andBoundingBox.volume()
for computing the volume of any DagNode (approximate, based on whatever bounding box information Maya has already got about your object)
writable
# Before
if not node["tx"].connected and not node["tx"].locked:
node["tx"] = 5
# After
if node["tx]".writable:
node["tx"] = 5
reset
A much simplified manner in which to reset an attribute to whatever value was its default.
# Before
plug = node["myAttr"]._mplug
attr = plug.attribute()
type = attr.apiType()
assert type == om.MFn.kNumericAttribute
default = om.MFnNumericAttribute(attr).default
node["myAttr"] = default
# After
node["myAttr"].reset()
Also works with undo.
with cmdx.DGModifier() as mod:
mod.resetAttr(node["myAttr"])