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 a code that
The problem is in #3. Render data is not restored. It stays as in #2
You can check the code here:
import c4d # Main function def main(): doc = c4d.documents.GetActiveDocument() rd_saved = doc.GetActiveRenderData() rd = doc.GetActiveRenderData() rd[c4d.RDATA_RENDERENGINE] = c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE rd[c4d.RDATA_XRES] = 200 rd[c4d.RDATA_YRES] = 200 rd[c4d.VP_PREVIEWHARDWARE_ANTIALIASING] = 3 doc.SetActiveRenderData(rd_saved) # Execute main() if __name__=='__main__': main()
Is there a way around this?
Thank you
RenderData objects are objects stored with the BaseDocument, representing a set of render settings.
RenderData
BaseDocument
GetActiveRenderData() returns a reference to such an object. So calling GetActiveRenderData() twice just returns two references to the same object.
GetActiveRenderData()
If you want to store the previous state, you could simply get a clone:
rd_saved = doc.GetActiveRenderData().GetClone()
and use that clone to restore the original state:
rd_saved.CopyTo(rd, c4d.COPYFLAGS_NONE)
But without knowing what you actually want to achive, it is hard to say if that is a good solution or not.
Also, assuming this is a Script Manager script: doc = c4d.documents.GetActiveDocument() is useless.
doc = c4d.documents.GetActiveDocument()
@PluginStudent
Thanks for the explanation. Your solution works as expected