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
    1. Maxon Developers Forum
    2. mfersaoui
    3. Best
    • Profile
    • Following 0
    • Followers 0
    • Topics 45
    • Posts 150
    • Best 2
    • Controversial 0
    • Groups 0

    Best posts made by mfersaoui

    • RE: Create a download progress bar in python

      Hi,
      I found the solution.

      import urllib2
      
      class Update(c4d.gui.GeDialog):
          UPDATE_BTN = 1000
          PROGRESS = 1001
          PROGRESSBAR = 1002
          state = ""
      
          def CreateLayout(self) :
              self.AddButton(self.UPDATE_BTN, flags = c4d.BFH_LEFT, inith = 13, name = "Update")
              self.AddStaticText(self.PROGRESS, flags=c4d.BFH_SCALEFIT, initw=0, inith=0, name=self.state, borderstyle=0)
      
              # How to taking the percentage value from the function chunk_report() and apply it to the following CUSTOMGUI_PROGRESSBAR
              self.GroupBegin(id=0, flags=c4d.BFH_LEFT, cols=1, rows=0)
              self.GroupBorderNoTitle(c4d.BORDER_THIN_IN)
              self.AddCustomGui(self.PROGRESSBAR, c4d.CUSTOMGUI_PROGRESSBAR, "", c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT,200, 8)        
              self.GroupEnd()
      
          def chunk_read(self, response, chunk_size=8192):
              total_size = response.info().getheader('Content-Length').strip()
              total_size = int(total_size)
              bytes_so_far = 0
              
              progressMsg = c4d.BaseContainer(c4d.BFM_SETSTATUSBAR)
              progressMsg[c4d.BFM_STATUSBAR_PROGRESSON] = True
      
              while 1:
                  chunk = response.read(chunk_size)
                  bytes_so_far += len(chunk)
      
                  if not chunk:
                      break
      
                  percent = float(bytes_so_far) / total_size
                  percent = round(percent*100, 2)
      
                  progressMsg[c4d.BFM_STATUSBAR_PROGRESS] = percent/100
                  self.SendMessage(self.PROGRESSBAR, progressMsg)
                  self.SetString(self.PROGRESS, percent)
      
          def Command(self, id, msg):
      
              if id == self.UPDATE_BTN :
                  filedata = urllib2.urlopen('https://www.domainname.com/file.zip')
                  self.chunk_read(filedata)
      
      posted in Cinema 4D SDK
      mfersaouiM
      mfersaoui
    • RE: Placing a custom menu under the File Menu and on specific position

      @mfersaoui
      Hi,
      I found the following solution:

      FileMenu = c4d.BaseContainer()
      resource = c4d.plugins.GeResource()
      resource.InitAsGlobal()
      FileMenu.InsData(c4d.MENURESOURCE_SUBTITLE, resource.LoadString(12587))
      
      posted in Cinema 4D SDK
      mfersaouiM
      mfersaoui