Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to get the current position in the image when rendering my material node in MPxNode::compute in order to export the rendering results to an image file.
I plan to use the rendering attribute pixelCenter, defined in Maya Developer Help - Appendix B.
I add the attribute to my node, as I do with other rendering attributes, in the node's initialize() with the following code.
aPixelCenterX = nAttr.create("pixelCenterX", "pcx", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setDefault(0.0f)); aPixelCenterY = nAttr.create("pixelCenterY", "pcy", MFnNumericData::kFloat, 0, &status); CHECK_MSTATUS(status); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setDefault(0.0f)); aPixelCenter = nAttr.create("pixelCenter", "pc", aPixelCenterX, aPixelCenterY); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setDefault(0.0f, 0.0f)); CHECK_MSTATUS(nAttr.setHidden(true)); CHECK_MSTATUS(addAttribute(aPixelCenter));
But the last line fails with error ": (kInvalidParameter): Object already exists".
It appears to work if I change the brief names of the attributes to ones that are different from the ones specified in Appendix B.
I observed the problem with Maya 2017 Update 2. I did not try yet with other versions of Maya.
Solved! Go to Solution.