Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi,
I have the following code that
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()
you render your document before you make the changes to display filter settings of the active base draw. Because of that they do not take effect in the render ;)
PS: You could also just clone and restore the data container of the BaseDraw instead of having this long list of stored_ variables.
BaseDraw
stored_
Cheers, zipit
@zipit My bad. Thanks for the catch. Have a great day!
Hello,
thanks for the answer :)
by the way you could also clone the renderdata, modify the clone and send it to as a parameter to the function RenderDocument. That way, you don't have to "restore" them.
RenderDocument
Just in case, don't forget that data may not be saved in the BaseContainer.
BaseContainer
Cheers, Manuel