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

    "two-leveled" ID ( [50004,1] ) of a Constraint Tag? C++

    Cinema 4D SDK
    c++ r25
    2
    3
    517
    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.
    • Y
      yaya
      last edited by ferdinand

      Hello.

      Language: C++

      Can you help me to figure it out?
      I understand how to set a simple single-DescLevel parameter like a sphere radius. I've found in manual how to set up more complex double desclevel parameter, like CubeLen.
      But what I can`t understand is - how to set parameter like a ID_CA_CONSTRAINT_TAG_CLAMP_TO
      of a constraint tag?
      Lets say to a ID_CA_CONSTRAINT_TAG_CLAMP_TO_SURFACE?

      It is not simple to understand from a manual.

      It is just a simple Integer type, and it should be simple to assign value, but it is not simple to get access exact into the parameter.
      In Python it has the "two-leveled" ID ( [50004,1] ) and looks as simple as possible:

      Constraint[50004,1] = 4
      

      But how to assign it in C++?

      https://www.ragdollplugin.com

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

        Hello @yaya ,

        thank you for reaching out to us. The bracket syntax, i.e., overloading object.__getitem__, is a Python specific convenience method. The special flexibilty of Python's parameter syntax and how it does translate to DescID and DescLevel has been discussed multiple times here on the forum, e.g., here. For details on DescID, we would recommend reading our C++ manual for that type. See end of my posting for how your specific case would translate.

        Cheers,
        Ferdinand

        // This example assumes that 50004 is a sub-container of integers ...
        
        const DescLevel firstLevel (50004, DTYPE_SUBCONTAINER, 0);
        const DescLevel secondLevel (0, DTYPE_LONG, 0);
        const DescID someId = DescID(firstLevel, secondLevel);
        
        // Assuming someNode is a pointer to some C4DAtom
        GeData data;
        if (!someNode->GetParameter(someId, data, DESCFLAGS_GET::NONE))
            // Do something to deal with failing to retrieve the parameter.
            // ...
        
        // The value of the parameter.
        const Int32 someParameterValue = data.GetInt32();
        

        MAXON SDK Specialist
        developers.maxon.net

        Y 1 Reply Last reply Reply Quote 0
        • Y
          yaya @ferdinand
          last edited by yaya

          Hello @ferdinand ,

          Thank you for your answer!
          I made a search by the forum but have lost your post above because of I sorted topics only for a C++. My bad)
          I also read the C++ manual for a DescID and DescLevel and the examples in there. But they are not cover the examples like my above for a [50004,1] - IDs (or maybe I've not found).
          For a Python version of my plugin I did not have a problem with understanding the access to the parameters at all. But on C++...
          For example I stuck in my mind with figuring out how does the second DescLevel work. But after your explanation above I understand it. The first level DescLevel in your code locates this sub-container: изображение_2021-10-15_181737.png

          And next with the codeline:

          const DescLevel secondLevel (0, DTYPE_LONG, 0);
          

          we access into the one of this items.

          So I've changed your your code into:

          const DescLevel secondLevel (1, DTYPE_LONG, 0);
          

          and I got access into the 5004,1 item.

          Thank you very much!

          https://www.ragdollplugin.com

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