Ok, I see where you're going, and you're correct, there's no double4 output.

You could make an array of doubles, but my question is why you'd want a Quaternion as an output--to my knowledge, Maya does process rotations internally as a Quaternion, but it converts those to Euler's before it outputs, and I don't know of any plugs that take a Quaternion.

When I've used Quaternions, I normally build my Quaternion internally, use it, and then output as a float3 after converting to a Euler with the appropriate rotation order.

You can do this pretty easily with MEulerRotation--it has asQuaternion(), and MQuaternion has asEulerRotation.

Once you've converted to a MEulerRotation, it's pretty straightforward to put it into a rotation data set.

You basically will need to set up three attributes (rotationX, rotationY, rotationZ) as MFnUnitAttributes with a type of MFnUnitAttribute::kAngle, and then a MFnNumericAttribute (rotation) with the three rotation attributes. At least that's how I do it--the setup looks something like this in c++ (but Python's very similar), in the initialize() function:

    MFnNumericAttribute nAttr;
    MFnUnitAttribute uAttr;

    aRotX = uAttr.create("rotateX", "rx", MFnUnitAttribute::kAngle);
    uAttr.setWritable(false);
    uAttr.setStorable(false);
    aRotY = uAttr.create("rotateY", "ry", MFnUnitAttribute::kAngle);
    uAttr.setWritable(false);
    uAttr.setStorable(false);
    aRotZ = uAttr.create("rotateZ", "rz", MFnUnitAttribute::kAngle);
    uAttr.setWritable(false);
    uAttr.setStorable(false);
    aOutRotation = nAttr.create("outRotation", "or", aRotX, aRotY, aRotZ);
    nAttr.setWritable(false);
    nAttr.setStorable(false);
    nAttr.setArray(true);

Then you just use set3Double to set them.

On 3/12/2015 7:03 PM, yaoys wrote:


But the problem is how to set the value with MDataHandle?
e.g.
MDataHandle dh = datablock.outputValue(myNode.aQuaternion)
dh.set?(...) # there is not interfaces for set double4 or quaternion
dh.setClean()

Cheers
yao
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7a4812eb-21e5-41db-8dbe-57bd459c4850%40googlegroups.com <https://groups.google.com/d/msgid/python_inside_maya/7a4812eb-21e5-41db-8dbe-57bd459c4850%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.



---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com

--
You received this message because you are subscribed to the Google Groups "Python 
Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/55031EDA.3070909%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to