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.
how to make a variable feature with multiple variables
rooiejoris
OS Professional Posts: 16 PRO
Hi,
I would like to have a feature script like the Variable, but then with multiple Variables for the input.
The reason is that when you have a very complex document and the Variables in the beginning I takes quite some time to regenerate the drawing after submitting the values. You have to wait for that before adjusting a new variable.
My solution was to make a feature where you can change multiple variables at once.
Another reason is that you can quickly change a bunch of variables at once by suppressing or changing the order of the MultiVariable feature.
Since I am not a programmer but a product designer I get a bit stuck. I tried to copy/paste and adjust some code, but not succesfull.
Below the changes I made in a copy of the Variable Feature.
Anybody any ideas/solution
cheers / joris
I would like to have a feature script like the Variable, but then with multiple Variables for the input.
The reason is that when you have a very complex document and the Variables in the beginning I takes quite some time to regenerate the drawing after submitting the values. You have to wait for that before adjusting a new variable.
My solution was to make a feature where you can change multiple variables at once.
Another reason is that you can quickly change a bunch of variables at once by suppressing or changing the order of the MultiVariable feature.
Since I am not a programmer but a product designer I get a bit stuck. I tried to copy/paste and adjust some code, but not succesfull.
Below the changes I made in a copy of the Variable Feature.
Anybody any ideas/solution
cheers / joris
precondition
{
annotation { "Name" : "Name" }
definition.name is string;
annotation { "Name" : "Value" }
isAnything(definition.value);
annotation { "Name" : "Name2" }
definition.name2 is string;
annotation { "Name" : "Value2" }
isAnything(definition.value2);
}
{
verifyVariableName(definition.name);
setVariable(context, definition.name, definition.value);
verifyVariableName(definition.name2);
setVariable(context, definition.name2, definition.value2);
0
Best Answers
-
ilya_baran Onshape Employees, Developers, HDM Posts: 1,215At the same time, I see no problems with your code at all -- here's a public document I made with it working: https://cad.onshape.com/documents/5f5777809672e49d503f5e8e/v/5b94daf8670296d0b6b20c91/e/30a2b09bfe50448f31a7eab5Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc1
-
ilya_baran Onshape Employees, Developers, HDM Posts: 1,215Not sure what was causing the trouble before. In any case, I only copied the code that was necessary.
BTW, please keep in mind that 12 and 12in are two different values -- one is a number and one is a length. So if #x is 12, you can use #x deg as the angle of a revolve (and typing #x there will automatically add the deg), but if #x is 12in, that will not happen.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc5
Answers
We have been looking at ways to make this process faster.
That's how i do this now indeed, but it is still very nice if this is not necessary... : )
also with more than 12 variables, it has a better overview in grouping them in a feature script, maybe even with captions in between
@ilya_baran
Thanks...!! seems to work indeed, but.... : )
it doesn't work when the second variable doesn't have a unit behind. only works with 12 in [and not with just '12']
btw, my original code was way longer, I also copied everything in front and after, with copying your code in my file it works. Even without the mm suffix in var 2...[?!!]
thanks...!!
cheers / joris
BTW, please keep in mind that 12 and 12in are two different values -- one is a number and one is a length. So if #x is 12, you can use #x deg as the angle of a revolve (and typing #x there will automatically add the deg), but if #x is 12in, that will not happen.