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

    Dialog refresh works correct in R18... not in R21 ?

    Cinema 4D SDK
    python r21
    3
    12
    1.7k
    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.
    • ManuelM
      Manuel
      last edited by

      hello,

      First, for your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.

      • Q&A New Functionality.
      • How to Post Questions especially the tagging part.

      I've added the tags and marked this thread as a question so when you considered it as solved, please change the state 🙂

      About your issue, there's too much dark spot.

      You are setting image of a imageButton but we need to know on witch function you are doing it.
      c4d.EventAdd() push a update event in the stack and DrawViews refresh cinema4D view (with also updating the scene)
      It's probably too much updates, just because you change the image of a button.

      So, are you doing that on your Command function ? CreateLayout ? Message ?

      Can you share a bit of your code ?

      Cheers,
      Manuel.

      MAXON SDK Specialist

      MAXON Registered Developer

      1 Reply Last reply Reply Quote 0
      • M
        marcelobruno
        last edited by

        Hi!
        Thank you for answering!
        Here a gif showing the problem, left side R18, right side R21
        Main difference:
        It seems R21 is not even updating the console for each print, it just updates when script ends
        R21 Dialog Update Problem.gif

        1 - self.btnImage.SetImage(self.image2, True) #Change image first
        2 - self.testCode() # Sample test code just prints lot of stuff in console...
        3 - self.btnImage.SetImage(self.image1, True) #Change image again

        1 Reply Last reply Reply Quote 0
        • ManuelM
          Manuel
          last edited by Manuel

          hi,

          Thanks for taking the time of doing that Gif, but i think i already understood what was your issue. Now we need to find the cause.
          I've asked you questions to be able to point you to the right direction or investigate the issue.

          Are you doing that on your Command function ? CreateLayout ? Message ?
          As it seems to just be a dialogbox with a button, maybe you can share your code and we can directly test it.

          With what you gave us, we can simply "guess" what you are doing.

          Cheers,
          Manuel

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • M
            marcelobruno
            last edited by

            Here a link:
            Download Code Here

            https://send.firefox.com/download/ef88e38d7f8248e4/#TM8x6tGlIzaRvKHhUciyrA

            Maybe is the same problem/solution:
            Is there a way to make the console behaves like in R18 that updates each time a print is done and it doesn't wait the full script to end to show the prints? for example a a simple for loop that prints stuff

            Thank you

            1 Reply Last reply Reply Quote 0
            • ferdinandF
              ferdinand
              last edited by

              Your link has expired. You can post the code directly in a posting, just use the little brackets icon.

              Cheers
              zipit

              MAXON SDK Specialist
              developers.maxon.net

              1 Reply Last reply Reply Quote 0
              • M
                marcelobruno
                last edited by marcelobruno

                I ziped because it contains 2 images in the folder 'res' of the plugin location:
                *I think that just finding a way to update the interface like when the console prints each print in a While loop like it behaves in R18 it can be the same solution for this problem
                Link:
                https://www.sendspace.com/file/6g8hwt

                import c4d, os
                from c4d import gui, documents
                from c4d import utils
                from c4d import plugins
                
                PLUGIN_ID=1029596 
                
                #Welcome to the world of Python
                class MiDialogo(c4d.gui.GeDialog):
                    dir, file = os.path.split(__file__)  # Gets the plugin's directory
                    images_Path = os.path.join(dir, 'res')  # Adds the res folder to the path
                    image1 = os.path.join(images_Path, 'image1.jpg')
                    image2 = os.path.join(images_Path, 'image2.jpg')
                
                
                    def CreateLayout(self):
                        bc = c4d.BaseContainer()  # Create a new container to store the button image
                        bc.SetBool(c4d.BITMAPBUTTON_BUTTON, True)
                        self.AddStaticText(241798101, c4d.BFH_CENTER, 0, 0, name='Change bitmap first, run more code, then change again')
                        self.btnImage = self.AddCustomGui(241798100, c4d.CUSTOMGUI_BITMAPBUTTON, "Bitmap Button", c4d.BFH_CENTER, 60, 70, bc)
                        self.AddButton(241798102, c4d.BFH_CENTER, initw=150, inith=20, name="Test")
                        self.btnImage.SetImage(self.image1, True)
                        return True
                
                    def testCode(self):
                        i = 1
                        while i < 6000:
                            print(i)
                            c4d.EventAdd()
                            i += 1
                
                
                    def Command(self, id, msg):
                        if id == 241798102:
                            #Change bitmap first, then run code, then change bitmap again
                            self.btnImage.SetImage(self.image2, True) #Change image first
                            self.testCode() # Sample test code
                            #gui.MessageDialog('Here a code instead of a popup', c4d.GEMB_OK)
                            self.btnImage.SetImage(self.image1, True) #Change image again
                
                        return True
                
                class MyMenuPlugin(c4d.plugins.CommandData):
                    dialog = None
                    def Execute(self, doc):
                    # create the dialog
                       if self.dialog is None:
                          self.dialog = MiDialogo()
                       return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=200, defaulth=150, xpos=-1, ypos=-1)
                
                    def RestoreLayout(self, sec_ref):
                    # manage the dialog
                        if self.dialog is None:
                            self.dialog = MiDialogo()
                        return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref)
                        
                if __name__=='__main__':
                    okyn = plugins.RegisterCommandPlugin(PLUGIN_ID, "Change bitmap test",0,None, "Change bitmap test", MyMenuPlugin())
                    if (okyn):
                        print "Change bitmap test"
                
                1 Reply Last reply Reply Quote 0
                • M
                  marcelobruno
                  last edited by

                  No solution? mm No way to force update of the dialog/console during the script as R18 behaves? to see each print at the right moment instead of waiting untild end of script or a modal dialog to appear to update dialog/console?
                  R21 Dialog Update Problem.gif

                  1 Reply Last reply Reply Quote 0
                  • ManuelM
                    Manuel
                    last edited by

                    hello,

                    i can confirm the issue here even in c++.

                    There are two issue here.
                    The python console have been changed a lot. Printing out things in the console is really slow. (in general)
                    With the last versions, you can print out lots of data and it doesn't block your code. That's why your loop execute really faster in R20/21 than on previous version.
                    There's no "flag" to make the console act as before.

                    The BitmapButton not updating is a lot more important and look like a bug.

                    This is under investigation and I'll be back to confirm if it's a bug. (both issue)

                    Cheers
                    Manuel.

                    MAXON SDK Specialist

                    MAXON Registered Developer

                    M 1 Reply Last reply Reply Quote 0
                    • M
                      marcelobruno @Manuel
                      last edited by

                      @m_magalhaes Thank you a lot!

                      1 Reply Last reply Reply Quote 0
                      • ManuelM
                        Manuel
                        last edited by

                        hello,

                        I don't think the console will be changed and with the R21, the redraw have been modified a bit.
                        Your code block the execution of the command and should not. This could be done differently but would lead to a bit more work.

                        The easiest way to "force" the update of the dialog box is to ask for the mouse state. This will force the os to ask for a redraw and c4d will redraw the box.

                        Just add :

                                    self.SetString(1003, "Before")
                                    self.btnImage.SetImage(self.image2, True) #Change image first          
                                    bc = c4d.BaseContainer()
                                    c4d.gui.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_CHANNEL, bc)
                        

                        Cheers,
                        Manuel

                        MAXON SDK Specialist

                        MAXON Registered Developer

                        M 1 Reply Last reply Reply Quote 0
                        • M
                          marcelobruno @Manuel
                          last edited by

                          @m_magalhaes Epic, It works! 🙂 Thank you very much Manuel!

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