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
    • Recent
    • Tags
    • Users
    • Register
    • Login
    1. Maxon Developers Forum
    2. chuanzhen
    3. Posts
    Offline
    • Profile
    • Following 1
    • Followers 6
    • Topics 81
    • Posts 238
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: MergeDocument() crash C4D

      @Anlv Thanks for your reply.can't reproduce this issue on your side, it seems I need to test it on other computers. It's a puzzling problem

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • RE: MergeDocument() crash C4D

      @Anlv Hi
      Here is a video demonstrating how C4D crashes. For a saved document (or a loaded document), using MergeDocument() is fine, but for a new document that hasn't been saved, using MergeDocument() will definitely crash
      2026.3.3 win11

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • MergeDocument() crash C4D

      Hi,

      c4d.documents.MergeDocument(doc, path_str,c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS,None)
      

      this code,c4d always crashed

      posted in Cinema 4D SDK python 2026
      chuanzhenC
      chuanzhen
    • RE: Using SetWeightMap() multiple times can lead to inexplicable changes in weight values

      @ferdinand
      Hi,The simple demo I made:
      1:Create a standard cube (with 8 vertices),
      2:Create 8 joint (point_id 1 -> joint 1 ),bind it,then offset all joints (x:10000,y:10000,z:10000 cm)
      3:Each point is 100% bound to a bone,
      4: Then, apply smooth 1-2 times to all bones and points to obtain a result where each point is influenced by all bones (facilitating the observation of the code execution results)
      5: normalize weights
      6:Then execute the code 2-3 times, and you can clearly see the result

      code:

      import c4d
      
      doc: c4d.documents.BaseDocument  # The currently active document.
      op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
      
      def main() -> None:
          tag = op.GetTag(c4d.Tweights)
          if not tag:
              return
          j_cnt = tag.GetJointCount()
          p_cnt = op.GetPointCount()
      
          for i in range(10):
              weights = [tag.GetWeightMap(j_id,p_cnt) for j_id in range(j_cnt)]
              for j_id in range(j_cnt):
                  tag.SetWeightMap(j_id,weights[j_id])
              tag.WeightDirty()
          
          
          c4d.EventAdd()
      
      
      if __name__ == '__main__':
          main()
      

      01aff503-a8c0-4521-8b99-3c094189c490-image.png
      video:

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • Using SetWeightMap() multiple times can lead to inexplicable changes in weight values

      Hi,
      Previously, I had been using the SetWeight() method to set weight values, and it worked very stably. However, after seeing the deprecation notice for SetWeight() in the python api documentation, I switched to using SetWeightMap() instead. However, there were some issues with this function. When I used SetWeightMap() multiple times to set values, its values would gradually change.

      Below is a simple example of my video, using a standard cube (with 8 points), where each point is equally influenced by all bones.

      However, when I repeatedly obtain the weight values using GetWeightMap()without making any changes, and then set the weights using SetWeightMap() again, I can see that the weight values have undergone slight changes, with the sum of weights changing from 1 --> 0.998

      posted in Cinema 4D SDK python 2026
      chuanzhenC
      chuanzhen
    • RE: After calling BaseContainer.Sort(), the stored values are lost

      @ferdinand Thanks for your detailed explanation and the implementation of the sorting function. It's very helpful!

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • After calling BaseContainer.Sort(), the stored values are lost

      Hi,
      My requirement is to rearrange the basecontainer in order of id, so I used the BaseContainer().Sort() function. However, there were two issues in the simple test:

      1. the stored values were lost
      2. it was not arranged in order of id
      import c4d
      
      doc: c4d.documents.BaseDocument  # The currently active document.
      op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
      
      def main() -> None:
          bc = c4d.BaseContainer()
          for i in range(4,12):
              bc.SetInt32(i,i)
          for i in range(3):
              bc.SetInt32(i,i)
          for id,v in bc:
              print(id,v)
          print("--------")
          bc.Sort()
          for id,v in bc:
              print(id,v)
          
          
      if __name__ == '__main__':
          main()
      

      Did I misunderstand this function?

      posted in Cinema 4D SDK 2026 python
      chuanzhenC
      chuanzhen
    • RE: TimeLine DopeSheet not update

      @ferdinand Thanks for help

      posted in Bugs
      chuanzhenC
      chuanzhen
    • TimeLine DopeSheet not update

      Hi
      in Dope Sheet -F-Curve mode,i change CTrack NBit(c4d.NBIT_TL1_SELECT2) ,(selection State),the window will not refresh immediately.

      After selection state change, how can I make the window refresh in real time

      import c4d
      
      def main() -> None:
         
          for track in op.GetCTracks():
              track.ChangeNBit(c4d.NBIT_TL1_SELECT2,c4d.NBITCONTROL_SET)
              
          c4d.EventAdd()
      
      
      if __name__ == '__main__':
          main()
      

      Thanks for any help!

      posted in Bugs 2026 python
      chuanzhenC
      chuanzhen
    • RE: how to detect obj selected in InExcludeData()?

      @ferdinand Thank you. hope this can be updated in the document👍

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • RE: how to detect obj selected in InExcludeData()?

      Hi @ferdinand , in .res file, how to set InExcludeData IN_EXCLUDE_FLAG_SEND_SELCHANGE_MSG is True? in c++ API doc,there no this flags for IN_EXCLUDE_FLAG_SEND_SELCHANGE_MSG

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • RE: how to detect obj selected in InExcludeData()?

      Supplement an example of generating UserData using code:

      import c4d
      
      
      def main() -> None:
          
          
          bc = c4d.GetCustomDataTypeDefault(c4d.CUSTOMDATATYPE_INEXCLUDE_LIST)
          bc[c4d.DESC_NAME] = "Test"
          bc[c4d.IN_EXCLUDE_FLAG_SEND_SELCHANGE_MSG] = True
          did = op.AddUserData(bc)
          c4d.EventAdd()
      
      if __name__ == '__main__':
          main()
      
      
      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • RE: how to detect obj selected in InExcludeData()?

      @ferdinand Thanks,it works!

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • how to detect obj selected in InExcludeData()?

      Hi,
      i use this script code to detect obj selected in InExcludeData(),always return "None"

      import c4d
      
      doc: c4d.documents.BaseDocument  # The currently active document.
      op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
      
      def main() -> None:
          ie = op[c4d.ID_USERDATA,1]
          for i in range(ie.GetObjectCount()):
              print(ie.GetData(i)[c4d.IN_EXCLUDE_DATA_SELECTION])
      
      if __name__ == '__main__':
          main()
      

      i found a example code in this post,but it also not work.

      Thanks for any help!

      posted in Cinema 4D SDK 2025 python
      chuanzhenC
      chuanzhen
    • RE: Viewport depth of field affects the content drawn using drawtexture()

      @ferdinand Thanks for reply
      Other channels(BOX,X-Ray....) also seem to be unfeasible, and currently it seems only can accept this limitation (affected by depth of field)
      Due to the current not to transfer to C++, some plugin ideas are indeed somewhat unusual
      only using some simple C4D drawings to generate Bitmaps, so I did not pay attention to the handling of Ocio. I will carefully read the manual on this aspect in the document.

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • RE: Viewport depth of field affects the content drawn using drawtexture()

      @ferdinand Thanks,
      DRAWPASS::HANDLES There is a limitation that only displays when I select the object, and my goal is to keep it displayed (select or not select)
      code:

          def Draw(self,op, drawpass, bd, bh):
      
              
      
              if drawpass == c4d.DRAWPASS_OBJECT:
                  #draw
                  bd.SetMatrix_Screen()
                  
                  window_dict = bd.GetSafeFrame()
                  
                  bd.SetLightList(c4d.BDRAW_SETLIGHTLIST_NOLIGHTS)
                  # set uv ... info
                  uvadr = [c4d.Vector(), c4d.Vector(), c4d.Vector(), c4d.Vector()]
                  uvadr[1] = c4d.Vector(1, 0, 0)
                  uvadr[2] = c4d.Vector(1, 1, 0)
                  uvadr[3] = c4d.Vector(0, 1, 0)
                  padr = [c4d.Vector(), c4d.Vector(), c4d.Vector(), c4d.Vector()]  
                  padr[0] = c4d.Vector(window_dict['cl'], window_dict['ct'], 0)
                  padr[1] = c4d.Vector(window_dict['cr'], window_dict['ct'], 0)
                  padr[2] = c4d.Vector(window_dict['cr'], window_dict['cb'], 0)
                  padr[3] = c4d.Vector(window_dict['cl'], window_dict['cb'], 0)
                  map = xx  # this can be any images
                  cadr = [c4d.Vector(1), c4d.Vector(1), c4d.Vector(1), c4d.Vector(1)]
                  nadr = [c4d.Vector(1), c4d.Vector(1), c4d.Vector(1), c4d.Vector(1)]
                  if map:
                      bd.DrawTexture(map, padr, cadr, nadr, uvadr, 4, c4d.DRAW_ALPHA_NORMAL, c4d.DRAW_TEXTUREFLAGS_TEMPORARY)
              
              return c4d.DRAWRESULT_OK
      
      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • Viewport depth of field affects the content drawn using drawtexture()

      hi,
      I have a OBJECT_GENERATOR plugin and I encountered some problems while drawing it. I am drawing something in screen space use BaseDraw.DrawTexture(), and when I turn on depth of field of viewport, the drawn content is also affected. How to make the drawn content not affected by depth of field.
      Thanks for any help!

      posted in Cinema 4D SDK 2025 python
      chuanzhenC
      chuanzhen
    • RE: The value of 'progress' during the use of RenderDocument() is greater than 1.0

      @ferdinand 😊

      posted in Bugs
      chuanzhenC
      chuanzhen
    • The value of 'progress' during the use of RenderDocument() is greater than 1.0

      Hi,
      I used the example code from c4d.documents.RendeDocument() in the document, which indicates that the values returned by progress are between 0-1.0. However, in my actual use, there may be some values greater than 1.0
      74fdd49f-2802-45eb-9756-b8e5fb46be7f-image.png

      This is my code, using Viewport Render with a frame range of 1001-1100

      """
      Copyright: MAXON Computer GmbH
      Author: Maxime Adam
      
      Description:
          - Render the current document with a progress hook to get notified about the current rendering progress.
      
      Class/method highlighted:
          - c4d.bitmaps.MultipassBitmap
          - c4d.documents.RenderDocument()
      
      """
      import c4d
      
      
      
      def PythonCallBack(progress, progress_type):
          """Function passed in RenderDocument. It will be called automatically by Cinema 4D with the current render progress.
      
          Args:
              progress (float): The percent of the progress for the current step
              progress_type (c4d.RENDERPROGRESSTYPE): The Main part of the current rendering step
          """
          print(progress)
      
      
      def main():
          # Retrieves the current active render settings
          rd = doc.GetActiveRenderData()
      
          # Creates a Multi Pass Bitmaps that will store the render result
          bmp = c4d.bitmaps.MultipassBitmap(int(rd[c4d.RDATA_XRES]), int(rd[c4d.RDATA_YRES]), c4d.COLORMODE_RGB)
          if bmp is None:
              raise RuntimeError("Failed to create the bitmap.")
      
          # Adds an alpha channel
          bmp.AddChannel(True, True)
      
      
      
          # Renders the document
          if c4d.documents.RenderDocument(doc, rd.GetDataInstance(), bmp,c4d.RENDERFLAGS_EXTERNAL, prog=PythonCallBack,
                                          wprog=None) != c4d.RENDERRESULT_OK:
              raise RuntimeError("Failed to render the temporary document.")
      
          # Displays the render in the Picture Viewer
          #c4d.bitmaps.ShowBitmap(bmp)
      
      
      if __name__ == "__main__":
          main()
      

      Thanks for any help!

      posted in Bugs 2025 python
      chuanzhenC
      chuanzhen
    • RE: How to obtain the object deformed by the deformer

      @ferdinand Thanks for detailed explanation.
      Let me introduce the goals that the custom deformer plugin wants to achieve. (As can be seen from the cube, cube. 1, cube. 2... in the image, each object has a weight tag.) The custom deformer plugin needs to preprocess and store some data before the ModifyObjects () function works. (By clicking a button) Access the weight tag of each object to be deformed in Message (), preprocess and store some data, and then use the preprocessed data to execute the ModifyObjects () function to correctly process the deformation calculation.
      9c418a15-9d3c-4466-83c2-0481e7b67c69-image.png

      In C4D, it seems that the Surface deformer has achieved a similar function
      5ef7303f-0ea2-4d3b-bed4-c342a755350c-image.png

      (there are certain benefits to restricting the custom deformer plugin only to the parent level, as there is no need to spend effort on correctly linking the corresponding preprocessed data when the ModifyObjects () function works.But it did break the general logic operation of the deformer)

      The only way you could do that is by checking each deformed object being passed into , to be the parent of the also passed in (i.e., the deformer also simply accessible via ). Only for an which is the parent of would you then carry out the modification.

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen