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.
Array Parameter ID's/Names
MichaelPascoe
Member Posts: 2,012 PRO
How do I update the group name in this array parameter for each added group?
https://cad.onshape.com/documents/8a8e419809a7dc3de36ff04d/w/0ed9e9d7984dea4c03a88617/e/3b07658a43284e036816907f
https://cad.onshape.com/documents/8a8e419809a7dc3de36ff04d/w/0ed9e9d7984dea4c03a88617/e/3b07658a43284e036816907f
annotation { "Feature Type Name" : "Boolean Groups", "Icon" : icon::BLOB_DATA } export const myFeature = defineFeature(function(context is Context, id is Id, definition is map) precondition { //Sources for precondition arrays: //Wood Grain by Tim Rice https://cad.onshape.com/documents/f5cd9f4b2ec8e9eea7266f1e/v/e15f879c66222ea59c108b8a/e/4626b80fb148952bd0b75c92 //Mahir https://forum.onshape.com/discussion/comment/68636#Comment_68636 annotation { "Name" : "Groups", "Item name" : "Group", "Item label template" : "Group" } definition.groups is array; for (var group in definition.groups) { annotation { "Name" : "Parts", "Filter" : EntityType.BODY, "UIHint" : UIHint.ALLOW_QUERY_ORDER } group.parts is Query; } } { for (var i = 0; i < size(definition.groups); i += 1) { try silent { opBoolean(context, id + i + "boolean1", { "tools" : definition.groups[i].parts,//group[i], "operationType" : BooleanOperationType.UNION }); } catch { } } });
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
Tagged:
0
Best Answer
-
Alex_Kempen Member Posts: 248 EDUIf you use #innerParameterName as your Item label template, (i.e. #parts), you can derive the template from an inner parameter in order to get behavior similar to the Loft Feature. This is described in the documentation here. It's also possible that things may number themselves automatically in the desired way if you simply remove the "Item Label Template" tag of the group annotation entirely.
Getting more control than that, however, is pretty difficult. One method is to use a hidden parameter as the item label template and then update the hidden parameter using Editing Logic - however, you will have to be careful to avoid this bug, although I don't think you're using those types of queries in your feature. If you do go this route, my custom function arrayItemChanges may also be of use to you.
As a final note, it may be tempting to try and use setFeatureComputedParameter to easily set group names, which is how the variable Feature gives itself custom names - however, that only works for the feature name itself, and not array parameters. Ugh.CS Student at UT DallasAlex.Kempen@utdallas.eduCheck out my FeatureScripts here:0
Answers
Getting more control than that, however, is pretty difficult. One method is to use a hidden parameter as the item label template and then update the hidden parameter using Editing Logic - however, you will have to be careful to avoid this bug, although I don't think you're using those types of queries in your feature. If you do go this route, my custom function arrayItemChanges may also be of use to you.
As a final note, it may be tempting to try and use setFeatureComputedParameter to easily set group names, which is how the variable Feature gives itself custom names - however, that only works for the feature name itself, and not array parameters. Ugh.
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴