Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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_mcclaryjohn_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




Best Answers

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565 image
    Answer ✓
    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.

Answers

  • john_mcclaryjohn_mcclary Member, Developers Posts: 4,035 PRO
    Ok, so you also need to delete the feature and re-create it.
    I was running in circles expecting the feature tree to update just by editing the feature.

    Good to know you don't need setFeatureComputedParameter
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565 image
    Answer ✓
    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.
  • jerry_berns465jerry_berns465 Member Posts: 10 EDU

    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:

    image.png

    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.

    image.png

    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

  • john_mcclaryjohn_mcclary Member, Developers Posts: 4,035 PRO

    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

  • jerry_berns465jerry_berns465 Member Posts: 10 EDU

    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

  • jerry_berns465jerry_berns465 Member Posts: 10 EDU

    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:

    image.png image.png

    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

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 658 PRO

    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.

  • jerry_berns465jerry_berns465 Member Posts: 10 EDU

    Ackn. Thank you for the info and quick reply, Derek.

    Hopefully a future version of Onshape will support this request.

    Regards,

    Jerry

Sign In or Register to comment.