Calling cmd.draw() will schedule a rendering event to be executed in the rending loop. This means the command will return before the image was rendered. The only way to access the result is with a callback, which will be asynchronous with the script you're executing.
Calling cmd.png() is related to that, but will not trigger the callback. It can enter a couple of different code paths, depending on the availability of the OpenGL context (on-screen display). 1) No OpenGL context (e.g. batch processing) -> Ray tracer will be used. Nothing asynchronous here, the PNG file will be available after the function call. 2) OpenGL context in different thread -> schedules an async task to be executed by the rendering thread. This means cmd.png() returns before the image was written (like cmd.draw) 3) Requesting width/height also triggers the async task So the only option which is guaranteed to be synchronous is the ray tracing. Implementing direct numpy array or PNG buffer export would be possible, but the performance benefit for your script would probably not be significant. Cheers, Thomas > On May 6, 2020, at 5:42 PM, Antonio Serrano <aserra...@ucam.edu> wrote: > > Thx for your quick response, Thomas. Please, could you elaborate the previous > example a little bit further? I'm a little confused about what you can > accomplish using the callback function you posted. Thx -- Thomas Holder PyMOL Principal Developer Schrödinger, Inc. _______________________________________________ PyMOL-users mailing list Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net Unsubscribe: https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe