Problem With GeDialog



  • On 22/02/2017 at 07:29, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R17.055 
    Platform:   Windows  ;   
    Language(s) :       PYTHON  ;

    ---------
    Hi,guys.

    I'm learning to create a simple dialog with python,but it is not working,I don't know how to solve the issue.could you help me? Any help would be greatly appreciated!

    Here is the code below:

      
    import c4d  
    import os  
    from c4d import gui  
      
      
    id_1=1001  
      
    class Layout(gui.GeDialog,) :  
      def CreateLayout(self) :  
            
          self.SetTitle("HDRI Created")  
          self.AddButton(id_1,c4d.BFH_CENTER,100,name='Hdri')  
            
          return True  
        
      def InitValues(self) :  
            
          self.SetBool(id_1,False)  
            
          return True  
        
      def Command(self,id,msg) :  
            
          if (id == id_1) :  
                
              sky = c4d.BaseObject(c4d.Osky)  
              sky.SetName("Relfect sky")  
                
              mat = c4d.BaseMaterial(c4d.Mmaterial)  
              mat.SetName("Reflection")  
              doc.InsertMaterial(mat)  
                
              tag = sky.MakeTag(c4d.Ttexture)  
              tag[c4d.TEXTURETAG_MATERIAL] = mat  
                
              doc.InsertObject(sky)  
                
              c4d.EventAdd()  
                
          return True  
                
                
    def main() :  
      test = Layout()  
      test.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE)  
      
    if __name__=='__main__':  
      main()  
    


  • On 23/02/2017 at 04:55, xxxxxxxx wrote:

    Hi,

    I'm sorry, but to everyone's advantage on this forum, can you please describe your problem and the expected results of posted code? This would help us immensely in order to focus on solving problems rather than looking for them.

    Also I moved the thread into the Python sub-forum.



  • On 23/02/2017 at 05:19, xxxxxxxx wrote:

    It is working on my computer.🙂



  • On 23/02/2017 at 21:32, xxxxxxxx wrote:

    Hi,Andreas Block.

    I'm sorry,It's my mistake.Now I re-describe my question:

    I'm learning to create a simple dialog with python,When I click the button,the sky object can not appear immediately.Only I close the dialog box and move the scence, the sky object will appear .I don't know where I was wrong? Could you  help me?Thank you!



  • On 23/02/2017 at 23:40, xxxxxxxx wrote:

    Hi,

    just Andreas, please, that's enough.
    The thing is you are using a modal dialog, which means, that C4D is basically sitting still in the background, while your dialog is open. That's also the reason the EventAdd() does not do, what you probably expect.
    So, if you want to use a modal dialog, all scene changes will only be visible after the dialog gets closed. And that's also the point in code, where you should call EventAdd() in order to inform C4D about the changes and make them show up in for example Object Manager immediately.



  • On 24/02/2017 at 07:39, xxxxxxxx wrote:

    Hi,Andreas.

    Thank you for your reply.I'm very sorry, my English is poor. So far I didn't  understand the difference between two types of the dialogs,one is a modal dialog anther is a async dialog.would you mind explain this? Thank you !



  • On 24/02/2017 at 07:46, xxxxxxxx wrote:

    Hi,

    a modal or synchronous dialog blocks the execution of Cinema 4D in the background. As long as such a dialog is open, the user won't be able to interact with the rest of Cinema. Like for example, when you open the "Manage User Data..." dialog on any object in Attribute Manager. That's a modal diallog, C4D is blocked until the dialog gets closed.

    The opposite is an asynchronous or non-modal dialog. Like for example the Object Manager, the Attribute Manager or the Preferences (the most dialogs in C4D are non-modal). While Preferences are open you can continue working with C4D and the dialog can stay open and be docked anywhere into the layout. Of course a non-modal dialog is slightly more complex, as you may need to care for the user changing things outside of your dialog (like adding/editing objects, switching to another scene...).



  • On 24/02/2017 at 08:00, xxxxxxxx wrote:

    Hi Andreas,

    Thank you very much for your help, you have cleared a lot of confusion for me. you are talented!👍


Log in to reply