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.
Use an editing logic function with booleans?
Lee_Hesketh
Member, Developers Posts: 148 ✭✭✭
Can an editing logic function be used to tick a boolean check box in the UI? If so, how?
Thanks
Lee Hesketh
Thanks
Lee Hesketh
There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
Tagged:
0
Best Answers
-
NeilCooke Moderator, Onshape Employees Posts: 5,718Hi Lee, this simple example creates radio buttons.
FeatureScript 505; import(path : "onshape/std/geometry.fs", version : "505.0"); annotation { "Feature Type Name" : "My Feature", "Editing Logic Function" : "RadioButtons" } export const myFeature = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "My Boolean", "Default" : true } definition.myBoolean1 is boolean; annotation { "Name" : "My Boolean" } definition.myBoolean2 is boolean; } { // Define the function's action }); export function RadioButtons(context is Context, id is Id, oldDefinition is map, definition is map, isCreating is boolean) returns map { if (oldDefinition.myBoolean1 != definition.myBoolean1) // this means if the value has been changed by the user { definition.myBoolean2 = !definition.myBoolean1; } if (oldDefinition.myBoolean2 != definition.myBoolean2) { definition.myBoolean1 = !definition.myBoolean2; } return definition; }
Senior Director, Technical Services, EMEAI5 -
NeilCooke Moderator, Onshape Employees Posts: 5,718Lee_Hesketh said:Ah, okay. So what I want to achieve is I have a boolean that is defaulted to false. Then later on in the code, it is set to true if certain conditions are met. How would I set it to true in the UI?Senior Director, Technical Services, EMEAI5
-
NeilCooke Moderator, Onshape Employees Posts: 5,718Lee_Hesketh said:Also, what is the purpose of isCreating? When I add that to my code, an error comes up saying my editing logic function has unrecognised arguments.Senior Director, Technical Services, EMEAI5
Answers