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. chuanzhen
    3. Posts
    • Profile
    • Following 1
    • Followers 6
    • Topics 74
    • Posts 219
    • Best 18
    • Controversial 0
    • Groups 0

    Posts made by 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
    • RE: How to obtain the object deformed by the deformer

      @ferdinand Thank you for your detailed reply.
      If there is no direct method, it is a feasible solution to re implement the defoemer logic. However, since it requires storing data separately for each object that needs to be deformed, limiting the deformable device to only act on the parent object is a limited but more efficient method.

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • How to obtain the object deformed by the deformer

      Hi,
      deformer object can deform an object in two ways:
      method A as a child of the deformed object,
      method B at the same level as the deformed object.

      There is a problem. In a custom deformer plugin, I obtain the deformed object in the Message() function. Using the first method A, I can obtain the deformed object ''Cube. x'' through node. GetUp(). but method B, how can I access the deformed object (Cube, Cube. 1, Cube. 2)?
      4c727a8a-c175-4c4a-adf6-b6c94a183ec0-image.png

      Thanks for any help!

      posted in Cinema 4D SDK 2025 windows python
      chuanzhenC
      chuanzhen
    • RE: pythonsdk doc Matrix manunl error?

      @ferdinand Thank you for explanation. The point of confusion should be marked as 2 in the image. in doc the counterclockwise rotation (ccw) refers to the counterclockwise rotation from the spatial perspective of the image. but for the same rotation, the z-axis should have rotated clockwise(cw). However, in any case, the calculation is correct, only the description is different。
      (Describing a rotation of an axis, it is assumed that a person looks in the negative direction from the positive direction of the axis, and based on this, counterclockwise and clockwise are defined)

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • pythonsdk doc Matrix manunl error?

      Hi,
      When I read the matrix manual in python sdk doc, I found that the descriptions of 1 and 2 seem contradictory. In c4d, counter-clockwise rotation (ccw) displays a positive value 90 °, while clockwise rotation (cw) displays a negative value -90 °. However, in image marker 2, the transformation should be clockwise cw 90 ° (i.e. R.B=-90 °), not ccw90 °
      d52ff3e3-4c20-4f0a-a6eb-e20f2284dba3-image.png

      posted in Cinema 4D SDK python
      chuanzhenC
      chuanzhen
    • RE: Frozen Matrix different

      When I restart C4D, I cannot reproduce this problem. It's really confusing, c4d 2025.2.1😵 (And I also forgot to save the file at that time, resulting in the loss of the file on site)

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • Frozen Matrix different

      hi,
      A parent object has 2 child objects whose global matrix are the same. They have the same frozen transform value, but the transform values are different. I used GetFrozenMln() to obtain the frozen matrix and found that the frozen matrix of the 2 child objects are *different.

      Why do 2 child objects have the same frozen transform value but different frozen matrix?
      4c0880f6-fb6f-4cd9-9e0e-a1c29320d8f9-image.png

      posted in Cinema 4D SDK 2025 python
      chuanzhenC
      chuanzhen
    • RE: Set RenderData framerate causing C4D to crash

      @i_mazlov there is video, 2025.2.1,win11

      posted in Bugs
      chuanzhenC
      chuanzhen
    • Set RenderData framerate causing C4D to crash

      Hi,
      use bellow code will causing C4D to crash

      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:
          rd = c4d.documents.RenderData()
          rd[c4d.RDATA_FRAMERATE] = 2.0
      
      
      if __name__ == '__main__':
          main()
      

      safe setting code:

          rd = c4d.documents.RenderData()
          data = rd.GetDataInstance()
          data[c4d.c4d.RDATA_FRAMERATE] = 2.0
      
      
      

      bug?

      posted in Bugs python 2025
      chuanzhenC
      chuanzhen
    • RE: How to Execute a Modifier plugin in Expression priority

      @i_mazlov Thanks,it works!

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • RE: Problem encountered when check double click in Message() Use MSG_EDIT

      @i_mazlov Thanks

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • RE: How to Execute a Modifier plugin in Expression priority

      @i_mazlov Thanks,in my code I found an error and directly used the value obtained from PRIORITYVALUEMYODE in the priority GUI to set the list The priority parameter in Add() is a low-level error.
      But there is still a problem. When I used your code and adjusted the priority of **Python tag*to expression 1, the calculation order did not execute as expected. Where exactly is the problem?
      My version is also 2025.2.0
      aa3b604f-b0ba-49cc-8b40-6276b19dca35-image.png
      c438db28-6569-45f8-b1d8-82049db07a2b-image.png

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • RE: How to Execute a Modifier plugin in Expression priority

      @i_mazlov Thanks for reply!
      I added this flag and modified the content of AddToExecution(). Execute() was successfully called, but it did not run in the expected calculation order. In the image below, The Cube object has a Python tag with priority=expression 0 and objectplugin with priority=expression 10. My expected work order should be python tag (priority=expression 0) -> objectplugin (priority=expression 10), but why is the actual running result objectplugin (priority=expression 10) ->python tags (priority=expression 10)
      bd57c2f7-c340-4c85-a9f3-ed22600fbb19-image.png

      my code:

          def Execute(self, op, doc, bt, priority, flags) -> int:
      
              print("Execute")
              return c4d.EXECUTIONRESULT_OK
      
          def AddToExecution(self, op, list) -> bool:
              print("AddToExecution")
              mode = op[c4d.S_TEMP_PRIORITY].GetPriorityValue(c4d.PRIORITYVALUE_MODE)
              list.Add(op, mode,c4d.EXECUTIONFLAGS_NONE)
      
      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • Problem encountered when check double click in Message() Use MSG_EDIT

      Hi,
      In the tag plugin, i use MSG_EDIT in Message() to detect the double-click behavior of the mouse, and then execute some commands. However, when create tag, MSG_EDIT is also used. I tried using gui.GetInputState (c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_DOUBLECLICK,bc) obtains specific information to distinguish between label create tag and double-click behavior, but bc no double click information is obtained.
      code:

          def Message(self, node: GeListNode, type: int, data: object) -> bool:
              if type == c4d.MSG_EDIT:
                  
                  c4d.CallCommand(200000084) # Rectangle Selection
      
                  bc = c4d.BaseContainer()
                  gui.GetInputState(c4d.BFM_INPUT_MOUSE,c4d.BFM_INPUT_DOUBLECLICK,bc)
                  if bc[c4d.BFM_INPUT_DOUBLECLICK] : 
                      print("double")
                  return True
              return True
      

      How to distinguish between these two behaviors
      Thanks for any help!

      posted in Cinema 4D SDK 2025 python
      chuanzhenC
      chuanzhen
    • How to Execute a Modifier plugin in Expression priority

      Hi,
      I have created a object modifier plugin and I want it to work once in priority Expression 10, and then again in Generator 1. How can I make it work as expected?
      In the code, AddToExecution() and Execute() do not seem to work (the documentation states that switching priorities requires calling these two functions).

      import c4d
      from c4d import plugins, bitmaps
      
      
      PLUGIN_ID = 1000001
      
      class S_Temp(plugins.ObjectData):
      
      
          def Execute(self, op, doc, bt, priority, flags) -> int:
              print("Execute")
              return c4d.EXECUTIONRESULT_OK
      
          def AddToExecution(self, op, list) -> bool:
              print("AddToExecution")
              return True
      
      
          def Init(self, node, isCloneInit: bool) -> bool:
              self.InitAttr(node, c4d.BaseList2D, c4d.S_TEMP_POSEDTARGETS)
              self.InitAttr(node, c4d.BaseList2D, c4d.S_TEMP_POSEDSOURCEADD)
              self.InitAttr(node, c4d.PriorityData, c4d.S_TEMP_PRIORITY)
      
              if not isCloneInit:
                  pridata = c4d.PriorityData()
                  pridata.SetPriorityValue(c4d.PRIORITYVALUE_MODE, c4d.CYCLE_EXPRESSION)
                  pridata.SetPriorityValue(c4d.PRIORITYVALUE_PRIORITY, 10)
                  node[c4d.S_TEMP_PRIORITY] = pridata
              return True
      
          def ModifyObject(self, mod, doc, op, op_mg, mod_mg, lod, flags, thread):
              allp = [pos + c4d.Vector(0,100,0) for pos in op.GetAllPoints()]
              op.SetAllPoints(allp)
              op.Message(c4d.MSG_UPDATE)
      
              return True
      
      
      if __name__ == '__main__':
          plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="S_Temp", g=S_Temp, description="stemp", info=c4d.OBJECT_MODIFIER,
                                       icon=None)
      

      Here is the file of this plugin --> s_Temp.zip

      Thanks for any help!

      posted in Cinema 4D SDK 2024 python
      chuanzhenC
      chuanzhen
    • RE: Change Icon Color parameter

      @i_mazlov Thanks for your help, it works well.

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • RE: Change Icon Color parameter

      @JH23 Thanks for your help,this is indeed a solution.
      For existing objects in Object Manager, using this code is effective, but creating a new object and setting it up yields a different result, which is confusing.

      @chuanzhen said in Change Icon Color parameter:

      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:
          for i in range(2):
              obj = c4d.BaseObject(c4d.Ojoint)
              obj[c4d.ID_BASELIST_ICON_COLORIZE_MODE] = 2
              obj[c4d.ID_BASEOBJECT_USECOLOR] = 2
              obj[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector()
      
              obj.SetName(str(i))
              doc.InsertObject(obj)
          c4d.EventAdd()
      
      
      if __name__ == '__main__':
          main()
      
      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • Change Icon Color parameter

      hi,
      I use script to create bone and insert it to document, set it Icon Color=Display Color,Why does the Icon Color parameter of the object turn to Custom when I click on it.

      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:
          for i in range(2):
              obj = c4d.BaseObject(c4d.Ojoint)
              obj[c4d.ID_BASELIST_ICON_COLORIZE_MODE] = 2
              obj[c4d.ID_BASEOBJECT_USECOLOR] = 2
              obj[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector()
      
              obj.SetName(str(i))
              doc.InsertObject(obj)
          c4d.EventAdd()
      
      
      if __name__ == '__main__':
          main()
      

      Thanks for any help!

      posted in Cinema 4D SDK 2024 python
      chuanzhenC
      chuanzhen
    • RE: How to convert the length of a line on the screen to the length of an object.

      @ferdinand Thanks for your help.
      For the unwanted effect of perspective distortion, I tried projecting a fixed size line onto an object to determine the length of the projected line in the world, and then proceeded to draw it.

      code:

      
      
      import c4d
      
      doc: c4d.documents.BaseDocument  # The document containing this field object.
      op: c4d.BaseTag  # The Python tag containing this code.
      flags: int  # The execution flags of `main()`. See c4d.EXECUTIONFLAGS for details.
      priority: int  # The execution priority of this tag. See c4d.EXECUTIONPRIORITY for details.
      tp: c4d.modules.thinkingparticles.TP_MasterSystem  # The TP system of the document.
      
      def GetLineAndPlaneIntersection(plane_pos, plane_normal, line_start, line_dir):
      
          zero_find = line_dir.Dot(plane_normal)
          if zero_find == 0:
              return False, None
          else:
              d = (plane_pos - line_start).Dot(plane_normal) / zero_find
      
      
          return True, line_start + d * line_dir
      
      
      def main() -> None:
      
          pass
      
      
      
      
      
      
      
      def draw(bd: c4d.BaseDraw) -> bool:
      
      
          if op[c4d.EXPRESSION_ENABLE]:
              c_mg = bd.GetMg()
              c_mi = bd.GetMi()
      
              plane_normal = c_mg.v3
      
              plane_100_point = c_mg * c4d.Vector(0,0,100)
              plane_obj_point = op.GetMain().GetMg().off
      
              intersect,intersect_100_plane_point = GetLineAndPlaneIntersection(plane_100_point, plane_normal, plane_obj_point, c_mg.off - plane_obj_point)
              line_end = intersect_100_plane_point + (c_mg * c4d.Vector(5,0,0) - c_mg.off)  # fixed size
              intersect,intersect_obj_plane_point = GetLineAndPlaneIntersection(plane_obj_point, plane_normal, c_mg.off, line_end - c_mg.off)
              length = (intersect_obj_plane_point - plane_obj_point).GetLength()
      
      
      
              mg = op.GetMain().GetMg()
              pos = bd.WS(plane_obj_point)
              bd.SetMatrix_Screen()
              bd.SetPen(c4d.GetViewColor(c4d.VIEWCOLOR_XAXIS))
              x = bd.WS(mg * c4d.Vector(length,0,0))
              bd.DrawLine2D(pos,x)
              bd.SetPen(c4d.GetViewColor(c4d.VIEWCOLOR_YAXIS))
              y = bd.WS(mg * c4d.Vector(0,length,0))
              bd.DrawLine2D(pos,y)
              bd.SetPen(c4d.GetViewColor(c4d.VIEWCOLOR_ZAXIS))
              z = bd.WS(mg * c4d.Vector(0,0,length))
              bd.DrawLine2D(pos,z)
      
      
          return True
      

      posted in Cinema 4D SDK
      chuanzhenC
      chuanzhen
    • How to convert the length of a line on the screen to the length of an object.

      hi,
      I tried to have an object display its coordinate axis at a fixed screen space length, but it didn't work properly. Where did I make a mistake with my code?

      This is a c4d file that displays its coordinate axis using tags.-->

      video:

      code:

      import c4d
      
      doc: c4d.documents.BaseDocument  # The document containing this field object.
      op: c4d.BaseTag  # The Python tag containing this code.
      flags: int  # The execution flags of `main()`. See c4d.EXECUTIONFLAGS for details.
      priority: int  # The execution priority of this tag. See c4d.EXECUTIONPRIORITY for details.
      tp: c4d.modules.thinkingparticles.TP_MasterSystem  # The TP system of the document.
      
      
      def main() -> None:
          """Called by Cinema 4D to execute the tag.
          """
          # Get the object the tag is attached to and its global position.
          pass
      
      
      
      
      
      
      def draw(bd: c4d.BaseDraw) -> bool:
          # Called to display some visual element in the viewport. Similar to TagData.Draw.
          # Write your code here
          if op[c4d.EXPRESSION_ENABLE]:
              size = 40  #  40 pixel length line
              bd.SetMatrix_Screen()
              start = c4d.Vector(200)
              end = start + c4d.Vector(size,0,0)
              bd.SetPen(c4d.Vector(1.0))
              bd.DrawLine2D(start, end)
      
              mg = op.GetMain().GetMg()
              pos = bd.WS(mg.off)
      
      
              length = size/bd.WP_W(pos,True)
      
      
              bd.SetPen(c4d.Vector(1.0,0,0))
              x = bd.WS(mg * c4d.Vector(length,0,0))
              bd.DrawLine2D(pos,x)
              bd.SetPen(c4d.Vector(0,1.0,0))
              y = bd.WS(mg * c4d.Vector(0,length,0))
              bd.DrawLine2D(pos,y)
              bd.SetPen(c4d.Vector(0,0,1.0))
              z = bd.WS(mg * c4d.Vector(0,0,length))
              bd.DrawLine2D(pos,z)
      
      
          return True
      

      Thanks for any help!

      posted in Cinema 4D SDK 2024 python
      chuanzhenC
      chuanzhen