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.

Need help with feature naming template

darren_13darren_13 Member, Developers Posts: 119 PRO
Hi, I am struggling with the feature naming template and have already checked most posts currently on the forums but from what I can tell my example should work:

feature definition:
annotation { "Feature Type Name" : "Profile Generator", "Manipulator Change Function" : "flipManipulators", "Feature Name Template" : "Aerofoil = #name", "Editing Logic Function" : "old"}

in main body: 
setFeatureComputedParameter(context, id, {
                    "name" : "name",
                    "value" : 5
            });

this gives a feature name of: Aerofoil = ?

If this isn't enough I can post a link but its

I changed the value to numerical because I read somewhere that it doesn't like strings? and also from checking the variable feature script what is the difference between ### and # used for ###name and #value
Tagged:

Comments

  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    edited September 2017
    I noticed that changing feature name template doesn't affect the name of prevously added features, try
    "value": " "~5
    or even set a whole string to value
    "value": "Aerofoil "~5
    and
    "Feature Name Template" : "#name"
    and add a new feature


  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    @darren_13
    I would expect that code to work. Can you post an example of a failing document? @konstantin_shiriazdanov is right that templates are fixed at the time of feature creation, we do not retroactively change existing features' templates, so you will need to create a new feature to test.

    On the "###" question, Onshape allows escaping "#" as "##", so the template "###name" will display a "#" literal then the computed name.

  • darren_13darren_13 Member, Developers Posts: 119 PRO
    edited September 2017
    Hi @kevin_o_toole_1, here is the link:

    https://cad.onshape.com/documents/95877be3b17f49277e87a2c3/w/b503830fd20472014beb1221/e/6a7730b786a3030938febbe7

    under profile generator (new) and the main script. I moved it up to line 266.

    I was creating new features to test, so that shouldn't be the issue.

    @konstantin_shiriazdanovcheers ill try that now.
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    edited September 2017
    Hey Darren,

    I believe your issue is that something within the feature is failing, which causes the whole feature to be aborted, reverting any effect the feature had (including setFeatureComputedValue).

    Perhaps seeing a question mark only in the case the feature fails is fine for you. If not, the only computed values which are always set (even when the feature is aborted) are the parameters on the definition. So one option is to make an ALWAYS_HIDDEN parameter on the definition which is set via editing logic. Check out variable.fs for an example of this!

  • darren_13darren_13 Member, Developers Posts: 119 PRO
    edited September 2017
    Hi @kevin_o_toole_1, nothing is failing on it... I put a warning on it so myself and others know that they are test scripts. I have now removed it and nothing errors or warns. I did try that logic function method but got the same result. Can you open the new version and confirm that nothing fails and therefor the '?' should be populated? I'm using part studio 8 for testing.

    Thanks for your help,
    Darren
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    maybe it don't like when "name":"name", try "name":"nameTemplate"
  • darren_13darren_13 Member, Developers Posts: 119 PRO
    Cheers @konstantin_shiriazdanov, I changed it to 'name' to simplify the problem. In doing this when I fixed it (without realising). it didnt display because of the 'name' being identical to 'name', in short, your above reply fixed my issue so thanks very much!

    Kind regards,
    Darren
  • darren_13darren_13 Member, Developers Posts: 119 PRO

Sign In or Register to comment.