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.

Options

For loop for annotation creation in FS

florianflorian Member, OS Professional Posts: 110 ✭✭✭
My plan: I just wanted to create quick new version of the "Part Number" property example FS.

When I looked at the code I was suprised by the extreme repetition in the code. I think it could be solved with a few small lists. But it seems that the limitation is annotation creation that does not accept for loops.

annotation { "Feature Type Name" : "Part Number" }
export const partNumber = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        ...ORIGINAL CODE...
            for (var i = 1; i <= 3; i += 1)
            {
            }
        }

The original: 
https://cad.onshape.com/documents/cb387c60a50e49e2a50a65da/w/38f957562c3238fb6debd3a3/e/c6024f1ff135baf098509c71
My start incl. error: https://cad.onshape.com/documents/6d98f6b9970b451ad1ea02d9/w/f2d80f916670b2e22b04c23d/e/19b6147f5e63fff7f36abbe5
Tagged:

Comments

  • Options
    kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    edited March 2018
    Our approach to handling varying parameter multiplicity in feature dialogs is array parameters. Documentation is here. They do use a for loop, just with slightly different syntax  :)

    I believe Ilya didn't use array parameters in that example because right now, they can't be configured (If you want this functionality, please request it!) 
  • Options
    mahirmahir Member, Developers Posts: 1,291 ✭✭✭✭✭
    Not sure it's exactly the same thing as configurable array parameters, but  you can vote for my improvement request for conditional visibility of inputs in array parameters. Making them configurable would fix that, too.

    https://forum.onshape.com/discussion/7628/conditional-visibility-of-array-parameters/
  • Options
    florianflorian Member, OS Professional Posts: 110 ✭✭✭
    Thanks for the help! That worked well.
    See the result: https://cad.onshape.com/documents/6d98f6b9970b451ad1ea02d9/w/f2d80f916670b2e22b04c23d/e/be217d6c0f6b483e0594d33a

    Offtopic: However I'm confused with the toString parsing. An isAnything with the value "diameter in mm" will be parsed as "diameter *inch *millimeter" => See entered values in V1 of the doc. Expected "diameter in mm"

    Offtopic 2: Any way to insert whitespace in a partname as separator? I tried setting tefault to " " but it does not work.
  • Options
    florianflorian Member, OS Professional Posts: 110 ✭✭✭
    I added two nasty workarounds to get what I want from my two offtopics above. Any ideas for a cleaner implementation are appreciated.
Sign In or Register to comment.