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

    [Py] ScriptMng - GeUserArea disappears

    Bugs
    0
    4
    904
    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
      Helper
      last edited by

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

      On 25/11/2011 at 09:36, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R13 
      Platform:      
      Language(s) :

      ---------
      in R13, the GeUserArea in an async dialog just disappears when you resize the dialog. Saving a reference to the dialog solves the problem.

      Example code:

        
          
          
          import c4d  
          import c4d.gui     as gui  
          import c4d.bitmaps as bitmaps  
            
          SHOW_ISSUE = False  
            
          class Area(gui.GeUserArea) :  
              
            def __init__(self, w = 20, h = 20, r = 1, g = 1, b = 1) :  
                self.bmp = bitmaps.BaseBitmap()  
                self.bmp.Init(w, h)  
                self.w   = w  
                self.h   = h  
                  
                self.alpha = self.bmp.AddChannel(True, False)  
                  
                r = int(r * 255)  
                g = int(g * 255)  
                b = int(b * 255)  
            
                for x in xrange(w) :  
                    for y in xrange(h) :  
                        a = x*y / float(w*h)  
                        a = 1 - 2**a  
                        a = int(a * 255)  
                        self.bmp[x, y] = r, g, b  
                        self.bmp.SetAlphaPixel(self.alpha, x, y, a)  
                          
            def DrawMsg(self, x1, y1, x2, y2, msg) :  
                self.DrawSetPen(c4d.Vector(0, 0, 0))  
                self.DrawRectangle(x1, y1, x2, y2)  
                  
                if SHOW_ISSUE:  
                    self.DrawSetPen(c4d.Vector(.2, .6, .9))  
                  
                w, h = self.w, self.h  
                self.DrawBitmap(self.bmp,  
                    0, 0, w, h, 0, 0, w, h, c4d.BMP_NORMAL | c4d.BMP_ALLOWALPHA)  
                      
            def GetMinSize(self) :  
                return self.w, self.h  
                  
          class Dialog(gui.GeDialog) :  
              
            def __init__(self, area) :  
                self.area = area  
              
            def CreateLayout(self) :  
                self.AddUserArea(1000, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT)  
                self.AttachUserArea(self.area, 1000)  
                return True  
              
          def main() :  
            area = Area(100, 100, 1.0, 0.66, 0.24)  
            dlg  = Dialog(area)  
            
            if c4d.GetC4DVersion() < 13000:  
                  # async in script manager and r12 does not work  
                  # open it modal  
                dlg.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE)  
            else:  
                dlg.Open(c4d.DLG_TYPE_ASYNC)  
                  # uncomment the following and it works  
                  # main.dlg = dlg  
              
          if __name__ == "__main__":  
            main()
      
      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

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

        On 24/02/2012 at 06:38, xxxxxxxx wrote:

        DLG_TYPE_ASYNC should only be used in Plugin environments. Cheers, Sebastian
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

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

          On 30/06/2012 at 09:58, xxxxxxxx wrote:

          Can I use it with other plug-ins?

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

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

            On 01/07/2012 at 05:04, xxxxxxxx wrote:

            You can use asynchronous dialogs whenever you want, just not in scripts.
            Scripts only live while they're being executed, so asynchronous dialogs can't work.

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