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.
Choosing parameters depending on length parameter
urszula_wachulska
Member Posts: 21 PRO
hello,
how can I read some previously defined parameters (dimensions) depending on other dimension typed by user?
I have tried something like this:
But in part studio I get FeatureScript notices that cannot compare boolean and ValueWithUnits, which I don't really understand, because both var "toCheck" and values to compare are ValuesWithUnits...
Could you please explain me what am I doing wrong and how to solve it?
how can I read some previously defined parameters (dimensions) depending on other dimension typed by user?
I have tried something like this:
<br>export function toCheckSth(toCheck)<br>{<br> <br> const mm = millimeter; <br> return {<br> <br> 0 *mm <= toCheck < 5* mm : { "a" : 16*mm, "b":20*mm,"l":10*mm},<br> 5*mm <= toCheck < 10*mm : { "a" : 20*mm, "b":22*mm, "l":20*mm},<br> 10*mm<= toCheck < 15*mm : { "a" : 22*mm, "b":25*mm, "l":30*mm},<br> <br> };<br>}<br><br><br>annotation { "Feature Type Name" : "My Feature" }<br>export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)<br> precondition<br> {<br> // Define the parameters of the feature type<br> annotation { "Name" : "My Length" }<br> isLength(definition.myLength, LENGTH_BOUNDS);<br> <br> }<br> {<br> var toCheck = definition.myLength;<br> var dim = toCheckSth(toCheck);<br> var myL = dim.l;<br> print(myL);<br> <br> <br> <br> });
Could you please explain me what am I doing wrong and how to solve it?
0
Comments
IR for AS/NZS 1100
https://forum.onshape.com/discussion/comment/44453/#Comment_44453
https://cad.onshape.com/documents/f6780441494046f4439a8219/w/71e7c5c95c521d8716fa75fa/e/631535138fdaba3ef7928ea2
I think that the other solutions in this thread are better than this one, but it is an option.
PhD, Mechanical Engineering, Stanford University