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. JACK0319
    J
    • Profile
    • Following 0
    • Followers 0
    • Topics 8
    • Posts 13
    • Best 2
    • Controversial 0
    • Groups 0

    JACK0319

    @JACK0319

    7
    Reputation
    17
    Profile views
    13
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    JACK0319 Unfollow Follow

    Best posts made by JACK0319

    • I have developed an open-source user interface framework based on UserArea.

      Dear Community,

      I have been using c4d UserArea for a while and have always wanted to write a library to encapsulate UserArea for better usability by users. So I created this module called ualib .

      The plugin ui in this following image is created using ualib.
      235361694-ec22fa42-29e1-4bfb-9063-3f5b754866d5.png
      ualib is a user interface framework based on the C4D GeUserArea module, which allows for the convenient creation of various UI controls that are typically difficult to create within C4D. It's a bit like PyQt, but simpler. You can create and replicate interfaces quickly and easily.

      This is GitHub link. https://github.com/JACKADUX/c4d-ualib/wiki
      Please feel free to download and use it. I will continue to optimize and improve this library. If you have any questions, please feel free to contact me or leave a comment.

      Cheers,

      posted in General Talk python
      J
      JACK0319
    • RE: Encrypt .pyp file to .pypv with script or command line?

      Hi,

      here is some code i used for create pypv

      def call_c4dpy(C4D_PATH, cmd):
          # 需要把c4dpy.exe所在路径添加到环境变量
          # C4D_PATH = r"~\Maxon Cinema 4D R26"
          if C4D_PATH not in os.environ["PATH"]:
              os.environ["PATH"]+=f"{C4D_PATH};"
      
          # cmd 也可以是脚本路径 cmd = r"~\c4dtest script.py" 
          _cmd = f"c4dpy \"{cmd}\"" # 脚本路径必须是字符串
          subprocess.call(_cmd) # 调用并且可以实时看到结果 
      
      def creat_pypv(C4D_PATH, plugin_path):
          # pyp 生成 pypv
          # c4dpy.exe g_encryptPypFile="G:\C4D JACK Plugins\G4Designer\G4Designer.pyp"
          cmd = f"c4dpy g_encryptPypFile=\"{plugin_path}\""
          call_c4dpy(C4D_PATH, cmd)
      
      posted in Cinema 4D SDK
      J
      JACK0319

    Latest posts made by JACK0319

    • document bug | GeDialog.SetString flags mismatch

      Hi,

      find a small bug here
      https://developers.maxon.net/docs/py/2024_3_0/modules/c4d.gui/GeDialog/index.html?highlight=setstring#GeDialog.SetString
      d84896fb-1846-44a9-8e5d-32b3d79a85e1-image.png

      posted in Cinema 4D SDK python 2024
      J
      JACK0319
    • RE: Encrypt .pyp file to .pypv with script or command line?

      Hi,

      here is some code i used for create pypv

      def call_c4dpy(C4D_PATH, cmd):
          # 需要把c4dpy.exe所在路径添加到环境变量
          # C4D_PATH = r"~\Maxon Cinema 4D R26"
          if C4D_PATH not in os.environ["PATH"]:
              os.environ["PATH"]+=f"{C4D_PATH};"
      
          # cmd 也可以是脚本路径 cmd = r"~\c4dtest script.py" 
          _cmd = f"c4dpy \"{cmd}\"" # 脚本路径必须是字符串
          subprocess.call(_cmd) # 调用并且可以实时看到结果 
      
      def creat_pypv(C4D_PATH, plugin_path):
          # pyp 生成 pypv
          # c4dpy.exe g_encryptPypFile="G:\C4D JACK Plugins\G4Designer\G4Designer.pyp"
          cmd = f"c4dpy g_encryptPypFile=\"{plugin_path}\""
          call_c4dpy(C4D_PATH, cmd)
      
      posted in Cinema 4D SDK
      J
      JACK0319
    • Documentation error? splineHelp.InitSpline(self, op, up=Vector(0) ) raise an error

      Hi,

      https://developers.maxon.net/docs/py/2024_3_0/modules/c4d.utils/SplineHelp/index.html#SplineHelp.InitSpline
      SplineHelp.InitSpline(self, op, up=Vector(0)) in the documentation raise an error,
      TypeError: 'up' is an invalid keyword argument for this function in 2024,
      'upvector' seems to be the correct keyword argument.

      posted in Bugs python 2024
      J
      JACK0319
    • SendModelingCommand(CURRENTSTATETOOBJECT) Unable to get correct results

      Hi,

      I want to create a plane and spline and use the SplineWrap effector to wrap the plane around the spline and then return the cached polygon.
      5968dc73-b0bd-463c-9ba5-5ced6b05decf-image.png

      But the code doesn't return the correct result,
      Did I write something wrong somewhere?

      import c4d
      
      def main():
          height = 300
      
          temp_doc = c4d.documents.BaseDocument()
      
          # spline
          spline = c4d.BaseObject(5186)
          temp_doc.InsertObject(spline)
          
          # plane
          plane = c4d.BaseObject(5168)
          temp_doc.InsertObject(plane)
      
          plane[c4d.PRIM_PLANE_WIDTH] = 1000
          plane[c4d.PRIM_PLANE_HEIGHT] = height
          plane[c4d.PRIM_AXIS] = 4  # +z
          plane[c4d.PRIM_PLANE_SUBW] = int(plane[c4d.PRIM_PLANE_WIDTH]/10)
          plane[c4d.PRIM_PLANE_SUBH] = 1
      
          spline_wrap = c4d.BaseObject(1019221)
          spline_wrap.InsertUnderLast(plane)
          spline_wrap[c4d.MGSPLINEWRAPDEFORMER_SPLINE] = spline
          spline_wrap[c4d.MGSPLINEWRAPDEFORMER_AXIS] = 1
      
          # poly
          #c4d.documents.InsertBaseDocument(temp_doc) # Enabling this line will give different results
          temp_doc.ExecutePasses(bt=None, animation=True, expressions=True, caches=True, flags=0)
          
          bc = c4d.BaseContainer()
          bc[c4d.MDATA_CURRENTSTATETOOBJECT_INHERITANCE] = True
          bc[c4d.MDATA_CURRENTSTATETOOBJECT_BUILDFLAGS] = c4d.BUILDFLAGS_INTERNALRENDERER
          res = c4d.utils.SendModelingCommand(c4d.MCOMMAND_CURRENTSTATETOOBJECT, 
                                              [plane],
                                              mode=c4d.MODELINGCOMMANDMODE_ALL, 
                                              bc=bc, 
                                              doc=temp_doc, 
                                              flags=c4d.MODELINGCOMMANDFLAGS_NONE
                                              )
                                              
          print(res)
          cache = res[0]
          doc.InsertObject(cache.GetClone(0))
      
      
      if __name__ == '__main__':
          main()
          c4d.EventAdd()
      
      posted in Cinema 4D SDK 2024 python
      J
      JACK0319
    • RE: ToolData.MouseInput() how to get right mouse click?

      @i_mazlov
      Hi,
      thanks for letting me know that.

      cheers~

      posted in Cinema 4D SDK
      J
      JACK0319
    • ToolData.MouseInput() how to get right mouse click?

      Hi,
      I am writing a ToolData plugin,'msg[c4d.BFM_INPUT_CHANNEL]' always returns 1 in MouseInput function, I would like to know how can i get mouse right button event?

      def MouseInput(self, doc, data, bd, win, msg):
          # Retrieves which clicks is currently clicked
          print(msg[c4d.BFM_INPUT_CHANNEL])  # -> 1
      

      Thanks~

      posted in Cinema 4D SDK python
      J
      JACK0319
    • how to close c4dpy inside a script?

      I am using command-line to execute a C4D script through c4dpy.exe. I want to close c4dpy after the script execution completes. How can I do this?

      def main():
          parser = argparse.ArgumentParser()
          parser.add_argument('--args', type=str, help='argument to be passed')
      
          args = parser.parse_args()
          if args.args:
              print(f'Received argument: {args.args}')      
      
          # quit c4d?
          c4d.CallCommand(12104)
      
      

      In addition, I am rendering a octane scene in this script, but sometimes the rendering process keeps running and it is unclear whether it is a bug in c4dpy or if I am using c4dpy incorrectly.

      import c4d 
      import os
      
      class RenderAgent:
      
          def __init__(self):
              self.progress = 0
              
          def render(self, doc, save_path=None, thread=None):
              self.progress = 0
              rd = doc.GetActiveRenderData()
              rd[c4d.RDATA_ALPHACHANNEL] = 1
              bmp = c4d.bitmaps.MultipassBitmap(int(rd[c4d.RDATA_XRES]), int(rd[c4d.RDATA_YRES]), c4d.COLORMODE_RGB)
              bmp.AddChannel(True, True)
              # Renders the document
              if thread:
                  thread = thread.Get()
              
              if c4d.documents.RenderDocument(doc, rd.GetData(), bmp, c4d.RENDERFLAGS_EXTERNAL, thread, prog=self.PythonCallBack, wprog=self.PythonWriteCallBack) != c4d.RENDERRESULT_OK:
                  #print("Failed to render the temporary document.")
                  return False
              if save_path:
                  bmp.Save(save_path, c4d.FILTER_PNG, data=None, savebits=c4d.SAVEBIT_ALPHA)
              return bmp
      
          def PythonCallBack(self, progress, progress_type):
              self.progress = float(int(progress*100))
              if self.progress>100:
                  self.progress = 100
              print(self.progress)
              # !!
              # When i print self.progress  inside octane renderer scene (Actually, I am using a logging module. It can redirect the print output to an external log.txt file.)
              # it will still return 0 after it return 100 
              # It seems that the renderer has entered an infinite loop.
      
          def PythonWriteCallBack(self, mode, bmp, fn, mainImage, frame, renderTime, streamnum, streamname):
              ...
      
      # call this in c4dpy
      # simple code
      RA = RenderAgent()
      save_path = r"..."
      RA.render(doc, save_path)
      
      

      my log file looks like this:

      
      LEVEL:1 - 2023-05-06 16:10:23
      rendering start
      
      LEVEL:1 - 2023-05-06 16:10:23
      rendering:0.0
      
      # ... (rendering
      
      LEVEL:1 - 2023-05-06 16:10:23
      rendering:100.0  # it seems like render finished but
      
      LEVEL:1 - 2023-05-06 16:10:23
      rendering:0.0
      
      LEVEL:1 - 2023-05-06 16:10:23
      rendering:0.0
      
      ... 
      
      # (it keeps output 0.0
      
      
      posted in Cinema 4D SDK python
      J
      JACK0319
    • I have developed an open-source user interface framework based on UserArea.

      Dear Community,

      I have been using c4d UserArea for a while and have always wanted to write a library to encapsulate UserArea for better usability by users. So I created this module called ualib .

      The plugin ui in this following image is created using ualib.
      235361694-ec22fa42-29e1-4bfb-9063-3f5b754866d5.png
      ualib is a user interface framework based on the C4D GeUserArea module, which allows for the convenient creation of various UI controls that are typically difficult to create within C4D. It's a bit like PyQt, but simpler. You can create and replicate interfaces quickly and easily.

      This is GitHub link. https://github.com/JACKADUX/c4d-ualib/wiki
      Please feel free to download and use it. I will continue to optimize and improve this library. If you have any questions, please feel free to contact me or leave a comment.

      Cheers,

      posted in General Talk python
      J
      JACK0319
    • RE: How can i get full chinese characters using userarea BFM_INPUT_ASC

      Hi @ferdinand ,

      First of all, I apologize for my poor explanation.

      I ran into an unexplainable situation, but your example solved my problem nicely.
      I couldn't get consecutive characters because I mistakenly called the self.GetInputState(c4d.BFM_INPUT_MOUSE, msg.GetInt32(c4d.BFM_INPUT_CHANNEL), msg) method and it would interrupt getting the original input.

      now I have solved the problem. Thank you very much you guys are the best!
      Cheers~

      posted in Cinema 4D SDK
      J
      JACK0319
    • How can i get full chinese characters using userarea BFM_INPUT_ASC

      Hi,
      I am using GeUserArea to create a text editor in python.
      but when I use BFM_ INPUT_ ASC, it will only return one character!
      How can i get full input of characters? (Here is the simplified code

      def InputEvent(self, msg):
          # i entered 'test' 
          asc = msg[c4d.BFM_INPUT_ASC]
          print(asc)
          # >>> t
          # but i only get 't' 
      
      
      
      

      i want to input 'test' here

      4ac30c7d-dd35-4b5c-bce1-5a9ffbc4e251-image.png

      i write 'test' and pressed enter

      069467c3-4531-482a-829f-908764a7fb34-image.png

      it will only return 't' , but i want to get fully return of 'test' at once

      89885a68-5e70-49e3-a9d7-1f14b5edda7d-image.png

      posted in Cinema 4D SDK python
      J
      JACK0319