On 27/11/2014 at 04:11, xxxxxxxx wrote:
Hello Nishant,
you might try this one:
Just a test doc with a cube...
As it uses the hardware render, it is not that time consuming:
import c4d
import os
from c4d import bitmaps, documents, storage
def WriteBitmap(bmp, format=c4d.FILTER_JPG,settings=c4d.BaseContainer()) :
mfs = storage.MemoryFileStruct()
mfs.SetMemoryWriteMode()
hf = storage.HyperFile()
if hf.Open(0, mfs, c4d.FILEOPEN_WRITE, c4d.FILEDIALOG_NONE) :
if not hf.WriteImage(bmp,format,settings) :
return None
hf.Close()
return mfs
def main() :
doc = c4d.documents.GetActiveDocument()
doc.InsertObject(c4d.BaseObject(c4d.Ocube))
flags = c4d.DRAWFLAGS_FORCEFULLREDRAW
c4d.DrawViews(flags)
rd = doc.GetActiveRenderData().GetData()
xres = int(rd[c4d.RDATA_XRES])
yres = int(rd[c4d.RDATA_YRES])
bmp = bitmaps.BaseBitmap()
bmp.Init(x=xres, y=yres, depth=24)
rd[c4d.RDATA_RENDERENGINE] = c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE
res = documents.RenderDocument(doc, rd, bmp, c4d.RENDERFLAGS_EXTERNAL)
mfs = WriteBitmap(bmp)
if res==c4d.RENDERRESULT_OK:
previewBmp = doc.GetDocPreviewBitmap()
if not previewBmp.InitWith(mfs) :
raise StandardError, "Not working"
path = "/Users/monkeytack/Desktop/projekt_x/2014-11-05_projekt_x.c4d"
c4d.documents.SaveDocument(doc, path , c4d.SAVEDOCUMENTFLAGS_0, c4d.FORMAT_C4DEXPORT)
c4d.documents.KillDocument(doc)
c4d.documents.LoadFile(path)
if __name__=='__main__':
main()
Best wishes
Martin