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.
For loop for annotation creation in FS
florian
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.
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
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:
0
Comments
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!)
https://forum.onshape.com/discussion/7628/conditional-visibility-of-array-parameters/
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.