Hi,
I have the following code that
- Stores Display Filter
- Turns them off
- Render
- Restore Display Filter.
The problem is when I render (#3) them the #2 is not in effect.
You can check the illustration of the problem here:
https://www.dropbox.com/s/r8cpy1lwgkmi1yj/c4d266_display_filter_not_working_rendering_python.mp4?dl=0
A "correct" render would be there should be no axis handles in the renders.
You can check the working code below:
import c4d
from c4d import gui
# Welcome to the world of Python
# Main function
def main():
doc = c4d.documents.GetActiveDocument()
obj_list = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN | c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
bd = doc.GetActiveBaseDraw()
displayFilter = bd.GetDisplayFilter()
# Store Render Data
rd_saved = doc.GetActiveRenderData().GetClone()
rd = doc.GetActiveRenderData()
stored_bounds = bd[c4d.BASEDRAW_DISPLAYFILTER_BOUNDS]
stored_multi_axis = bd[c4d.BASEDRAW_DISPLAYFILTER_MULTIAXIS]
stored_obj_handle = bd[c4d.BASEDRAW_DISPLAYFILTER_OBJECTHANDLES]
stored_obj_highli = bd[c4d.BASEDRAW_DISPLAYFILTER_OBJECTHIGHLIGHTING]
stored_world_axis = bd[c4d.BASEDRAW_DISPLAYFILTER_WORLDAXIS]
# Modify Render Data
rd[c4d.RDATA_RENDERENGINE] = c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE
rd[c4d.RDATA_XRES] = 400
rd[c4d.RDATA_YRES] = 400
rd[c4d.VP_PREVIEWHARDWARE_ANTIALIASING] = 3
# Creates a Multi Pass Bitmaps that will store the render result
bmp = c4d.bitmaps.MultipassBitmap(int(rd[c4d.RDATA_XRES]), int(rd[c4d.RDATA_YRES]), c4d.COLORMODE_RGB)
# Adds an alpha channel
bmp.AddChannel(True, True)
# Renders the document
if c4d.documents.RenderDocument(doc, rd.GetData(), bmp, c4d.RENDERFLAGS_EXTERNAL) != c4d.RENDERRESULT_OK:
raise RuntimeError("Failed to render the temporary document.")
bd[c4d.BASEDRAW_DISPLAYFILTER_BOUNDS] = False
bd[c4d.BASEDRAW_DISPLAYFILTER_MULTIAXIS] = False
bd[c4d.BASEDRAW_DISPLAYFILTER_OBJECTHANDLES] = False
bd[c4d.BASEDRAW_DISPLAYFILTER_OBJECTHIGHLIGHTING] = False
bd[c4d.BASEDRAW_DISPLAYFILTER_WORLDAXIS] = False
bd.Message(c4d.MSG_CHANGE)
c4d.EventAdd()
# Save Image
c4d.bitmaps.ShowBitmap(bmp)
# Restore Render Data
rd_saved.CopyTo(rd, c4d.COPYFLAGS_NONE)
bd[c4d.BASEDRAW_DISPLAYFILTER_BOUNDS] = stored_bounds
bd[c4d.BASEDRAW_DISPLAYFILTER_MULTIAXIS] = stored_multi_axis
bd[c4d.BASEDRAW_DISPLAYFILTER_OBJECTHANDLES] = stored_obj_handle
bd[c4d.BASEDRAW_DISPLAYFILTER_OBJECTHIGHLIGHTING] = stored_obj_highli
bd[c4d.BASEDRAW_DISPLAYFILTER_WORLDAXIS] = stored_world_axis
bd.Message(c4d.MSG_CHANGE)
c4d.EventAdd()
# Execute main()
if __name__=='__main__':
main()