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 properly use: setFeatureComputedParameter()
john_mcclary
Member, Developers Posts: 4,035 PRO
What am I missing?
This is all the info I see in the documentation
I've tried many times, but I cannot get the feature name to stick like I've seen in measureValue.fs and variable.fs


This is all the info I see in the documentation
I've tried many times, but I cannot get the feature name to stick like I've seen in measureValue.fs and variable.fs


0
Best Answers
-
MBartlett21
Member, OS Professional, Developers Posts: 2,064 ✭✭✭✭✭
@john_mcclary
The parameter name has to be in the precondition for setFeatureComputedParameter to work.
PS: You don't have to use setFeatureComputedParameter to use # syntax in the feature name. You can just directly use #Name.5 -
kevin_o_toole_1
Onshape Employees, Developers, HDM Posts: 565
FYI, in order to use #someValue in templates, you need either definition.someValue to be a parameter or setFeatureComputedParameter("someValue", ...). No need for both, but setFeatureComputedParameter is still useful for computed values that aren't inputs.
And yes, an individual feature's name and template are assigned when the feature is created, so if you're debugging this stuff and changing the feature name or template, you need to delete and recreate the feature in order to see the new name or template take effect.
2
Answers
The parameter name has to be in the precondition for setFeatureComputedParameter to work.
PS: You don't have to use setFeatureComputedParameter to use # syntax in the feature name. You can just directly use #Name.
IR for AS/NZS 1100
I was running in circles expecting the feature tree to update just by editing the feature.
Good to know you don't need setFeatureComputedParameter
And yes, an individual feature's name and template are assigned when the feature is created, so if you're debugging this stuff and changing the feature name or template, you need to delete and recreate the feature in order to see the new name or template take effect.
How does the Hole feature change its feature name when you change parameters?
I created a 3/8" THRU hole and the feature name appears as follows:
After editing the hole feature to a 1/2" Blind, the feature name updates. I did not have to delete and create the feature again to get the updated feature name.
How is this accomplished? I am using FeatureScript 2144. Are there some simple examples available that demonstrate the behavior?
Thank you for your time and attention. I look forward to your replies.
Regards,
Jerry
My issue before was probably misunderstood by all of us.
I had created a blank feature script, started adding some IU stuff, then put it in the feature tree. Continued to edit… etc. later tried to add the renaming feature, but it wasn't working until I deleted and re-made it in the feature tree.
What may have fixed it could have just been to rename the feature to an empty string. (rename, hit delete, then enter). This method worked when they added this functionality to the hole feature.
I think the reason is, you can always override the feature name by renaming it. Which breaks the auto-renaming. But you rename to blank and auto naming comes back
Interesting info.
I was able to access the Hole featurescript source code and apply its naming method to get my feature naming working.
I must of course delete existing features since they will not regenerate to leverage the automatic naming convention in my code.
Regards,
Jerry
As reported above, I have been able to get the feature name to change based on the feature parameters.
However, how do I allow a user to input a custom feature name?
The Hole Feature allows a custom name while editing the feature or rename the feature in the browser:
Is it possible to update a feature name based on feature parameters, but still permit a custom feature name?
The goal is to replicate the Hole feature's naming behavior in my custom FeatureScript.
Thank you again for your time and attention. I look forward to the replies.
Regards,
Jerry
I did some experiments with this myself and determined that the hole feature and routing curve features are hard coded exceptions to allow user renaming of applied features. If you copy and paste the hole code exactly but rename the feature declaration in featurescript the ability to override the name disappears, and vice versa if you have any other custom feature that you want to enable this ability on renaming the declaration to hole makes it work.
It's a thing that would need fixed by the developers to allow us to turn on or off.
Derek Van Allen | Engineering Consultant | MeddlerAckn. Thank you for the info and quick reply, Derek.
Hopefully a future version of Onshape will support this request.
Regards,
Jerry