import c4d from c4d import gui # Main function def main(): """ Creates a V-Ray Reflection Render element and sets its Consider for Anti-Aliasing parameter to true """ activeDocument = c4d.documents.GetActiveDocument() vrayRenderElementsHook=activeDocument.FindSceneHook(1054363) # ID_VRAY_RENDER_ELEMENTS_SCENE_HOOK if not vrayRenderElementsHook: raise Exception('Could not find V-Ray Render Elements Scene Hook') elementsHookBranchInfo=vrayRenderElementsHook.GetBranchInfo() vrayRenderElementsRootHead=None for branchInfo in elementsHookBranchInfo: # ID_VRAY_RENDER_ELEMENT_ROOT if branchInfo['id']==1054149: vrayRenderElementsRootHead=branchInfo['head'] break if not vrayRenderElementsRootHead: raise Exception('Could not find V-Ray Render Elements Root Head') # ID_VRAY_RENDER_ELEMENT_COLOR newRenderElement=c4d.BaseObject(1054151) if not newRenderElement: raise Exception('Could not create V-Ray Color Render element') # This name should be different for multiple allocations newRenderElement.SetName('Reflection') renderElementID=102 # Reflection render element ID # These are hidden parameters describing the exact render element newRenderElement[c4d.RENDERCHANNELCOLOR_ALIAS]=renderElementID newRenderElement[c4d.VRAY_RENDER_ELEMENT_CREATE_NODE_TYPE]=renderElementID # These two are necessary to have the parameters properly working newRenderElement[c4d.VRAY_RENDER_ELEMENT_FILTER_PARAMETER_ID]=c4d.RENDERCHANNELCOLOR_FILTERING newRenderElement[c4d.VRAY_RENDER_ELEMENT_DENOISE_PARAMETER_ID]=c4d.RENDERCHANNELCOLOR_DENOISE # Enable the consider for Anti-Aliasing checkbox newRenderElement[c4d.RENDERCHANNELCOLOR_CONSIDER_FOR_AA]=True undoStrated=activeDocument.StartUndo() newRenderElement.InsertUnderLast(vrayRenderElementsRootHead) if undoStrated: activeDocument.AddUndo(c4d.UNDOTYPE_NEWOBJ, newRenderElement) activeDocument.EndUndo() # The hide part is necessary to avoid selecting the render element object when all document object are selected # from the object manager. newRenderElement.ChangeNBit(c4d.NBIT_OHIDE, c4d.NBITCONTROL_SET) c4d.EventAdd() # Execute main() if __name__=='__main__': try: main() except Exception as error: gui.MessageDialog(' '.join(map(str, error.args)), c4d.GEMB_ICONSTOP)