@m_magalhaes Epic, It works! Thank you very much Manuel!
Posts made by marcelobruno
-
RE: Dialog refresh works correct in R18... not in R21 ?
-
RE: Dialog refresh works correct in R18... not in R21 ?
@m_magalhaes Thank you a lot!
-
RE: Dialog refresh works correct in R18... not in R21 ?
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?
-
RE: Dialog refresh works correct in R18... not in R21 ?
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/6g8hwtimport 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"
-
RE: Dialog refresh works correct in R18... not in R21 ?
Here a link:
Download Code Herehttps://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 stuffThank you
-
RE: 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
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 -
Dialog refresh works correct in R18... not in R21 ?
Situation:
LogoButton.SetImage... (image of gui changes)
More code....
LogoButton.SetImage again. (image of gui changes)
End of code.Problem in R21:
In R18 the image changes, then the rest of code keeps runing.
In R21 nothing is updated until the end of the code.So in R18 this works correctly, but in R21 the bitmap of the button in the dialog Never changes until all the operations ends.
The only way I found to see the gui update in R21 is:
(of course just as test to help me detect the problem):Calling the command to show the About screen of C4D or opening a Modal dialog so the bitmap changes, then when the modal dialog is closed the operation goes on.... I tried this that already works in R18:
c4d.EventAdd()
c4d.EventAdd(c4d.EVENT_FORCEREDRAW)
c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW | c4d.DRAWFLAGS_NO_THREAD | c4d.DRAWFLAGS_NO_REDUCTION | c4d.DRAWFLAGS_STATICBREAK)All this doesn't seems to force the update of dialog on R21, it will only update the image on the end of the operations or until a modal dialog or about screen of c4d appears...