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

    Custom data+gui access with GetParameter()

    Cinema 4D SDK
    c++ r21 r20 r19
    3
    6
    1.2k
    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.
    • rsodreR
      rsodre
      last edited by rsodre

      Hello,

      I have a custom data type for some time, and it works fine, without any GUI. I use it only to store data.
      Now I made a custom GUI, based on the DOTS example, and seems to work well. The GUI sets the data, I save the scene and when loaded it correctly displays the stored data.

      But, when I try to access my custom data using GetParameter(), it's always empty.
      I rarely use the object's container to access data, took me some time to figure out the data was hidden there, but I don't understand why GetParameter() can't access it.

      To check if I was doing something wrong, I added a DOTS parameter to my object, and the same happens with it. The code below is inside a Generator's GetVirtualObjects(), we can clearly see the difference.

      // With GetParameter() the dots array is always empty
      GeData dotsData;
      DescID desc( DescLevel( ID_USERDATA, DTYPE_SUBCONTAINER, 0 ), DescLevel( my_DOTS_parmeter, ID_SDK_EXAMPLE_CUSTOMDATATYPE_DOTS, 0 ) );
      op->GetParameter( desc, dotsData, DESCFLAGS_GET_0 );
      auto dots = static_cast<iCustomDataTypeDots*>( dotsData.GetCustomDataType( ID_SDK_EXAMPLE_CUSTOMDATATYPE_DOTS ) );
      ApplicationOutput( "Dots GetParameter() size = " + String::IntToString( dots ? dots->_points.GetCount() : -1 ) );
      // But the BaseContainer has it all...
      auto bc = op->GetDataInstance();
      dots = static_cast<iCustomDataTypeDots*>( bc->GetData( my_DOTS_parmeter ).GetCustomDataType( ID_SDK_EXAMPLE_CUSTOMDATATYPE_DOTS ) );
      ApplicationOutput( "Dots BaseContainer size = " + String::IntToString( dots ? dots->_points.GetCount() : -1 ) );
      

      Is that a limitation?
      How do I make the data available from GetParameter()?

      1 Reply Last reply Reply Quote 0
      • P
        PluginStudent
        last edited by PluginStudent

        No idea why it does not work out of the box.

        But you could implement NodeData::GetDParameter() to see if something weird happens there and to set the value yourself.

        Edit: I just tested the scenario in R20 and with RoundedTube and everything seems to work fine.

        1 Reply Last reply Reply Quote 1
        • ManuelM
          Manuel
          last edited by

          hi,

          I confirm what @PluginStudent said. If you call GetParameter, it will end in the GetDParameter of the object if implemented or in NodeData::GetDParameter() witch by default do nothing and return true. That's why your always retrieve an empty data.

          Don't forget to initialise your data or to take that into account in the GetDParameter function

          Cheers,
          Manuel

          MAXON SDK Specialist

          MAXON Registered Developer

          rsodreR 1 Reply Last reply Reply Quote 0
          • rsodreR
            rsodre @Manuel
            last edited by rsodre

            @m_magalhaes But GetParameter() does work for this custom type, when I'm not using a custom GUI.
            A LONG parameter with custom GUI also works with GetParameter().
            Sounds like the combination Custom type + Custom GUI is missing something to have GetParameter() out of the box.
            But SPLINE for example, is both custom type and custom GUI, and I can access with GetParameter().
            Ain't nothing missing on CustomGuiData, iCustomGui, CustomDataTypeClass or iCustomDataType to make it work?

            I understand how I can make it work with GetDParameter(), but it feels unnecessary, any object that needs it will have that same pasted code.

            1 Reply Last reply Reply Quote 0
            • ManuelM
              Manuel
              last edited by

              hi,

              after another look at it, the function will check the BaseContainer. If you Init the BaseContainer you don't even need the GetDParameter function.

              AutoAlloc<iCustomDataTypeDots> data;
              BaseContainer* bc = ((BaseList2D*)node)->GetDataInstance();
              bc->SetData(5000, GeData(ID_SDK_EXAMPLE_CUSTOMDATATYPE_DOTS, data));
              

              So yes, something is kind of missing, i need to figure this out. I need to dive to the code a bit. I didn't want to wait too much before giving you some feedback.

              Cheers,
              Manuel

              MAXON SDK Specialist

              MAXON Registered Developer

              rsodreR 1 Reply Last reply Reply Quote 0
              • rsodreR
                rsodre @Manuel
                last edited by

                @m_magalhaes No hurry, for now there's just one place where I need this, I get it using the BaseContainer. But I will probably use it more often, so if the DOTS example is updated I can replicate the solution to my own type and remove this workaround.

                Thanks!

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