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



  • 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



  • 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



  • 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



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

    Cheers
    zipit



  • 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"
    


  • 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



  • 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.



  • @m_magalhaes Thank you a lot!



  • 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



  • @m_magalhaes Epic, It works! :) Thank you very much Manuel!


Log in to reply