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

    How to expose an object function done in C++

    SDK Help
    0
    19
    3.5k
    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.
    • H
      Helper
      last edited by

      On 28/07/2016 at 16:15, xxxxxxxx wrote:

      Howdy,

      OK, I got the passing a BaseList as a prameter with the "G" format, but suppose I want to pass both a BaseList and an interger or real in the same function? How would that be formatted?

      Adios,
      Cactus Dan

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 29/07/2016 at 02:37, xxxxxxxx wrote:

        Originally posted by xxxxxxxx

        OK, I got the passing a BaseList as a prameter with the "G" format, but suppose I want to pass both a BaseList and an interger or real in the same function? How would that be formatted?

        Like the argument parsing in the function example extendpyapi_PassParameters() I posted above, concatenate the characters for each parameter.
        For instance:

        GeData data;
        Int32 integer = 0;
        Float real = 0.0f;
          
        const Char *kwlist[] = {"baselist", "integer", "real", nullptr};
        if (!pylib.ParseTupleAndKeywords(args, keywords, "Gif", kwlist, &data, &integer, &real))
            return nullptr;
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 29/07/2016 at 04:53, xxxxxxxx wrote:

          Howdy,

          DOH! It's the strings that always throw me off when they're used for anything other than printing.
          But I get it now:
          "$" = string format
          "i" = integer format
          "f" = float format
          "G" = GeData format

          Possibly if the example had the float first like "$fi" then I might have been able to figure that out. But, with it the other way around, no matter how many times I looked at it, I still saw the word "if", and got confused. 😊

          Thanks for the clarification.

          Adios,
          Cactus Dan

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 29/07/2016 at 05:53, xxxxxxxx wrote:

            You're welcome 🙂

            "C" can also be used to parse BaseContainer* too (note only pointer to BaseContainer, initialize with nullptr before calling ParseTupleAndKeywords()).

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 29/07/2016 at 06:07, xxxxxxxx wrote:

              Howdy,

              Thanks. Is there a complete list of formatting letters that you could post?

              Also, is there a way to add global symbols in python like in coffee, and if so, can you post an example?

              Adios,
              Cactus Dan

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 26/04/2017 at 00:05, xxxxxxxx wrote:

                Hello,

                I know this is a bit older topic but the last question from Cactus Dan was not answered and I also need it. Especially I need to transfer BaseObject to and from python script.

                So again, we just need a table of all formatting letters and types that Cinema python binding API uses.

                Just for completeness, python build-in formatting letters seems to work and are available here: https://docs.python.org/2.7/c-api/arg.html?highlight=parsetupleandkeywords#c.PyArg_ParseTupleAndKeywords

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  On 26/04/2017 at 02:38, xxxxxxxx wrote:

                  Hi Miro,

                  Originally posted by xxxxxxxx

                  I know this is a bit older topic but the last question from Cactus Dan was not answered and I also need it. Especially I need to transfer BaseObject to and from python script.

                  To parse a BaseList based object, use 'G' format character as show in my above code snippet's function  extendpyapi_PassBaseList(). The object can be casted to the most interesting type after retrieving it.

                  Originally posted by xxxxxxxx

                  So again, we just need a table of all formatting letters and types that Cinema python binding API uses.

                  PythonLibrary::ParseTupleAndKeywords() accepts the following format characters for Cinema 4D C++ API classes:
                  - $: String
                  - %: Filename
                  - M: Matrix
                  - V: Vector
                  - Q: Quaternion
                  - 😄 BaseContainer*
                  - G: GeData (versatile: can parse a BaseList, a custom data, a time, etc.)
                  - T: BaseTime
                  - X: BaseThread

                  Originally posted by xxxxxxxx

                  Just for completeness, python build-in formatting letters seems to work and are available here: https://docs.python.org/2.7/c-api/arg.html?highlight=parsetupleandkeywords#c.PyArg_ParseTupleAndKeywords

                  PythonLibrary::ParseTupleAndKeywords()also accepts the following standard format characters: b, B, j, h, i, I, v, l, L, r, f, d, c

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    On 27/04/2017 at 23:34, xxxxxxxx wrote:

                    That's perfect! Thank you.

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      On 24/09/2017 at 13:07, xxxxxxxx wrote:

                      Hello all,

                      It seems to be that i's only possible to make a python extension library as a plugin. Which plugin then is best suited? A command plugin, I would guess, or is there another plugin that loads completely automatic at startup?

                      I need something that is always available, so that I don't have to think about loading the library. Much like the c++ example here: page_creating_libraries.html

                      Regards,

                      Hermen

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        On 25/09/2017 at 01:29, xxxxxxxx wrote:

                        Hello,

                        a "_ plugin_" is just a custom module loaded by Cinema. So a "plugin" does not need to include anything e.g. a command data extension. You only have to implement PluginStart()/PluginMessage()/PluginEnd(), see Plugin Functions Manual. In such a PluginMessage () function you have to register your Python extension as shown above.

                        best wishes,
                        Sebastian

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

                          On 25/09/2017 at 02:53, xxxxxxxx wrote:

                          Aha!
                          Now I understand, thanks for clearing that up!

                          regards,

                          Hermen

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