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.
condition in the if statement is failing
Mohamed_Alieddin
Member Posts: 5 PRO
I am using the following script to create a three-stepped cylinder, I want the diameter for step 1 and 2 to depend on the selected value of dia3 from the lookup table/sizeTable. The condition in the if statement is failing though! can someone provide some guidance?
FeatureScript 2144;
FeatureScript 2144;
import(path : "onshape/std/common.fs", version : "2144.0");
export const sizeTable = {
"name" : "dia3",
"displayName" : "Dia3",
"default" : "25",
"entries" : {
"25" : {
"name" : "StockHeight",
"displayName" : "StockHeight",
"default" : "140",
"entries" : {
"60" : 60 * millimeter,
"100" : 100 * millimeter,
"127" : 127 * millimeter,
"140" : 140 * millimeter
}
},
"20" : {
"name" : "StockHeight",
"displayName" : "StockHeight",
"default" : "125",
"entries" : {
"60" : 60 * millimeter,
"84" : 84 * millimeter,
"104" : 104 * millimeter,
"125" : 125 * millimeter
}
}
}
};
annotation { "Feature Type Name" : "Tool4" }
export const tool4 = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "Tool height", "Lookup Table" : sizeTable }
definition.sizeTable is LookupTablePath;
if (definition.sizeTable.dia3=="25")
{
annotation { "Name" : "Dia1" }
isLength(definition.dia1, { (millimeter) : [1, 14, 14] } as LengthBoundSpec);
annotation { "Name" : "Dia2" }
isLength(definition.dia2, { (millimeter) : [14, 16, 19] } as LengthBoundSpec);
}
annotation { "Name" : "height1" }
isLength(definition.height1, { (millimeter) : [1, 20, 100] } as LengthBoundSpec);
annotation { "Name" : "height2" }
isLength(definition.height2, { (millimeter) : [1, 20, 100] } as LengthBoundSpec);
}
0
Comments
You will need editing logic for this to work.
You can only over ride a users input in edit logic so if someone types in a value too big or small, you just modify it to the min value if too small or the max value if too big. Just set it in the edit logic function that I provided above