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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How to use GetPolygonW/R under Python? ...if at all

    Cinema 4D SDK
    r21 python c++
    2
    4
    510
    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.
    • CairynC
      Cairyn
      last edited by Cairyn

      Hello;

      looking at the functions of PolygonObject, I notice that two obvious C++ functions have made it into the Python interface: GetPolygonW and GetPolygonR.

      Both functions return a PyCObject, which to my knowledge is a connector object between Python data and C++ data. But it's not included in the API documentation.

      We also do not have examples for these functions in the Python code samples, and they aren't mentioned in a Python context on the Café. So, the question beckons: What can you use them for?

      And is the actual way to set all polygons in a PolygonObject really a loop over SetPolygon, or am I missing something? There is no method SetAllPolygons as equivalent for SetAllPoints in PointObject. (Of course I can program such a function as a loop, but I feel as if I'm missing a trick here...)

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by ferdinand

        Hi,

        PyCObject is not documented because it is part of the Python standard library. It is basically just a void pointer and its intended use is in a Python as a glue language scenario between two C applications. I also always found it a bit puzzling with which frequency this type is included in the SDK, given its rather limited utility for must users.

        About the specific polygon stuff. You are right, writing polygons is awkwardly inefficient in Python. But there is no better way (or at least I am not aware of one).

        Cheers,
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        CairynC 1 Reply Last reply Reply Quote 1
        • CairynC
          Cairyn @ferdinand
          last edited by

          @zipit Indeed! I never got the idea to look into the standard library. The type struck me as some special construct to link Python and C data types in C4D. (Well, it does, but differently from what I assumed.)

          I guess the inefficiency of poly access in Python is due to the fact that Python doesn't have any kind of array that works like C arrays, so there must be an abstraction layer present. Ah well. Given the speed of Python, it's probably better not to do any polygon stuff there, anyway.

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand
            last edited by ferdinand

            Hi,

            jeah, that is probably somewhat the reason. Although Python has true statically typed arrays, which also can be used to directly in-place manipulate C arrays (i.e. array.array), from what I understand it is quite cumbersome to achieve such linkage. This is probably the reason why Maxon does not bother in this case and others like for example vertex colors. Including these access points is still a bit puzzling though. Maybe they are somehow used internally? But I cannot think of a case where this would make sense.

            Cheers,
            zipit

            MAXON SDK Specialist
            developers.maxon.net

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