Hi @Dunhou, Manuel being in vaccation I will take over your topic.
@dunhou said in How to render a animation preview ?:
maybe I can get a range like 5f - 25f and render it and show it in sequence in Picture viewer in a folder ?
Sadly it is not possible to create folder in the Picture Viewer via the API. As Manuel said the only way to have image sequence displayed is to have a movie to be loaded in the Picture Viewer. Which is not possible in Python cinse the ShowBitmap function accepting a Filename is not available in Python. But this is something in our radar and I will look to support ShowBitmap with a filename in Python as soon as possible.
For the second part of your question about how to iterate a range of frames look at basedocument_animate_r13.py example, you will need to edit line 45 with a call to c4d.documents.RenderDocument. But in any case you will not be able to see them animated in the Picture Viewer.
@dunhou said in How to render a animation preview ?:
And a move on question with "preview" is can I set a parameter with plugin Make Preview
, How can I set some settings for plugin like this and call it with this settings ?
When you call RenderDocument, the 2nd argument is the BaseContainer representing the c4d.documents.RenderData. This argument let you change the render setting as demonstrated in the render_current_frame_r12.py example. The class description of c4d.documents.RenderData enunerates the possible IDs and expected values to be defining in the render setting BaseContainer. So in your specif case this give us:
import c4d
def main() -> None:
# Retrieves a copy of the current documents render settings
data = doc.GetActiveRenderData().GetClone().GetData()
if data is None:
raise RuntimeError("Failed to retrieve the clone of the active Render Settings.")
# Define the render setting so the file will be saved on the harddrive.
data.SetInt32(c4d.RDATA_FRAMESEQUENCE, c4d.RDATA_FRAMESEQUENCE_PREVIEWRANGE)
# To define with manually specified frame rande this can be defined like so:
# data.SetInt32(c4d.RDATA_FRAMESEQUENCE, c4d.RDATA_FRAMESEQUENCE_MANUAL)
# data.SetInt32(c4d.RDATA_FRAMEFROM, c4d.BaseTime(5, doc.GetFps()))
# data.SetInt32(c4d.RDATA_FRAMETO, c4d.BaseTime(25, doc.GetFps()))
data.SetBool(c4d.RDATA_GLOBALSAVE, True);
data.SetBool(c4d.RDATA_SAVEIMAGE, True);
data.SetBool(c4d.RDATA_ALPHACHANNEL, False);
data.SetInt32(c4d.RDATA_FORMATDEPTH, c4d.RDATA_FORMATDEPTH_8);
# define the file Format to MP4
data.SetInt32(c4d.RDATA_FORMAT, 1125);
file = r"/Users/m_adam/Desktop/temp_render"
data.SetFilename(c4d.RDATA_PATH, file);
# define the render resolution
data.SetInt32(c4d.RDATA_XRES, 1280);
data.SetInt32(c4d.RDATA_YRES, 720);
# This bmp will server as a dummy bmp, the project being save below
bmp = c4d.bitmaps.MultipassBitmap(int(data[c4d.RDATA_XRES]), int(data[c4d.RDATA_YRES]), c4d.COLORMODE_RGB)
if bmp is None:
raise RuntimeError("Failed to create the bitmap.")
if c4d.documents.RenderDocument(doc, data, bmp, c4d.RENDERFLAGS_EXTERNAL | c4d.RENDERFLAGS_PREVIEWSETTINGS) != c4d.RENDERRESULT_OK:
raise RuntimeError("Failed to render the temporary document.")
if __name__ == '__main__':
main()
Cheers,
Maxime.