Problem accessing MVectorArray attribs through MPlug...


#1

Hi all,

I was wondering if someone could help me to get my custom Locator node working please? It has a compute() function in which an MVectorArray called ‘gridGeometry’ is assigned to an output attribute (called gridGeom) using the lines:

MFnVectorArrayData gridGeomArrayDataFn;
MObject gridGeomArrayData = gridGeomArrayDataFn.create();

gridGeomArrayDataFn.set(gridGeometry);
h_gridGeom.set(gridGeomArrayData);

I have verified that gridGeomArrayDataFn contains the correct data - but am unsure whether this is being correctly assigned to the attribute using the h_gridGeom.set function (h_gridGeom is an MDataHandle).

This is because when I come to access the values in this attributes in the locator’s draw() function using the lines:

MStatus stat;
MVectorArray &pts;
MObject thisNode = thisMObject() ;
MFnDagNode dagFn( thisNode );

MPlug pointsPlug = dagFn.findPlug( gridGeom, &stat );
if (!stat) { stat.perror(“dagFn.findPlug( gridGeom, &stat )”);}

MObject ptsObj;

stat = pointsPlug.getValue(ptsObj);
if (!stat) { stat.perror(“pointsPlug.getValue(ptsObj)”);}

MFnVectorArrayData ptsData(ptsObj);
pts = ptsData.array();

Both ptsData and pts contain incorrect data - for example all x-coords are 0.01, whereas they’re meant ot vary between about -7.0 and -3.0. The size of the arrays ptsData and pts contain are correct, though - which is good but also baffling! :slight_smile:

I would be very grateful if someone could suggest where I’m going wrong…?


#2

Actually, I’ve just worked it out for myself: I was right in the first place, but had made a simple typo elsewhere!

Typical! :wink:


#3

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.