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. baca
    3. Posts
    • Profile
    • Following 0
    • Followers 0
    • Topics 28
    • Posts 108
    • Best 10
    • Controversial 0
    • Groups 0

    Posts made by baca

    • RE: Spline Generator GetVirtualObjects() + GetContour()

      Thanks @ferdinand

      I appreciate your explanation and solution.

      Honestly I also felt input based spline generators looks confusing because you'll need to implement both GVO and GC.
      But I already made quite a lot of these plugins, so I'll just follow hacky solution.
      Hoping it would lasts some time for newer C4D versions.

      posted in Cinema 4D SDK
      bacaB
      baca
    • Spline Generator GetVirtualObjects() + GetContour()

      Hi team,

      I only recently noticed there's an issue with Spline Generators which utilized both GVO and GetContour, and this object has a Rope Dynamics tag.
      Spline simulates properly while timeline is playing, but once paused — returns to it's initial state because of GVO.
      If generator has only GetContour() method implemented then it's working fine, except source child object is not being hidden.

      If it's not a bug — are there workarounds?

      To replicate the issue — official example could be used https://github.com/Maxon-Computer/Cinema-4D-Python-API-Examples/blob/master/plugins/py-osffset_y_spline_r16/py-osffset_y_spline_r16.pyp

      posted in Cinema 4D SDK python 2025
      bacaB
      baca
    • RE: Syntax highlight in VS Code under MacOS

      Thanks, I forgot about the extension.
      I didn't use the connection to Cinema4D, but syntax highlighting works just fine.

      posted in Cinema 4D SDK
      bacaB
      baca
    • Syntax highlight in VS Code under MacOS

      Hi,
      I just installed MacOS (MBP M1) from scratch, and looking for syntax highlighting in VS Code.
      Official c4dpy Manual doc has no instruction for MacOS.
      When trying to set interpreter to /Applications/Maxon Cinema 4D 2025/c4dpy.app/Contents/MacOS/c4dpy I get this error

      2024-11-09 22:17:14.074 [info] > "/Applications/Maxon Cinema 4D 2025/c4dpy.app/Contents/MacOS/c4dpy" -I ~/.vscode/extensions/ms-python.python-2024.18.1-darwin-arm64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.18.1-darwin-arm64/python_files/interpreterInfo.py
      2024-11-09 22:17:29.115 [error] [Error: Command failed: "/Applications/Maxon Cinema 4D 2025/c4dpy.app/Contents/MacOS/c4dpy" -I /Users/user/.vscode/extensions/ms-python.python-2024.18.1-darwin-arm64/python_files/get_output_via_markers.py /Users/user/.vscode/extensions/ms-python.python-2024.18.1-darwin-arm64/python_files/interpreterInfo.py
      sysctl: No such file or directory
      	at genericNodeError (node:internal/errors:984:15)
      	at wrappedFn (node:internal/errors:538:14)
      	at ChildProcess.exithandler (node:child_process:423:12)
      	at ChildProcess.emit (node:events:531:35)
      	at maybeClose (node:internal/child_process:1105:16)
      	at ChildProcess._handle.onexit (node:internal/child_process:305:5)] {
        code: null,
        killed: true,
        signal: 'SIGTERM',
        cmd: '"/Applications/Maxon Cinema 4D 2025/c4dpy.app/Contents/MacOS/c4dpy" -I /Users/user/.vscode/extensions/ms-python.python-2024.18.1-darwin-arm64/python_files/get_output_via_markers.py /Users/user/.vscode/extensions/ms-python.python-2024.18.1-darwin-arm64/python_files/interpreterInfo.py'
      }
      

      Several years ago I deal with python package symlink if I remember correctly, but I can't find this instruction anymore.
      Would be thankful for any suggestion.

      posted in Cinema 4D SDK python macos
      bacaB
      baca
    • RE: c4dpy -g_encryptPypFile fails: cannot find pyp file - plugin registration failed

      Hi @ezeuz, @ferdinand,

      Back in a days, it was run with python file as a second argument, like so:
      c4dpy.exe dummy.py -g_encryptPypFile py-commanddata_dialog_r13.pyp
      where dummy.py just a blank file.

      posted in Bugs
      bacaB
      baca
    • RE: Browsing field layers causes dangling/not alive references

      Thanks @ferdinand ,

      Appreciate your answer.
      Since cloning might dramatically reduce performance — I'll pay attention to this information, and will try to find the issue.

      Currently the thing is — my plugin worked for years (starting R25 if I remember correctly), and this part of the code worked as expected all this time without modifications.
      It just iterates through fieldlist layers and calculate dirty value in order to redraw generator within GetVirtualObject() scope.

      After updating to 2024.4 I get reported — my plugin stoped to work.
      It was hard to debug the issue, since I printed layer or result of IsAlive() — issue didn't replicated. So the quickest resolution was to yield cloned layer.

      It's not easy for me to share sample which reproduces the issue, I have complex structure of code. Maybe I'll spend sometime later if I'll not be able to get rid of the cloning.
      But since I spend several hours to resolve that issue, I wanted to leave a comment for those who just uses your sample in their code, and it stop to work.

      posted in Bugs
      bacaB
      baca
    • Browsing field layers causes dangling/not alive references

      @ferdinand said in Field Refusing Object:

          def getFieldLayers(node):
              """
              """
              visited = []
              end = node.GetUp() if isinstance(node, c4d.GeListNode) else None
      
              while node:
                  # If the current node is a newly encountered one.
                  if node not in visited:
                      visited.append(node)
                      # When it is a field layer, yield it and deal with group
                      # fields ...
                      if isinstance(node, c4d.modules.mograph.FieldLayer):
                          yield node
                          linkedNode = node.GetLinkedObject(doc)
                          if linkedNode and linkedNode.CheckType(c4d.Fgroup):
                              # Get the field list and iterate over it.
                              fieldList = linkedNode[c4d.FIELDGROUP_FIELDS]
                              root = fieldList.GetLayersRoot()
                              for nestedNode in getFieldLayers(root):
                                  yield nestedNode
      
                      # There are more special cases in the field list hierarchy,
                      # e.g., folders, which also have to be treated specifically.
                      # I did not do that here.
      
                  # Normal depth-first traversal of a node tree
                  if node.GetDown() and node.GetDown() not in visited:
                      node = node.GetDown()
                  elif node.GetNext():
                      node = node.GetNext()
                  else:
                      node = node.GetUp()
                  if node == end:
                      return
      

      If anyone else relies on this code (many thanks @ferdinand for this great example)
      for some reason yield node in 2024.4 emits exception:

      ReferenceError: the object 'c4d.modules.mograph.FieldLayer' is not alive

      Currently I went with yield node.GetClone() — issue is gone and it works as expected.

      But I'm not sure if it's proper way.

      posted in Bugs 2024 python
      bacaB
      baca
    • RE: How to get OutLine of Polygon object

      @Paul-Everett not really

      In fact, if it's not convex-hull geometry, some edge might be fully or partially covered by some polygon(s) laying in front if this edge.
      0d389c8c-5061-4b16-b2bd-cb9d29c5f56f-image.png

      posted in General Talk
      bacaB
      baca
    • RE: Python field error

      @SweepingMotion nice finding
      Yes, there are quite a few issues in the sample codes everywhere.
      To fix the Python Field, I think it's required to change

          outputs._value = [
              c4d.utils.RangeMap((~mgEffector * mgInput * p).GetLength(), 100., 0., 0., 1., True)
              for p in inputs._position
          ]
      

      to

          outValues = outputs._value
      
          for index, p in enumerate(inputs._position):
              outValues[index] = c4d.utils.RangeMap((~mgEffector * mgInput * p).GetLength(), 100., 0., 0., 1., True)
      
          outputs._value = outValues
      
      posted in Cinema 4D SDK
      bacaB
      baca
    • RE: Python field error

      Hi @SweepingMotion ,
      Would be helpful if you'll provide sample project, or at least code for the python field.

      posted in Cinema 4D SDK
      bacaB
      baca
    • RE: C4D crashes when removing node via MSG_MENUPREPARE

      Hi @merkvilson ,
      try to add check for main thread scope:

          def Message(self, node, type, data):
              if c4d.threading.GeIsMainThread() and type == c4d.MSG_MENUPREPARE:
                  node.Remove()
      
      posted in Cinema 4D SDK
      bacaB
      baca
    • RE: VariableTag, Resize, and CopyTo

      @d_schmidt
      If this vertex data is going to be utilized by shaders, or deformers, or fields — you don't need to store any data there, your tag will be just a reference, so you'll need to fined derived tag on the cache.

      If you want to grab data exactly from the generator's tag, then this approach doesn't suit you.

      posted in Cinema 4D SDK
      bacaB
      baca
    • RE: VariableTag, Resize, and CopyTo

      Hi @d_schmidt, few releases ago Maxon changed the way how vertex maps are applies to the generators.

      I think nowadays generators tag data is not taken in respect.
      Cinema automatically propagates generators tags onto cache geometry, and evaluates fields from origin tag to each geometry.
      If there are no fields — your maps will have values of zero on your cache geo.

      Maybe you'll need to utilize AddToExecution() method to build geometry, return it as result of GetVirtualObjects(), then Cinema will propagates origin tags onto cache, and then you'll do your tags logic at priority of "Generators" 0+.

      posted in Cinema 4D SDK
      bacaB
      baca
    • RE: Python effector (Full control) - has no effect during render

      Hi Maxon team,

      Just want to bump up the issue, which is still here under the Cinema4D 2024.2

      posted in Cinema 4D SDK
      bacaB
      baca
    • Get clone position over spline for Spline Based Cloner/Matrix

      Hi,

      Is it possible to re-create uniform position over spline for clones when both Offset and Offset Variation are defined:
      c0f19a8b-88ee-4644-ae9b-17e727c1f39a-image.png

      Currently trying to recreate with Python random.random(),
      but either I made expression, either python's random is totally different to Cinema's random

      posted in Cinema 4D SDK python
      bacaB
      baca
    • RE: Python Effector with custom FieldList

      Any inputs?..

      posted in Cinema 4D SDK
      bacaB
      baca
    • RE: Python tag initalization?

      @gaschka
      I can think like hundreds of operations are nothing for the Python
      When it counts as thousands — you'll notice that.

      Optimizations requires some knowledge of Cinema tech side, to listen events, understand execution context, and so on.
      Because there might be multiple scenarios, which you're not expecting in your "optimal" logic.
      Main issue is the user — who will delete your key tags/objects, move objects within hierarchy, wrap objects into a null, and so on

      posted in Cinema 4D SDK
      bacaB
      baca
    • Python Effector with custom FieldList

      Hi,

      I'm developing Python Effector which will have FieldList parameter (separate of the default one).

      Since Cinema 2024 introduced some optimizations, Python Effector is not being automatically executed, once any of Field objects related to custom FieldsList object are updated in the document.

      I suppose there's no CheckDirty() method for Python Effector to check FieldList dirtyness.
      What would be the approach to force Effector update?

      Rough sample: py_effector_with_custom_field.c4d
      Just drag Spherical Field left to right with the mouse device.
      Here left Matrix with Python Effector where Field is attached to custom FieldList — doesn't updating,
      but right Matrix with Python Effector where Field is attached to default FieldList — does

      posted in Cinema 4D SDK python 2024
      bacaB
      baca
    • RE: Python: User Data Float Slider?

      Hi @gaschka ,

      I assume that would be percentile value, so you can also add unit, like

      squash_and_stretch_container[c4d.DESC_UNIT] = c4d.DESC_UNIT_PERCENT
      
      posted in Cinema 4D SDK
      bacaB
      baca
    • RE: Python: How to inject code into a Python tag?

      Hi @gaschka

      Nothing really confusing in your code, python is not very strict...

      I can only suggest to move out constants of the function scope,
      and there are plenty space to add verifications...

      And c4d.EventAdd() might be executed just once, in the end of the parent function where you creating objects and attaching tags
      Also don't forget to use document's StartUndo() AddUndo() EndUndo() methods when creating your objects.

      SOME_PYTHON_TAG_CODE = """
      import c4d
      
      def main():
          # my code for the Python tag
      
      # Execution
      if __name__ == '__main__':
          main()
      """
      
      def add_python_tag(obj):
          if not isinstance(obj, c4d.BaseObject):
              return None
      
          python_tag = obj.MakeTag(c4d.Tpython)
          python_tag[c4d.TPYTHON_CODE] = SOME_PYTHON_TAG_CODE
      
          return python_tag
      
      posted in Cinema 4D SDK
      bacaB
      baca