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

    Extending Python - Pass Variable Parameter?

    SDK Help
    0
    4
    399
    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 09/08/2016 at 16:13, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R13+ 
      Platform:   Windows  ; Mac  ;  Mac OSX  ; 
      Language(s) :     C++  ;   PYTHON  ;

      ---------
      Howdy,

      Is it possible to create a python extension function that takes an integer for the first parameter, and then a variable parameter for a second parameter, like I can do with a coffee extension function?

      For instance if I want the first parameter to be an ID, and then the second parameter to be either a bool, integer or float. Is that possible?

      Adios
      Cactus Dan

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

        On 09/08/2016 at 18:16, xxxxxxxx wrote:

        Howdy,

        OK, never mind. I took an educated guess and it worked perfectly:

        LONG id;
        GeData gdata;
          
        const CHAR *kwlist[] = {"integer", "gedata", NULL};
        if(!pylib.ParseTupleAndKeywords(args, keywords, "iG", kwlist, &id, &gdata)) return pylib.ReturnPyFALSE();
          
        if(gdata.GetType() != DA_LONG && gdata.GetType() != DA_REAL) return pylib.ReturnPyFALSE();
        

        The last line checks the type, so the function only accepts a bool, int or float (a bool is actually an int). 😉

        Adios,
        Cactus Dan

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

          On 10/08/2016 at 02:31, xxxxxxxx wrote:

          Hi,

          Yes, using a GeData is the way to go in Python to parse a parameter that can be of various types.

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

            On 10/08/2016 at 05:45, xxxxxxxx wrote:

            Howdy,

            Well, the educated guess was mainly in the use of the string "gedata". I sort of knew that a GeData was the way to go.

            That's why I asked in the other thread if you could post a complete list of parameters for the different types. 😉

            Adios,
            Cactus Dan

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