Working with file textures in API?


Good time of the day everyone,

In this thread I would like to discuss the ways of working with file textures in Maya API. Please share your experience!

The only way I found to read the texture contained in the file texture node is by using MImage::readFromTextureNode() method. This gives us a raw array of pixels of the image.

It is a by copy query, that is changes to this MImage’s pixels will not affect the file texture itself.

Using readFromTextureNode not always returns the “up to date” version of the texture. For instance if user is using Artisan 3d Paint to paint the texture, the updated version will show up only after the user has finished the stroke.

Right now I am writing a node that is based on custom painted textures. I would love to provide interactive feedback to the user while he/she is moving the mouse, and not only after each stroke.

Another question is how to get notified about the texture becomes dirty? Connecting the texture’s out color will become dirty only once in a while, not even after every stroke.
Ideally for an interactive tool based on textures one would need to get updated every time the actual texture displayed in the viewport changes.

A dirty hack would be to connect to a refresh event and monitor the texture changes there which should give a correct behavior with delay of one frame. But this won’t work because querying the texture will not return its up to date version.

Also what if we need to write into a texture?
I have not found a way to write to the file texture (even though 3d paint tool is able to do so).

Is there actually a way around those issues?

Thanks for your input,


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.