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

    Python Preview Plugin Help

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 456 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 26/11/2015 at 10:51, xxxxxxxx wrote:

      Hey guys 🙂

      So, I am trying to make a preview plugin like Magic Preview, butI just can't figure out, how to add a preview render to a dialog. I would like to make this, becuase I am making a lighting tool with alot of HDRI's and all that sort of stuff. It is pretty much completed, but I really want to make such a litle preview dialog for this tool. 
      If anyone could help me ... that would be really awesome 😄

      Have a good day, 
      neon

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

        On 27/11/2015 at 10:22, xxxxxxxx wrote:

        Hi,

        welcome to the Plugin Café forums 🙂

        You will have to do this in two steps:

        1. Render your preview. Have a look at RenderDocument(), there's also some example code.
        2. Display the rendered image in your dialog. The easiest way is probably to use the BitmapButtonCustomGui. There are a bunch of threads in this forum regarding BitmapButtons. Like for example Add image to GUI.

        I hope this helps.

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

          On 28/11/2015 at 06:42, xxxxxxxx wrote:

          Hey Andreas,

          thanks for your reply helped me alot ^^
          I managed to make everything "kinda" working, but my problem now is, that my Cinema 4D crashes when I click on my button to render that image and diasplay it on the button. I have no Idea why this is. Do you have an idea, or anyone?

          but thanks anyway!

          Greetings,
          neon

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

            On 28/11/2015 at 06:55, xxxxxxxx wrote:

            Well, depends on your code, really. 😉

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

              On 28/11/2015 at 07:32, xxxxxxxx wrote:

              I am fairly new to coding in CInema 4D and python so my code isn't the nicest and the most efficient one 😄 
              This is my Code:

              class OwlView(gui.GeDialog) :   
                  def CreateLayout(self) :
                      self.SetTitle("Owl View")

              self.GroupBegin(0, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "Owl View", 0)
                      path, fn = os.path.split(__file__)
                      path = os.path.join(path, "res/icons/", "pre.tif")
                      bc = c4d.BaseContainer()                                       
                      bc.SetFilename(MY_BITMAP_BUTTON, path)              
                      self.myBitButton=self.AddCustomGui(MY_BITMAP_BUTTON, c4d.CUSTOMGUI_BITMAPBUTTON, "PReview", c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT | c4d.BFH_CENTER | c4d.BFV_CENTER | c4d.BFV_BOTTOM, 30, 30, bc)
                      self.myBitButton.SetImage(path, False)             
                      self.GroupEnd()
                      return True

              def Command(self, id, msg=None) :
                      if id==MY_BITMAP_BUTTON:
                         doc = documents.GetActiveDocument()
                         rd = doc.GetActiveRenderData().GetData()
                         xres = int(rd[c4d.RDATA_XRES])    
                         yres = int(rd[c4d.RDATA_YRES])
                         bmp = bitmaps.BaseBitmap()
                         outp = documents.RenderDocument(doc, rd, bmp, c4d.RENDERFLAGS_EXTERNAL)
                         if outp ==c4d.RENDERRESULT_OK:
                              self.myBitButton.SetImage(bmp, False) 
                              return True 
                         return True

              I don't know what I have done wrong, or not as supposed, and I know your not here to correct my code but I don't understand everything so that I could correct it myself ^^

              Greetings, 
              neon

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