forked from Maxon-Computer/Cinema-4D-Python-API-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender_current_frame_r12.py
More file actions
51 lines (37 loc) · 1.47 KB
/
render_current_frame_r12.py
File metadata and controls
51 lines (37 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
Copyright: MAXON Computer GmbH
Author: Maxime Adam
Description:
- Adjusts the active Render Settings to render the current frame based on user settings.
Class/method highlighted:
- BaseDocument.GetActiveRenderData()
"""
import c4d
def main():
# Retrieves a copy of the current documents render settings
rd = doc.GetActiveRenderData().GetClone().GetData()
if rd is None:
raise RuntimeError("Failed to retrieve the clone of the active Render Settings.")
# Sets various render parameters
rd[c4d.RDATA_FRAMESEQUENCE] = 1
rd[c4d.RDATA_SAVEIMAGE] = False
rd[c4d.RDATA_MULTIPASS_SAVEIMAGE] = False
# Gets the x and y res from the render settings
xRes = int(rd[c4d.RDATA_XRES])
yRes = int(rd[c4d.RDATA_YRES])
# Initializes the bitmap with the result size
# The resolution must match with the output size of the render settings
bmp = c4d.bitmaps.BaseBitmap()
if bmp is None:
raise RuntimeError("Failed to create the Bitmap.")
if bmp.Init(x=xRes, y=yRes) != c4d.IMAGERESULT_OK:
raise RuntimeError("Failed to initialize the Bitmap.")
# Calls the renderer
res = c4d.documents.RenderDocument(doc, rd, bmp, c4d.RENDERFLAGS_EXTERNAL)
# Leaves if there is an error while rendering
if res != c4d.RENDERRESULT_OK:
raise RuntimeError("Failed to render the document.")
# Displays the bitmap in the Picture Viewer
c4d.bitmaps.ShowBitmap(bmp)
if __name__ == '__main__':
main()