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

    CUSTOMGUI_PROGRESSBAR

    PYTHON Development
    0
    5
    895
    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

      On 02/02/2016 at 07:30, xxxxxxxx wrote:

      How do I use the CUSTOMGUI_PROGRESSBAR.
      I cannot find any examples?

      -Pim

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

        On 02/02/2016 at 09:36, xxxxxxxx wrote:

        Hi Pim,

        The CUSTOMGUI_PROGRESSBAR is setup and updated using BFM_SETSTATUSBAR GUI message and its related BFM_STATUSBAR container options.
        Here's a simple example:

        import c4d
        from c4d import gui
          
        class TestDialog(gui.GeDialog) :
            
            PROGRESSBAR = 1001
            
            def __init__(self) :
                self.progress = 0
            
            def StopProgress(self) :
                self.SetTimer(0)
                progressMsg = c4d.BaseContainer(c4d.BFM_SETSTATUSBAR)
                progressMsg.SetBool(c4d.BFM_STATUSBAR_PROGRESSON, False)
                self.SendMessage(self.PROGRESSBAR, progressMsg)
            
            def CreateLayout(self) :
                self.SetTitle("ProgressBar Example")
                
                self.GroupBegin(id=1000, flags=c4d.BFH_SCALEFIT|c4d.BFV_TOP, cols=0, rows=1)
                self.AddCustomGui(self.PROGRESSBAR, c4d.CUSTOMGUI_PROGRESSBAR, "", c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT, 0, 0)
                self.GroupEnd()
                
                return True
            
            def InitValues(self) :
                self.SetTimer(1000)
                return True
            
            def Timer(self, msg) :
                self.progress += 1
                progressMsg = c4d.BaseContainer(c4d.BFM_SETSTATUSBAR)
                progressMsg[c4d.BFM_STATUSBAR_PROGRESSON] = True
                progressMsg[c4d.BFM_STATUSBAR_PROGRESS] = self.progress/10.0
                self.SendMessage(self.PROGRESSBAR, progressMsg)
            
            def Message(self, msg, result) :
                if msg.GetId() == c4d.BFM_TIMER_MESSAGE:
                    if self.progress==10:
                        self.StopProgress()
                        self.Close()
                        return True
                
                return gui.GeDialog.Message(self, msg, result)
            
            def AskClose(self) :
                self.StopProgress()
                return False
          
          
        if __name__=='__main__':
            dialog = TestDialog()
            dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=0, defaulth=400, defaultw=400)
        

        A progress bar can also be added to a dialog within a status bar with GeDialog.ScrollGroupBegin().

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

          On 02/02/2016 at 12:21, xxxxxxxx wrote:

          Is there a speecial reason you use SubDialog as the parent class? Just interested.

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

            On 03/02/2016 at 02:45, xxxxxxxx wrote:

            Hi Niklas,

            Oooops, I had not seen the dialog was declared as a SubDialog and not as a normal GeDialog.

            I updated the code I posted as it was missing the last progress step and other minor things have been fixed (call SetTimer() in InitValues(), StopProgress() etc.)

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

              On 05/02/2016 at 05:36, xxxxxxxx wrote:

              Great, thank you.

              -Pim

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