Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Extracting a thumbnail of C4d file. [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 406 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 01/12/2014 at 21:25, xxxxxxxx wrote:

            Hi,
            Thanks for the help guys.

            Thanks 
            Nishant

            1 Reply Last reply Reply Quote 0
            • First post
              Last post