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.
Query for entities to boolean
ben_partouch
Member, csevp Posts: 158 PRO
Hi,
I'm trying to boolean subtract bodies created with oppattern inside a for loop. Not sure what I should do...
Thank you!
doc:
https://cad.onshape.com/documents/ef3ba98102efc6b4e4c71194/w/50cf1b58a05a4b7c535589fd/e/8c530af3038d5e69dbf7c755
I'm trying to boolean subtract bodies created with oppattern inside a for loop. Not sure what I should do...
Thank you!
doc:
https://cad.onshape.com/documents/ef3ba98102efc6b4e4c71194/w/50cf1b58a05a4b7c535589fd/e/8c530af3038d5e69dbf7c755
for (var i = -1; i < definition.numberOfHoles - 1; i += 1)
{
const computedTransforms1 = transform((vector(0 * centimeter, 0 * centimeter, definition.holeSpacing)) * (i + 1));
opPattern(context, id + ("patternB" ~ i), {
"entities" : qCreatedBy(id + "extrude1", EntityType.FACE),
"transforms" : [computedTransforms1],
"instanceNames" : ["Holes"]
});
// opBoolean(context, id + "boolean2", {
// "tools" : qCreatedBy(id + ("patternB" ~ i), EntityType.BODY),
// "targets" : definition.panels,
// "operationType" : BooleanOperationType.SUBTRACTION
// });
}
Tagged:
0
Comments
opPattern(context, id + ("patternB" ~ i), {
Looks like it can stay FACE but my id was wrong. Now- opBoolean(context, id + ("boolean2" ~ i).
Seems to work:)
I would love to take you advice but my capabilities in FS are so amature and limited that I have no idea how to do what you suggested LOL.
My code is so inefficient. Would love to learn how to get better at this!
//for loop for drilled holes var computedTransforms1 = []; // make an empty array to later store transforms var instanceNames = []; // make an empty array to later store instance names<br> for (var i = -1; i < definition.numberOfHoles - 1; i += 1) { const computedTransform = transform((vector(0 * centimeter, 0 * centimeter, definition.holeSpacing)) * (i + 1)); computedTransforms1 = append(computedTransforms1, computedTransform); // add the new transform to the array instanceNames = append(instanceNames, "hole"~toString(i)); // add the new instance name to the array<br> } // no more need to add + i to the Id's here since you only call the functions once. opPattern(context, id + "patternB", { "entities" : qCreatedBy(id + "extrude1", EntityType.FACE), "transforms" : computedTransforms1, "instanceNames" : ["Holes"] }); opBoolean(context, id + "boolean2", { "tools" : qCreatedBy(id + "patternB", EntityType.BODY), "targets" : definition.panels, "operationType" : BooleanOperationType.SUBTRACTION });The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com
Thanks for looking into it:)
@opPattern: INVALID_INPUT
opPattern(context, id + "patternB", { "entities" : qCreatedBy(id + "extrude1", EntityType.BODY), "transforms" : computedTransforms1, "instanceNames" : instanceNames });The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com