Extracting a thumbnail of C4d file. [SOLVED]
-
On 27/11/2014 at 03:23, xxxxxxxx wrote:
Hi all,
I am trying to extract the thumbnail of a C4d file. I don't want to use rendering as it is time consuming. Do we have any other option of saving a frame in png, tif or jpeg format. Any other method which can help me here would be fine too.
Thanks
Nishant
-
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 -
On 27/11/2014 at 04:41, xxxxxxxx wrote:
Hello,
to get the preview image of a (saved) scene simply use
GetDocPreviewBitmap()
[URL-REMOVED].best wishes,
Sebastian
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
On 01/12/2014 at 21:25, xxxxxxxx wrote:
Hi,
Thanks for the help guys.Thanks
Nishant