Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. MMayrh
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 3
    • Best 0
    • Controversial 0
    • Groups 0

    MMayrh

    @MMayrh

    0
    Reputation
    4
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    MMayrh Unfollow Follow

    Latest posts made by MMayrh

    • How to set the active documents preview image

      Hey,

      I am trying to code a python script that automatically renders the active document and sets the preview for the document to that rendered image.

      The set parameter that I use wants a BaseList2D object instead of a bitmap and I have no idea how I could convert that info. (Or maybe im dead lost already 😓 ) Maybe you can help?

      Thanks in advance

      import c4d
      from c4d import documents
      import os
      
      def main():
          doc = documents.GetActiveDocument()
          rd = doc.GetActiveRenderData()
          # Set resolution
          rd[c4d.RDATA_XRES] = 640
          rd[c4d.RDATA_YRES] = 480
          
          # Render document
          bmp = c4d.bitmaps.BaseBitmap()
          bmp.Init(640, 480)
          if c4d.documents.RenderDocument(doc, rd.GetDataInstance(), bmp, c4d.RENDERFLAGS_EXTERNAL) != c4d.RENDERRESULT_OK:
              raise Exception("Rendering failed")
          
          # Save bitmap to disk for manual setting of preview later
          temp_filepath = os.path.join(os.path.expanduser("~"), "temp_preview.png")
          if bmp.Save(temp_filepath, c4d.FILTER_PNG, c4d.BaseContainer()) != c4d.IMAGERESULT_OK:
              raise Exception("Failed to save bitmap")
          
          # Display the bitmap for verification
          c4d.bitmaps.ShowBitmap(bmp)
          
          # Set the rendered Bitmap bmp as the preview of the document
          doc.SetParameter(c4d.DOCUMENT_PREVIEW_IMAGE, bmp, c4d.DESCFLAGS_SET_0) #<--- cant figure out how to get this working
      
      if __name__ == '__main__':
          main()
      

      Version: Cinema4D 2025.0.2
      OS: Windows 11
      Python

      posted in Cinema 4D SDK windows python
      M
      MMayrh
    • RE: Python plugin in costum C4D-Layout

      @ferdinand thank you for your welcoming words, for your help and edits.

      Since I am no trained developer I was simply copy and pasting my first lines of code including the RegisterCommand function from the maxon python example github and thought it would fit my application since I thought the description in the sdk seemedlike a match to me ["Command can be dragged into an icon bar and delivers its own dialogs instead of icons." (- maybe I got that wrong)]. Also scince I have little developing experience the term "smallnode" is nothing I can make sense of and an accurate description seems to be missing.

      Nevertheless I tried your suggestion and it works like a charm.

      Thanks a lot 🙌
      Marc

      posted in Cinema 4D SDK
      M
      MMayrh
    • Python plugin in costum C4D-Layout

      Sorry for the basic question -
      Like the title says - I am trying to add my plugin to my costum c4d Layout but when I try to do it the plugin doesnt show. It is added but simply not visible (I know this because if an loading error occurs the place it should have been says: "Plugin not found"). In the extensions tab of cinema its shown as expected with icon and title.

      I guess I am missing something basic. Anyone who can help?

      The Plugin is registered as follows:

      c4d.plugins.RegisterCommandPlugin(id=PLUGIN_ID, str=plugin_name, icon = get_icon(), 
                                        info = c4d.PLUGINFLAG_COMMAND_ICONGADGET, help=helptext, 
                                        dat = MyCommandData())
      

      Thanks in advance,
      Marc

      posted in Cinema 4D SDK 2024 python windows
      M
      MMayrh