Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Calling MDataHandle.data() causes crash

Calling MDataHandle.data() causes crash

Anonymous
Not applicable
522 Views
1 Reply
Message 1 of 2

Calling MDataHandle.data() causes crash

Anonymous
Not applicable

Hi all,

 

I'm writing a node that takes a worldMatrix as an input and I need to get the world transform from that matrix.

 

Here's part of my compute function:

 

# returns MDataHandle
inMatrixHandle = dataBlock.inputValue(ConeReaderNode.inMatrix)

# crashes here
mFnMatrix = om.MFnMatrixData(inMatrixHandle.data())
mXformMatrix = mFnMatrix.transformation()

inVector = mXformMatrix.getTranslation()

 

The docs for MDataHandle.data() mentions "This method is not valid for simple numeric types" , so I'm not sure if that's what is causing the issue. 

 

Also, I tried this and it returned the 0 vector as a result. Not sure if I indexed the matrix correctly. 

# returns an MMatrix
inMatrixHandle = dataBlock.inputValue(ConeReaderNode.inMatrix).asMatrix()

# access the translation values directly from our MMatrix. Also doesn't work. Returns the 0 vector.
inVector = om.MVector(inMatrixHandle(3,0),inMatrixHandle(3,1),inMatrixHandle(3,2))

 

 

Any ideas? I was able to get my node working by taking a regular k3Double input, but as this is a cone reader node I needed a fast way to get its absolute position in world space. 

 

Still new to the API. Trying to make sense out of it all... 

 

- Ben

0 Likes
523 Views
1 Reply
Reply (1)
Message 2 of 2

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

 

The second code block should be working. Could you give a reproducible sample? I could have a look at where could be wrong.

 

Yours,

Li

0 Likes