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.
Editing Logic: Equal Lengths
I've set definition.myLength2 to equal definition.myLength1 with editing logic like this:
export function editTest(context is Context, id is Id, oldDefinition is map, definition is map, isCreating is boolean) returns map { definition.myLength2 = definition.myLength1; return definition; }It works until I manually set myLength2 to something else, then it stops changing. If I manually make it equal myLength1 again it will keep up with it and match. Can someone explain why?
Evan Reese
0
Best Answers
-
mahir Member, Developers Posts: 1,307 ✭✭✭✭✭If you want them to always match, you can start by comparing values of definition vs oldDefinition. Depending on which input was edited, you could then update the other one to match.0
-
MBartlett21 Member, OS Professional, Developers Posts: 2,050 ✭✭✭✭✭@Evan_Reese
You could try using a copyParameter (std | manipulator.fs), which is supposed to copy the value, including configurations and everything, like what happens in the variable feature (std | variable.fs). The variable feature copies the value to another parameter so that its formatting of the value in the feature title is correct.
The copyParameter function is marked @internal, so there is no docs in the FS library.
If the parameters need to depend on each other in a more complex way, you should probably add UIHint.UNCONFIGURABLE to the parameters to stop the user configuring them, like what happens (annoyingly) in Onshape's hole feature.1
Answers
You could try using a copyParameter (std | manipulator.fs), which is supposed to copy the value, including configurations and everything, like what happens in the variable feature (std | variable.fs). The variable feature copies the value to another parameter so that its formatting of the value in the feature title is correct.
The copyParameter function is marked @internal, so there is no docs in the FS library.
If the parameters need to depend on each other in a more complex way, you should probably add UIHint.UNCONFIGURABLE to the parameters to stop the user configuring them, like what happens (annoyingly) in Onshape's hole feature.
IR for AS/NZS 1100