Hi everybody,

there was once a post with a similar issue in python API.
But there was no answer to that problem and I am writing my node in C++.

Here is the following setup:

   - I have an inputWorldMatrix attribute
   - I have outputTranslationX, Y and Z attributes

Now my goal is to create the same affect like a decomposeMatrix

I plug in the worldMatrix of a transform(objA) into my inputWorldMatrix 
attr of my CustomNode and connect its outputTranslationX,Y,Z into another 
transform's(objB) tx, ty, tz attr.

The issue is that after I did all the connections the transform node objB 
is not affected anyhow. In my compute function when I cout << translation.x 
<< endl; it shows me that it is getting dirty(what it should) and that this 
value is not changing. 

My question: where is the issue?

Here is the code of the compute function:

MStatus WorldMatrix::compute(const MPlug& plug, MDataBlock& data) {

MStatus status;
if((plug == aOutTranslationX) || (plug == aOutTranslationY) || (plug == 
aOutTranslationZ)){
    //get worldMatrix dataHandle
    MDataHandle hInputMatrix = data.inputValue(aWorldMatrix, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);   

    //get the worldMatrix and the translation
    MMatrix mInputMatrix = hInputMatrix.asMatrix();       
    MTransformationMatrix mTransMat(mInputMatrix);
    MVector translation = mTransMat.getTranslation(MSpace::kWorld);

    cout << translation.x << translation.y << translation. z << endl;    

    //get outMatrixX data
    MDataHandle hOutMatrixX = data.outputValue(aOutTranslationX, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);

    //get outMatrixY data
    MDataHandle hOutMatrixY = data.outputValue(aOutTranslationY, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);

    //get outMatrixZ data
    MDataHandle hOutMatrixZ = data.outputValue(aOutTranslationZ, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);

    float outX = translation.x;//do some compute stuff
    float outY = translation.y;//do some compute stuff 
    float outZ = translation.z;//do some compute stuff

    //set outMatrixX with outX value
    hOutMatrixX.setFloat(outX);

    //set outMatrixY with outY value
    hOutMatrixY.setFloat(outY);

    //set outMatrixZ with outZ value
    hOutMatrixZ.setFloat(outZ);

    data.setClean(plug);
    return MS::kSuccess;}else{
    return MS::kUnknownParameter;}

}

My aWorldMatrix attribute is created by an MFnMatrixAttribute and it is set 
as MFnMatrixAttribute::kFloat in the initialize function

And of course it is affecting the OutputTranslationX, Y, Z attributes. I 
guess also I need to do a conversion of the vector to a float(for 
setFloat), but don't know how. 

It would be awesome if someone could help me out.  (It doesn't matter if 
it's in python or C++)

Thanks in advance!!

Cheerio turkish engineer

-- 
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/2f3ccdf5-13d0-40b4-bb08-1ac50c2e6de3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to