SOLVED Changing VideoPost leads to TypeError

Hello,
I am trying to change the Viewport Renderer parameters. I was able to use the method illustrated in the code sample below, but something changed (I believe in the API) and this now leads to TypeError: __setitem__ expected str, not bool. If I'm not to assign these values as a boolean, can someone please advise on how these are to be set? Thank you.

import c4d
from c4d import documents

def main():
    doc = documents.GetActiveDocument()
    rdata = doc.GetActiveRenderData()
    rd = rdata.GetData()
    post = rdata.GetFirstVideoPost()
    post[c4d.VP_PREVIEWHARDWARE_DISPLAYFILTER_NGONLINES] = False
    post[c4d.VP_PREVIEWHARDWARE_DISPLAYFILTER_OTHER] = False
    post[c4d.VP_PREVIEWHARDWARE_DISPLAYFILTER_SDSCAGE] = False
    post[c4d.VP_PREVIEWHARDWARE_DISPLAYFILTER_ONION] = False

if __name__=='__main__':
    main()

I think I have discovered the issue: I believe rdata.GetFirstVideoPost() was getting a renderer other than the Viewport Renderer, so those symbols weren't available. I am now using the following (I found it here) to check that the video post is the Viewport Renderer.

            post = rdata.GetFirstVideoPost()
            while post is not None:
              if post.CheckType(300001061):
                break
              post = post.GetNext()
            if post is None:
              rd.InsertVideoPost(c4d.BaseList2D(300001061))

Unless the API devs have any corrections, I'll mark this as solved.

I think I have discovered the issue: I believe rdata.GetFirstVideoPost() was getting a renderer other than the Viewport Renderer, so those symbols weren't available. I am now using the following (I found it here) to check that the video post is the Viewport Renderer.

            post = rdata.GetFirstVideoPost()
            while post is not None:
              if post.CheckType(300001061):
                break
              post = post.GetNext()
            if post is None:
              rd.InsertVideoPost(c4d.BaseList2D(300001061))

Unless the API devs have any corrections, I'll mark this as solved.

hi,

Pretty strange i was not able to reproduce the issue.

@blastframe said in Changing VideoPost leads to TypeError:

300001061

you can use the symbol c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE instead.

Cheers,
Manuel

@m_magalhaes Yes, I think the error was because Octane was the result of rdata.GetFirstVideoPost() and those symbols don't exist in it. If I check for the Viewport Renderer, it seems to work fine. Thanks for the reply and symbol tip!