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

    A bug that should be fixed in your Python API code generation (Applies to all recent versions)

    Cinema 4D SDK
    2
    3
    666
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mikegold10
      last edited by mikegold10

      The argument self should not appear in any of the following static method declarations that are part of the generated Python C4D API skeletal/placeholder code, since any good Python IDE will complain and/or flag correct user code that use these methods.

      In the future, you guys can do something like the following in ...resource\modules\python\libs:

      # You can also add the -n flag to the first grep in the pipe chain below, to add line number info after the file name
      grep -R -A2 -H "@staticmethod" * 2>&1 | grep -v "MAXON_" | grep -PB2 "def.*?self"
      

      I am not sure if the above grep comprehensively captures every one of these issues, but 99-100% of them should have been caught:

      python39/c4d/bitmaps/__init__.py:    @staticmethod
      python39/c4d/bitmaps/__init__.py-    def AllocWrapper(self, bmp):
      --
      python39/c4d/modules/mograph/__init__.py:    @staticmethod
      python39/c4d/modules/mograph/__init__.py-    def Create(self, flags, thread, doc, currentThreadIndex, threadCount, inputs, callers):
      --
      python39/c4d/utils/__init__.py:    @staticmethod
      python39/c4d/utils/__init__.py-    def PickObject(self, bd, doc, x, y, rad, flags):
      --
      python39/c4d/__init__.py:    @staticmethod
      python39/c4d/__init__.py-    def GetDistance(self, v1, v2):
      --
      python39/maxon/decorators.py:            @staticmethod
      python39/maxon/decorators.py-            @wraps(fn)
      python39/maxon/decorators.py-            def Auto(self, *args):
      --
      python39/maxon/decorators.py:            @staticmethod
      python39/maxon/decorators.py-            @wraps(fn)
      python39/maxon/decorators.py-            def ReferenceConvert(self, *args):
      --
      python39/maxon/decorators.py:            @staticmethod
      python39/maxon/decorators.py-            @wraps(fn)
      python39/maxon/decorators.py-            def Wrap(self, *args):
      --
      python39/maxon/decorators.py:            @staticmethod
      python39/maxon/decorators.py-            @wraps(fn)
      python39/maxon/decorators.py-            def NativeDataOrBuiltin(self, *args):
      --
      python39/maxon/decorators.py:            @staticmethod
      python39/maxon/decorators.py-            @wraps(fn)
      python39/maxon/decorators.py-            def _MaxonConvertOrFail(self, *args):
      --
      python39/maxon/interface.py:    @staticmethod
      python39/maxon/interface.py-    def Free(self):
      --
      python39/maxon/interface.py:    @staticmethod
      python39/maxon/interface.py-    def GetLocal(self):
      --
      python39/maxon/interface.py:    @staticmethod
      python39/maxon/interface.py-    def AllocEmpty(self):
      --
      python39/maxon/interface.py:    @staticmethod
      python39/maxon/interface.py-    def AllocFromUuid(self, uuid):
      --
      python39/maxon/interface.py:    @staticmethod
      python39/maxon/interface.py-    def AllocFromString(self, uuidStr):
      --
      python39/maxon/interface.py:    @staticmethod
      python39/maxon/interface.py-    def DescribeIO(self):
      --
      python39/maxon/interface.py:    @staticmethod
      python39/maxon/interface.py-    def CreateUuidString(self):
      --
      python39.win64.framework/lib/pathlib.py:        @staticmethod
      python39.win64.framework/lib/pathlib.py-        def link_to(self, target):
      

      Also, for all of the following, the @classmethod attribute should be changed to @staticmethod and the self argument should be removed, just like for the above cases:

      python39.win64.framework/lib/importlib/_bootstrap.py-    @classmethod
      python39.win64.framework/lib/importlib/_bootstrap.py:    def create_module(self, spec):
      --
      python39.win64.framework/lib/importlib/_bootstrap.py-    @classmethod
      python39.win64.framework/lib/importlib/_bootstrap.py:    def exec_module(self, module):
      --
      python39.win64.framework/lib/_collections_abc.py-    @classmethod
      python39.win64.framework/lib/_collections_abc.py:    def _from_iterable(self, it):
      --
      python39.win64.framework/lib/_collections_abc.py-    @classmethod
      python39.win64.framework/lib/_collections_abc.py:    def _from_iterable(self, it):
      
      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Thanks a lot some are false positive or even coming from the standard library.

        But I will fix the one that are wrong and update the doc 🙂

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • M
          mikegold10
          last edited by

          Hi, Maxime, great!

          if I come across any additional issues of a similar nature, I'll update this post.

          1 Reply Last reply Reply Quote 1
          • First post
            Last post