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.
Loops in Precondition
Lauren_Froschauer
Member Posts: 10 EDU
Emily and I are trying to implement a variable amount of inputs in the precondition.
We are trying to generate N amount of input boxes in the feature dialog that is based on the number N entered by the user in another dialog box.
We have tried a for loop, and discovered that this is not possible. We get the error " nonconforming precondition: unexpected statement type (loop).
Is there a way to have N boxes generated? Or a way for a user to input an array of values into one dialog box?
We are trying to generate N amount of input boxes in the feature dialog that is based on the number N entered by the user in another dialog box.
We have tried a for loop, and discovered that this is not possible. We get the error " nonconforming precondition: unexpected statement type (loop).
Is there a way to have N boxes generated? Or a way for a user to input an array of values into one dialog box?
0
Comments
-
Yeah, pretty sure you can't do that-- preconditions have to be predicates-- no loops are allowed.
If you are writing a feature, you could try using the 'editing logic function', though, in which you can do arbitrary logic. You do that like this:
annotation { "Feature Type Name" : "Your Feature" , "Editing Logic Function" : "yourEditLogicFunction" }Your function needs to be declared like this:
export function yourEditLogicFunction(context is Context, id is Id, oldDefinition is map, definition is map,
isCreating is boolean, specifiedParameters is map, hiddenBodies is Query) returns map { ... }It will be called whenever your feature inputs are edited, and there you can pretty much do whatever.
I used this approach as a work-around when I was needing to dynamically manipulate the inputs.
HTH
0 -
As far as the FeatureScript language is concerned preconditions can have loops, but preconditions with loops will not be recognized as feature specifications.0
-
I'm also curious about this. What's the best way to allow the user to input N lengths, for example?0
-
There currently is no good way to do this. You can't even condition visibility based on something other than an enum or a boolean. You can imagine hacking hidden booleans set with editing logic, but that will not be a great user experience since round trips to the server will be required. We intend to improve on this in the future.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0
-
I'm also interested this, I need to define like 4 identical parameters 'n' number of times. Might use the above-described method by @dave_cowden. David could I somehow have an enum from say 1-5 and edit the properties for each enum individually? so I change the parameters for '1' then move onto setting up the parameters for '2'?
Thanks in advance,
Darren1


