Adding Layers to a MultipassBitmap

Sorry folks, I keep spamming my topic! I've realised there's another issue. AddLayer() returns NULL, and from a topic I made previously (some time a go now) it was reported as a bug, but it's never been fixed by the looks of it.

How can I add layers to a MultipassBitmap!? How does the command Render to Picture Viewer do it?

WP.

edit by @ferdinand : Forked from Render settings Multi-Pass flag. Please open new topics for new questions, your follow up questions were too broad to be put into the same topic.

Hi,
If you want the layer and folder to be displayed in the picture viewer you need to define the parameter MPBTYPE_SAVE to True.
MPBTYPE_SHOW is defined by default to true when you add a layer.
This parameter will just disable the layer as seen below. (the red eye)
7375d915-1e62-4b6b-b174-3a16d05a5e20-image.png

This example will create a folder with a layer in it and another layer below the folder.

If it is working with pyhton, it should work with c++, you can share a bit of your code so we can reproduce it.

from typing import Optional
import c4d

doc: c4d.documents.BaseDocument  # The active document
op: Optional[c4d.BaseObject]  # The active object, None if unselected

def main() -> None:
    mpb = c4d.bitmaps.MultipassBitmap(640, 480, c4d.COLORMODE_ARGB)
    folder1 = mpb.AddFolder(None)
    folder1.SetParameter(c4d.MPBTYPE_NAME, "folder")
    folder1.SetParameter(c4d.MPBTYPE_SAVE, True)

    
    layer1 = folder1.AddLayer(None, c4d.COLORMODE_ARGB)
    layer1.SetParameter(c4d.MPBTYPE_NAME, "layer1")
    layer1.SetParameter(c4d.MPBTYPE_SAVE, True)
   
        
    layer2 = mpb.AddLayer(folder1, c4d.COLORMODE_ARGB)
    layer2.SetParameter(c4d.MPBTYPE_NAME, "layer2")
    layer2.SetParameter(c4d.MPBTYPE_SAVE, True)
    
    
    c4d.bitmaps.ShowBitmap(mpb)


if __name__ == '__main__':
    main()

Cheers,
Manuel