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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Yet another approach for async dialogs.

    Scheduled Pinned Locked Moved PYTHON Development
    1 Posts 0 Posters 284 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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 17/06/2011 at 09:42, xxxxxxxx wrote:

      And this one is a good one. 😉
      I hate restarting cinema 4d because i want to test my async dialog but i can only open it in a command data >.>

      from    c4d.gui         import GeDialog  
      from    threading       import Thread  
        
      class DialogThread(Thread) :  
        """  
        A class to enable opening ASync Dialogs in the Skript Manager.  
        Initialise with a GeDialog subclass instance.  
        """  
        
        class ArgumentError(Exception) :  
            """ Raised when a bad argument is given. """  
        
        def __init__(self, dlg) :  
            # initialise with a GeDialog subclass instance  
            if not issubclass(dlg.__class__, GeDialog) :  
                raise self.ArgumentError, "Overloaded argument 'dlg' is not an instance of GeDialog or an instance of a subclass of GeDialog.\n" \  
                                   \+ "It is an instance of:     %s" % dlg.__class__.__name__  
        
            Thread.__init__(self)  
            self.dlg        = dlg  
        
        def run(self) :  
            # wait until the dialog is closed  
            while self.dlg.IsOpen() :  
                pass  
        
        def start(self, opentype = c4d.DLG_TYPE_ASYNC) :  
            # open the dialog and start Superclass' start().  
            self.dlg.Open(opentype)  
            Thread.start(self)  
        
      def OpenAsyncDialog(dlg) :  
        dlg_thread = DialogThread(dlg)  
        dlg_thread.start()  
        return dlg_thread
      

      Maybe at least this can be added to the Py4D Standart Library ? Would be pretty useful for skripts, hehe.

      Cheers,

      //edit:
      Hm, again some issues. 😂
      is there any way to keep the globals within a Thread ? >.>

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