Hi,
I'm starting to feel pretty stupid. I'm trying to do a hardware preview render using the nice new filter options added in C4D S22.
My code looks roughly like so, here for use in Script Manager:
import c4d
def CreateDefaultRenderData():
rd = c4d.documents.RenderData()
if rd is None:
return None
vp = c4d.BaseList2D(c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE)
if vp is None:
return None
rd.InsertVideoPostLast(vp)
vp[c4d.VP_PREVIEWHARDWARE_ONLY_GEOMETRY] = True ### THIS IS WHAT I AM ACTUALLY INTERESTED IN
rd[c4d.RDATA_RENDERENGINE] = c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE
rd[c4d.RDATA_XRES] = 600
rd[c4d.RDATA_YRES] = 600
return rd
def main():
docClone = doc.GetClone()
rdPreview = CreateDefaultRenderData()
if rdPreview is None:
return
rdPreview[c4d.RDATA_XRES] = 600
rdPreview[c4d.RDATA_YRES] = 600
bmPreview = c4d.bitmaps.BaseBitmap()
bmPreview.Init(rdPreview[c4d.RDATA_XRES], rdPreview[c4d.RDATA_YRES])
result = c4d.documents.RenderDocument(docClone, rdPreview.GetData(), bmPreview, c4d.RENDERFLAGS_EXTERNAL, th=None)
if result == c4d.RENDERRESULT_OK:
c4d.bitmaps.ShowBitmap(bmPreview)
# insert render settings for comparison
rdPreview.SetName('Test Settings')
doc.InsertRenderData(rdPreview)
c4d.EventAdd()
if __name__=='__main__':
main()
I'm trying to get the VP_PREVIEWHARDWARE_ONLY_GEOMETRY
flag to work.
The funny thing is, if I manually render the active scene with the render settings created by above script, I do get the result I want. But not so in the image rendered by the script.
... ... while writing these lines, it struck me. And indeed I can make it work by inserting the new RenderData into the cloned document and making it active. So my question is actually no longer, how to make it work. But more, why do I need to insert the RenderData into the scene? I mean, it's passed to RenderDocument separately and I doubt, I saw an SDK example explicitly inserting new RenderData for such purposes. But then again, as I said in the beginning, I'm starting to feel stupid and most likely I am.
Cheers