Set Slider minimum programmatically [SOLVED]



  • On 22/04/2015 at 06:17, xxxxxxxx wrote:

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

    ---------
    Hi,

    I want to restrict the minimum value of my real slider (programmatically) to another value from another slider.

    Could somebody please show me how to do this?
    I've searched the web for some hours now, with no result.

    Restricting the slider inside the .res file is no problem, as long as I use defined values, eg. 1; 33; 4.75.

    Thanks in advance for your help and time!
    Greetings,

    Casimir Smets



  • On 22/04/2015 at 06:42, xxxxxxxx wrote:

    Hello,

    the minimum value of a parameter is not part of the "parameter" itself but of it's Description. The minimum value is defined with DESC_MIN, the minimum slider value with DESC_MINSLIDER.

    The description of a parameter can be defined in GetDDescription(). You find an example on how to create such a description in the Morph Mixer plugin in the SDK. You can also find many examples on how to edit existing descriptions, like in the Sculpt Deformer plugin.

    Best wishes,
    Sebastian



  • On 22/04/2015 at 07:30, xxxxxxxx wrote:

    Hi Sebastian,

    Thanks for your answer!
    I've tried to implement the method inside my project, but it seems to do nothing.
    Here is my code:

      
    Bool MyPluginData::GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags)  
    {  
      if (!description->LoadDescription(IDS_MYPLUGIN))  
          return false;  
      const DescID* singleid = description->GetSingleDescID();  
      
      DescID cid = DescLevel(10002, DTYPE_REAL, 0);  
      if (!singleid || cid.IsPartOf(*singleid, nullptr))  
      {  
          BaseContainer bc = GetCustomDataTypeDefault(DTYPE_REAL);  
          bc.SetFloat(DESC_MIN, SLIDER2);  
          if (!description->SetParameter(cid, bc, DescLevel(0)))  
              return true;  
      }  
      
      flags |= DESCFLAGS_DESC_LOADED;  
      
      return true;  
    

    Does anybody see the problem here?
    I get no errors inside Xcode, and none in C4D.

    Thanks in advance for your help and time!

    Greetings,
    Casimir Smets



  • On 23/04/2015 at 00:51, xxxxxxxx wrote:

    Hello,

    I assume that the parameter 10002 does not yet exist and you want to create it from scratch.

    You are creating the parameter but crucial elements are missing.

    • The third argument of SetParameter() is the ID of the group that hosts that parameter. You don't define a group. You could use a group you define in your description resource file or a standard group of your plugin type.
    • Also, you don't define a name for your parameter (DESC_NAME).
    • And finally you don't say that you want to display your parameter as a slider. You can define to use a custom GUI to display you parameter (DESC_CUSTOMGUI).

    You find a good example in the Morph Mixer plugin.

    Best wishes,
    Sebastia



  • On 23/04/2015 at 06:01, xxxxxxxx wrote:

    Hi,

    I've added my parameters inside the .res file, so it allready exists. Because of that, it has allready a name and is standard a slider.
    I have changed the group ID to the correct group, but it still doesn't work.

    Also saw a few mistakes I made, so I changed it to this:

      
    Bool MyPluginData::GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags)  
    {  
      if (!description->LoadDescription(IDS_MYPLUGIN))  
          return false;  
      const DescID* singleid = description->GetSingleDescID();  
      
      DescID cid = DescLevel(10002, DTYPE_REAL, 10000);  
      if (!singleid || cid.IsPartOf(*singleid, nullptr))  
      {  
          BaseContainer bc = GetCustomDataTypeDefault(DTYPE_REAL);  
          bc.SetFloat(DESC_MIN, SLIDER2);  
          if (!description->SetParameter(cid, bc, DescLevel(10000)))  
              return false;  
      }  
      
      flags |= DESCFLAGS_DESC_LOADED;  
      
      return SUPER::GetDDescription(node, description, flags);  
    

    But this still doesn't work.
    Does anybody have any idea what could be the problem here?
    Thanks in advance for your help and time!
    Greetings,

    Casimir Smets



  • On 23/04/2015 at 09:04, xxxxxxxx wrote:

    Hello,

    in your code you are adding a parameter to the description and overwriting the existing BaseContainer with an (almost) default one; you are not editing an existing parameter.

    To edit an existing parameter you have to access the BaseContainer with the information on that parameter. You do this with GetParameterI(). The SDK project contains several examples on how to use this function, like the Sculpt Deformer plugin.

    Best wishes,
    Sebastian



  • On 24/04/2015 at 05:33, xxxxxxxx wrote:

    Hi,

    I've finally got it working, but the only problem is that my slider gets duplicated, which is not what I want.
    I'm going to have a complex user interface, so doubling my sliders is bad.

    Here is my code:

      
    Bool MyPluginData::GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags)  
    {  
      if (!description->LoadDescription(node->GetType()))  
          return false;  
      const DescID* singleid = description->GetSingleDescID();  
      DescID cid = DescLevel(10002, DTYPE_REAL, 10000);  
      if (!singleid || cid.IsPartOf(*singleid, nullptr))  
      {  
            AutoAlloc<AtomArray> ar;  
            BaseContainer* bc = description->GetParameterI(DescLevel(10002), ar);  
            if (!bc)  
            {  
                return false;  
            } else {  
                bc->SetFloat(DESC_MIN, 8.0);  
            }  
            if (!description->SetParameter(cid, *bc, DescLevel(10000)))  
                return false;  
        }  
        flags |= DESCFLAGS_DESC_LOADED;  
        return SUPER::GetDDescription(node, description, flags);  
    }  
    

    Does somebody know how to fix this? How to not duplicate your sliders?

    (For the people not reading my whole post: I've added my sliders inside my .res file, and I want to set the minimum value programmatically, so I can constrain it with other sliders)

    Thanks for your help and time!!
    Greetings,
    Casimir Smets



  • On 24/04/2015 at 06:19, xxxxxxxx wrote:

    Hi Casimir,
    I think, you just need to delete the SetParameter() part, as you are not adding a new dynamic description, but just edit a part of an existing description and you retrieved the container instance via GetParameterI().



  • On 24/04/2015 at 07:03, xxxxxxxx wrote:

    Hi Andreas,

    It seems that you are right! :)
    If I delete

      
    if (!description->SetParameter(cid, *bc, DescLevel(10000)))  
      return false;  
    

    I get my slider only once.

    Thanks for your help, Andreas and Sebastian!!
    Greetings,
    Casimir Smets



  • On 27/04/2015 at 02:31, xxxxxxxx wrote:

    Hi,

    I have 2 sliders, slider2 limits slider1's MIN value.
    So if I make the value of my first slider lower, I can't get under the value of my second slider.
    However, if I make the value of my second slider lower, the first slider sometimes follows, which I don't want. To be more clear, sometimes it follows to the exact value, sometimes to a different value than my second slider, but still different than the previous value; and sometimes it doesn't change, which is what I want.

    I hope my problem is clear to you guys, if not, ask me some more questions!
    Does anybody know what causes the problem here?

    The code can be found on a previous post on this topic.
    Thanks in advance for your help and time!

    Greetings,
    Casimir Smets



  • On 27/04/2015 at 03:22, xxxxxxxx wrote:

    Check the SDK examples. You need to overload the Message member function and then check for the DESCRIPTION_VALIDATE message id. Then you can use CutReal() to limit one element value based on another. If you are already doing this some code is required to see what's wrong.



  • On 27/04/2015 at 05:36, xxxxxxxx wrote:

    Hi Katachi,

    It seems like you are my hero! :D
    This is exactly what I want, nothing more, nothing less! Thanks for your answer!

    I'm confused and wondering why the moderators didn't show me this simple and effective method.
    But still, you can mark this as closed!

    For the other people having the same problem, I strongly recommend the way with Message: once again, because its so easy and effective.

    Greetings,
    Casimir Smets



  • On 27/04/2015 at 05:47, xxxxxxxx wrote:

    They are all human and sometimes you simply don't think of every other way (spooking in the back of your head with so many other things), so cut the support some slack ;) Glad it worked out fine for you.



  • On 27/04/2015 at 06:51, xxxxxxxx wrote:

    Hi Casimir,

    you need to give us some time to react... you asked the question with slider dependencies roughly four hours ago. And if Katachi hadn't been faster (thanks Katachi 🙂), you probably would have gotten a similar answer from us by now.
    Please also always keep in mind, PluginCafe forum is not the only place we work on.
    On our developer support site, we describe what we do and what not: About us
    The support on PluginCafe is free and we try to keep our answer times below two workdays (which to me doesn't sound too bad for free support). And on average we are even a bit faster.



  • On 27/04/2015 at 07:00, xxxxxxxx wrote:

    Oh, don't get me wrong, I'm not mad at them or something.
    I just thought this to be a simple and standard way to do it. Clearly it's not that standard, I guess, that's all.
    And I appreciate the time they put in helping me and others around here so much!! (This goes for everybody, moderators or users)
    It also wasn't criticism, just a thought spooking in my head ;)

    Thanks for your help guys!
    Greetings,
    Casimir Smets


Log in to reply