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.
setFeatureComputedParameter leaving quotes
DSPuzzles
Member Posts: 17 EDU
I am currently making a feature that requires using the setFeatureComputedParameter function to set a custom label. However, when I use it and I pass a custom string onto the function, it leaves quotes around the name in the feature tree.
For example, if I do setFeatureComputedParameter(context, id, { "name" : "label", "value" : "World" }), and my Feature Name template is "Hello #label", the feature tree shows up as "Hello World", quotes included, instead of just Hello World.
Interestingly enough, it does not happen if I set the # to #name and I pass the string stored in a definition.name parameter (ie: setFeatureComputedParameter(context, id, { "name" : "name", "value" : definition.name })). If I do that, everything works and there are no quotes for some reason, and I can't quite figure out why.
Any help is appreciated. Thanks.
For example, if I do setFeatureComputedParameter(context, id, { "name" : "label", "value" : "World" }), and my Feature Name template is "Hello #label", the feature tree shows up as "Hello World", quotes included, instead of just Hello World.
Interestingly enough, it does not happen if I set the # to #name and I pass the string stored in a definition.name parameter (ie: setFeatureComputedParameter(context, id, { "name" : "name", "value" : definition.name })). If I do that, everything works and there are no quotes for some reason, and I can't quite figure out why.
Any help is appreciated. Thanks.
Tagged:
0
Answers
https://forum.onshape.com/discussion/comment/30842#Comment_30842
How would you feel about the solution proposed there? What would be a helpful name for that type?
i.e. definition.label will set #label without any extra code.
#name is a special reserved case that will not add quotes (as used in variable.fs) - not sure why.
I think the need for differentiation between user-text and interface-text is there, but in the case of the custom feature defining a label, there is currently no way of making it not seem like user-text. What about using different symbols for a user-label (#label) that creates quotes and feature label (eg: $label) that does not?
@NeilCooke I was not aware of this. I will try a workaround where definition.name is defined via code (outside the precondition) and used to set the label.