DC - User value overrides formula
-
There's a DC forum?
...or do you refer to the normal Component forum? -
Thomthom,
I think (have not tried DC formulas yet myself) that you should create a custom attribute for the user to fill their value in, and then let the Angle attribute calculate its value based on the user input, but leaving it invisible from the user.
Anssi
-
So there is no way to let the user see that the value has been corrected?
-
Also, the docs says that if the example
=SMALLEST(CURRENT("LenX"),20, 10)
was put into the LenX value it'd restrict it. Or am I reading it completely wrong?
-
Hey Thomas, did you ever figure all this out? I am also confused by the smallest function. I am getting it to snap sometimes, but always to the smallest of the options given (which makes sense, right?). Except that the documentation is confusing to me. The quote you gave is:
=SMALLEST(CURRENT("LenX"),20, 10)
Which if inserted to the LenX cell is saying that LenX will equal the smallest of the 3 values (LenX, 10 or 20). But the 10 or 20 is confusing, because 10 will ALWAYS be smaller than 20. So their example should just be:
=SMALLEST(CURRENT("LenX"),10), right? Then the scaling would always be stuck at never going larger than 10.
Anyhow, the documentation seems wrong, am I right in thinking that?
Chris
-
@thomthom said:
So there is no way to let the user see that the value has been corrected?
That is my understanding. I made a DC house (which I am very proud of ) that allows the user to input a stair width by hand. So they could make the stairs wider than the house. But I built in a check to limit it to the width of the house or whatever they typed in, whichever was smaller (I used an "if" statement though, not the "smallest", which would have worked I see now). And so when the DC reconfigures itself, the user input box is not updated to show the actual length. It still shows the invalid length, even though the stairs are not actually that length. I think that is just a part of DC's (for now?).
Chris
-
Yea, I think it basically doesn't work as we expect. I had a look at the lorry DC example that came with SU. The one you can scale the length of but it has a minimum and maximum length. It did however not have any entry in Options to set the length. When I made that attribute editable by the user and typed in a value it broke the formula.
So unless the SU team can shed some light on this I think we have to do with some workarounds.
I think we have to make a second attribute that stands for the MAX and MIN calculation as a buffer. That leaves the drawback that the user wont get feedback of the corrected value. ...unless you make the buffer attribute visible read only. All though, that's not ideal either IMO.
I think this is something worth putting in for the wishlist.
-
I agree, it would be nice if there was a way that the value shown in the option dialog could get updated if an internal formula is limiting it. Perhaps there could be a way to limit the input in the Options, through the use of formulas also. So the input box could know before the user enters a value what the current acceptable range is. So lets say the value is limited to 1 - 10. Those values could be passed on to the options box and if the user input 20, it would automatcally take it down to 10. That works for numbers, but I don't know how text would work or if this even applies to text.
Chris
-
Just had a thought... would it be possible for the validating attribute to correct the user value if it's out of range by using an IF statement in the validating attrib? ...or can the IF statement only be used for onClick? I haven't looked into the IF statements with DCs.
Gotto do some digging.
-
You can use the if statement to correct what they have entered. For example:
The are inputing a LenX through the Options box.
The actual attribute they are changing is a custom one called "UserLenX".
You want them to be able to anything between 1 and 10, but 10 is the max.
They Enter 15, just to be funny
But you have in your actual LenX cell this formula:
=if("UserLenX">10,10,UserLenX)That is saying that if the UserLenX is greater than 10, then the cell's value should equal 10. If it is smaller than 10, then use the number they provided.
Another way to do it would be:
=smallest("UserLenX", 10)
That will choose the smallest value between what they entered (15) and 10. So it will choose 10 and LenX is then set to 10.
But neither of these options will update the value box in the DC Options dialog, unless like you said above you have another menu item that merely shows the actual value of X, after all checks are run on the value they entered (ie it would show 10 and their box would still show 15. But at least they could know what the value was actually constrained to).
Its an interesting topic, wish there was a better solution,
Chris
-
Its a pity you cant call an alert form a formula, would be pretty useful in this sort of situation.
Another request perhaps?
-
I agree that the Alert should be more than just an OnClick. There are a lot of text functions too which I haven't explored too much yet.
You can create a crude messaging system though. I've attached a dynamic Message Box. Try importing it and then use the Choose Options dialog to change its size.
It works, even if it isn't elegant.
William
-
Yeah, thats a nice solution William. Is there a way to better design the options dialog box? Perhasp there would be some way with the html tags to make that a popup message or something that only shows up if its too large of a value. Maybe?
Chris
Advertisement