Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Featurescript: Editing Logic Function does not update length parameter in Feature UI
antlu65
Member Posts: 59 EDU
Have looked through the documentation as well as the Spur Gear example code, but I seem to be missing something obvious. I would like for the Logic Editing Function of my Custom Feature to change a numerical value entered by the user, and for this updated value to be reflected in the Feature UI dialog. When the user changes any parameter in the Feature UI, the Logic Editing Function is triggered. I modify the corresponding value in the 'definition' variable and return it from the function. This appears to work for boolean values, but does not work for my numerical value.
I've attached a minimal document illustrating my issue here:
https://cad.onshape.com/documents/99f64ae634cf6ee14ab3fece/w/7f6c6a530464ce65695a2d3b/e/ec2fc7c827f04f821c42d795
(As an aside, when I try to 'Ask a Question' directly in the Featurescript subforum, it indicates I am not allowed to post questions there. Does that forum require additional privileges? Or am I just asking really silly questions...)
I've attached a minimal document illustrating my issue here:
https://cad.onshape.com/documents/99f64ae634cf6ee14ab3fece/w/7f6c6a530464ce65695a2d3b/e/ec2fc7c827f04f821c42d795
(As an aside, when I try to 'Ask a Question' directly in the Featurescript subforum, it indicates I am not allowed to post questions there. Does that forum require additional privileges? Or am I just asking really silly questions...)
0
Best Answer
-
Alex_Kempen Member Posts: 248 EDUSure. The bug appears to occur only when a field value is overwritten by editing logic immediately after it is submitted. For example, if the user enters a value into definition.length, the bug occurs if the editing logic immediately attempts to set definition.length to something else. So so long as the trigger for updating definition.length is not the user changing definition.length (like if it triggers in response to definition.myBoolean or definition.otherLength or whatever), everything works as expected. Thus, since overwriting a parameter immediately after a user changes it is pretty dubious from both a UX and a general usefulness perspective, I don't think the bug you've found is very likely to actually rear its head under "real-world" conditions.
CS Student at UT DallasAlex.Kempen@utdallas.eduCheck out my FeatureScripts here:0
Answers
This behavior isn't critical - just nice to have a responsive UI.
As you stated, changing other numerical values does produce the expected behavior in the 'length' parameter. The exception appears to be if one opens the UI dialog and *first* changes the length parameter before making any other changes - in which case, the 'length' parameter remains unresponsive despite changes to other inputs until the UI dialog is closed and reopened. At least, that is the behavior I am observing in my minimal example linked above. Oh well. I guess I will just have to work around it for now.
In any case, I really do appreciate your time and effort, so thank you!
To extend this to a thought experiment in the standard library, imagine if the requirements for the name parameter of the variable feature (cannot start with a number, no spaces or other special characters) enforced themselves automatically by deleting any invalid characters as they were entered. Clearly, this would be a disaster for the user experience, as lots and lots of people would likely be confused when they attempt to enter a variable name like My variable and it immediately snaps to Myvariable. Instead, the current behavior of explicitly highlighting the name field and displaying an appropriate error message (Variable names start with a letter and can only contain letters, numbers, and _) makes it clear to the user that the input is incorrect and gives them a chance to fix it in a way that makes the most sense to them.