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 can I create string variables?
daniel_bailey
Member Posts: 7 ✭
I have a featurescript feature that takes a string as a precondition.
Is it possible to define a variable that is a string that I can pass into this feature?
I've tried setting the value of a variable to be something quoted in double quotes and single quotes, neither of these is accepted.
Is it possible to define a variable that is a string that I can pass into this feature?
I've tried setting the value of a variable to be something quoted in double quotes and single quotes, neither of these is accepted.
Tagged:
0
Answers
-
as far as I know you can't set string value to a part studio variable, but you can pass to feature script the name of a variable as string
0 -
Hmm, okay then, I've added the feature request tag. This would be really useful for me.
3 -
There is work in progress to remove the type restrictions on variables, so our intent is that you will be able to use strings, arrays, maps, even functions (lambdas).Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc2
-
Now that is splendid news. Thankyouilya_baran said:There is work in progress to remove the type restrictions on variables, so our intent is that you will be able to use strings, arrays, maps, even functions (lambdas).
Owen S.
Business Systems and Configuration Controller
HWM-Water Ltd0 -
@ilya_baran Lambda functions in variables... this sounds fun!"A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools." - Douglas Adams, Mostly Harmless0
-
@leon_poot You can already put a lambda into a variable with a custom feature. What we plan to add is the ability to put it in a variable in a Part Studio directly.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0
-
niceilya_baran said:@leon_poot You can already put a lambda into a variable with a custom feature. What we plan to add is the ability to put it in a variable in a Part Studio directly.
will that mean we can have logical if statements (if..else..while) inside the variable's lambda function?
or is the lambda function limited?
I've rarely used lambda's in C#, so they are still kinda short hand (in-line) tricks to me...0 -
The lambda can contain arbitrary FeatureScript code (so yes, if-else, loops, variables). Though if you are going to be defining non-trivial lambdas, I would recommend putting them in a custom feature, like this: https://cad.onshape.com/documents/9307925f33961a9f1b10c559/w/8cd40e21db8c1060b315e72f/e/0801bef9707f10c6cf75635fIlya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0





