Getting the frame from movie in material [SOLVED]

  • On 31/07/2015 at 08:14, xxxxxxxx wrote:

    I have a material with a movie loaded in the Color channel. When I apply the material to an object and set the Editor->Animate Preview option on, scrubbing the timeline, I see the movie playing in the object surface.
    However, when I try to get the bitmap from the material, using this python code, it always gets me the first frame, no matter where I have the play-head:

    import c4d   
    #Welcome to the world of Python   
    def main() :   
        # is there anything in the Link user data?   
        if mat==None: return   
        # is it a Material?   
        if mat.GetType()!=5703: return   
        # is the Color channel turned on?   
        if color_ch==0: return   
        # is there anything in the Texture slot?   
        if texture==None: return   
        # is it a bitmap/movie?   
        if texture.GetType()!=5833: return   
        # render the bitmap to the Picture Viewer   
        irs = c4d.modules.render.InitRenderStruct()   
        if texture.InitRender(irs)==c4d.INITRENDERRESULT_OK:   
            bitmap = texture.GetBitmap()   
            if bitmap is not None:   

    Yes, I do get a "RuntimeError: illegal operation, invalid cross-thread call" error in the last line of code but, even so, I get an image in the Picture Viewer and it is ALWAYS the first frame of the movie.

    How can I get the correctly calculated frame, according to the parameters set in the Animation tab inside the material channel?

  • On 31/07/2015 at 15:52, xxxxxxxx wrote:

    I managed to find a way to make it work...

        framecount, ml_fps = ml.GetInfo()
        if result==c4d.IMAGERESULT_OK:

    But it only works with movies. For image sequences, it doesn't. Must I do it by hand?

  • On 03/08/2015 at 02:42, xxxxxxxx wrote:

    Hi Rui,

    you might set the right frame with: Shader[c4d.BITMAPSHADER_TIMING_FROM] etc.
    Please have a look at this thread:

    Grabbing bitmap data off a shader

    Hope this helps?
    Best wishes

  • On 03/08/2015 at 04:52, xxxxxxxx wrote:

    Thank you. I did found that thread.
    But I will have to calculate the frame by myself, right?
    I was expecting that, once we had a material with a movie or image sequence loaded in the Color channel and we had all the parameters of the animation set (by pressing Calculate for an image sequence, for example), there was a way to get the calculated frame automatically.

  • On 03/08/2015 at 05:28, xxxxxxxx wrote:

    Actually I´m not aware of any other way to get the corresponding image than calculating it by yourself.

  • On 03/08/2015 at 05:44, xxxxxxxx wrote:

    I understand that now. I just assumed that, since it happens automatically when when the editor animation preview is turned on, it would be something that could be accessed in code.

  • On 04/08/2015 at 05:39, xxxxxxxx wrote:

    Hi Rui,

    just want to confirm, there's no such functionality available. As Martin said, you will need to do it yourself. Sorry.

Log in to reply