GeDialog::SetReal() + string?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/04/2008 at 13:09, xxxxxxxx wrote:

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

    ---------
    Howdy,

    I don't know if this is at all possible but I'd like to add a letter for a custom unit after the real value in an EditNumberArrows dialog gadget. I tried using:

    > SetString(MY_GADGET,RealToString(value)+uStr);

    and it seemed to work, but only if I typed a value into the field. If I try to use the arrows to change the number, it is then restricted to whole numbers between 0 and 100 (no fractions, no negative numbers and no numbers higher than 100)

    Is there another way to get the letter in after number with an EditNumberArrows gadget, and still maintain the use of the arrows?

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/04/2008 at 00:58, xxxxxxxx wrote:

    I think you have to write your own customgui element for this. I will look into it.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/04/2008 at 05:40, xxxxxxxx wrote:

    Howdy,

    Well, I seem to have stumbled upon something that actually works:

    > SetReal(MY_GADGET,value); \> SetString(MY_GADGET,RealToString(value)+uStr);

    If I first set the real value and then set the string value, it seems to work. I can now use:

    > GetReal(MY_GADGET,value);

    ... to get the the real value from the gadget, instead of trying to use:

    > GetString(MY_GADGET,str); \> value = str.StringToReal();

    ... to get the real value from the string in the gadget.

    My way of thinking was that we have a several ways available to us to set the value of an EditNumberArrows gadget:
    SetReal() - sets the real value normally
    SetMeter() - sets the real value then adds the current Cinema unit string
    SetDegree() - sets the real value then adds the degree character
    SetPercent() - sets the real value then adds the percent character

    So evidently, an EditNumberArrows gadget can accept string values, and there's bound to be some internal function that handles that. Displaying numbers in a field must surely convert a number value to a string first before it can display the characters, right?

    Then I saw that there are also several Container setters for gadgets, and it got me thinking that maybe SetReal() sets a separate container in the gadget than SetString(), so I gave it a shot. There's no info on the C4DGadget class in the SDK documentation, so I don't know for sure if that assumption is correct, but it seems to work without any problems. ;o)

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 07:57, xxxxxxxx wrote:

    Howdy,

    OK, there is one small problem with this method, and I think I'm just going to scrap the idea of having the units displaying. The problem is by resetting it to a string, it screws up the formula ability. I can't type in a "+" and a number to add to the current value, anymore. :o(

    Oh well, displaying the units was just for looks, but functionality is more important. ;o)

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 10:19, xxxxxxxx wrote:

    Have you tried the Parser class? This means evaluating the strings yourself (basically) but it does evaluation just like Cinema 4D does automatically. :)

    Here's an example if you haven't used it previously. Note the method where the parser is used. If you need this for AM, it may require a different method be invoked (Message() or SetDParameter()).

    > // GeDialog.Message \> //\*---------------------------------------------------------------------------\* \> LONG Message(const BaseContainer& msg, BaseContainer& result) \> //\*---------------------------------------------------------------------------\* \> { \>      if ((msg.GetId() == BFM_ACTION) && (msg.GetLong(BFM_ACTION_VALCHG) || msg.GetLong(BFM_ACTION_VALUE))) \>      { \>           LONG     action = msg.GetLong(BFM_ACTION_ID); \>           // Min \>           if (action == DE_MIN) \>           { \>                if (parser) \>                { \>                     String     expression; \>                     LONG     lval; \>                     Real     rval; \>                     Real     max; \>                     GetReal(DE_MAX,     max); \>                     GetString(DE_MIN,     expression); \>                     if (!parser->Eval(expression, &lval;, &rval;, UNIT_NONE, ANGLE_DEG, 10L) || (rval > max))     SetReal(DE_MIN, min); \>                     else     min     =     rval; \>                } \>                else \>                { \>                     Real     rval; \>                     GetReal(DE_MIN,     rval); \>                     // Reset Min \>                     if (rval > max)     SetReal(DE_MIN, min); \>                } \>           } \>           // Max \>           else if (action == DE_MAX) \>           { \>                if (parser) \>                { \>                     String     expression; \>                     LONG     lval; \>                     Real     rval; \>                     Real     min; \>                     GetReal(DE_MIN,          min); \>                     GetString(DE_MAX,     expression); \>                     if (!parser->Eval(expression, &lval;, &rval;, UNIT_NONE, ANGLE_DEG, 10L) || (rval < min)) SetReal(DE_MAX, max); \>                     else     max = rval; \>                } \>                else \>                { \>                     Real     rval; \>                     GetReal(DE_MAX, rval); \>                     // Reset Max \>                     if (rval < min)     SetReal(DE_MAX, max); \>                } \>           } \>           // Step \>           else if (action == DE_STEP) \>           { \>                if (parser) \>                { \>                     String     expression; \>                     LONG     lval; \>                     Real     rval; \>                     GetString(DE_STEP,     expression); \>                     if (!parser->Eval(expression, &lval;, &rval;, UNIT_NONE, ANGLE_DEG, 10L) || (rval > Abs(max-min)))     SetReal(DE_MAX, step); \>                     else     step =     rval; \>                } \>                else \>                { \>                     Real     rval; \>                     GetReal(DE_STEP,     rval); \>                     // Reset Step \>                     if (rval > Abs(max-min))     SetReal(DE_STEP, step); \>                } \>           } \>      } \>      return GeDialog::Message(msg, result); \> }



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 10:27, xxxxxxxx wrote:

    Howdy,

    Wow, I didn't even know that class existed. :oO

    Have you used it before?

    Edit:
    DOH! I see you have. :o)

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 12:36, xxxxxxxx wrote:

    Howdy,

    Yee-Ha! It works. Thanks Robert. Once again you've saved the day. :o)

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 12:45, xxxxxxxx wrote:

    You're welcome.

    How many times have you saved my a.., er, day. ;)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 13:43, xxxxxxxx wrote:

    Howdy,

    Well, I cheered a bit too soon. It works but not on an intel Mac, in either R9 or R10.

    I'm testing R9.1 on a PPC Mac and an AMD PC, and testing R9.6 and R10.1 on an intel Mac, and R10.1 on the AMD PC. It works everywhere except the intel Mac. What's the deal with that? :o(

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 13:54, xxxxxxxx wrote:

    No problems here on an Intel Mac in R10.111 - though I'm not using any units.

    What version SDK are using for these? Does it completely fail or is it only failing with particular formula operators?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 15:20, xxxxxxxx wrote:

    Howdy,

    It totally fails on the intel Mac.

    Actually, the only place it works properly is on the G4 PPC Mac and on the PC in R9. R10 on the PC is giving me the wrong result.

    If I have a value of 0.254 already in the dialog's edit number field, and I type in at the end of that "+1", and hit tab or enter, the result should be 1.254.

    But these are the test results:
    G4 Mac running R9.1 - result = 1.254
    G4 Mac running R9.5 - result = 1.254
    G4 Mac running R9.6 - result = 1.254
    G4 Mac running R10.5 demo - result = 1.077
    PC running R9.1 - result = 1.254
    PC running R10.1 - result = 1.077
    Intel Mac running R9.6 - result = 125.4
    Intel Mac running R10.1 - result = 78.419

    OK, first in the GeDialog::Command() function I have this:

    > case MY_EDITNUMBER: \>       GetString(MY_EDITNUMBER,str); \>       val = ParseString(str); \>       SetReal(MY_EDITNUMBER,val); \>       SetString(MY_EDITNUMBER,RealToString(val)+uStr);

    My parser function receives the string and first strips all of the letter characters from the string (A-Z and a-z) and then parses the remaining string. It seemed like the letter characters were interfering with the parser's result.

    Then I have a print statement after the parser evaluates the string in my ParseString() function to print out the result:

    > GePrint("String = "+expression+" = "+RealToString(rVal));

    On the G4 Mac and PC in R9.1 it prints:
    String = 0.254+1 = 1.254
    Which is correct. :o)

    On the G4 Mac and the PC in R10 it prints:
    String = 1.077 = 1.077
    it looks like Cinema parsed the string before it got to my parsing function, I'm assuming it parsed it before the GeDialog::Command() function. :o(

    On the intel Mac in R9.6 it prints:
    String = 0.254+1 = 1.254
    Which is correct, BUT the output to the dialog is 125.4 :o(

    On the intel Mac in R10 it prints:
    String = 78.419 = 78.419
    Again, it looks like Cinema parsed the string before it got to my parsing function. :o(

    The Parser class in both R9 and R10 SDK's are identical. So, needless to say, I just may go back to the "no unit display" in the number edit field. :o(

    Trying to get the unit string into the number edit field is becoming too much of a hack, and I'd much prefer proper functionality for the plugin.

    Thanks anyway.

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 16:12, xxxxxxxx wrote:

    Howdy,

    OK, sorry about the intel Mac running R9.6. It's actually correct, but I had another field set to a value that was mulitpying it by 100, so that was a simple DOH! mistake on my part.

    But I'm still curious why in R10, it parses the string before my code can get to it. :o(

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 16:22, xxxxxxxx wrote:

    It may be that Message() is getting to it first. ;)

    I noticed that I use both in my code - in my non-modal plugin dialog Command() is used whereas in the modal dialog Message() is used. I don't think that this is by accident - but can't remember why it was done these different ways.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 16:30, xxxxxxxx wrote:

    Howdy,

    Hmmmm, could be.

    But I'm done going back and forth over this minor problem. The rest of my plugin is ready for release, and I'm letting this silly little thing hold me up. :o(

    I can always add that in an update. I've only commented out the functions for it so that when I get back to it, I won't have to start from scratch. ;o)

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/04/2008 at 16:51, xxxxxxxx wrote:

    Sounds like a plan. :) Can't wait to see this plugin - I know what you've been trying to achieve here.


Log in to reply