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.
Appending or combining to qUnions
sean_connor714
Member Posts: 6 ✭
Is there a way to combine or append to a qUnion? In the code below, if "firstRow" is false, I'd like to add an additional subtract target to the boolean operation at the bottom. I've tried doing a qUnion of a qUnion and a qCreatedBy, but that doesn't seem to work either.
var subtractTargets = qUnion([
qCreatedBy(id + i + "trussPoint", EntityType.BODY),
qCreatedBy(id + i + "slotForward", EntityType.BODY)
]);
if (firstRow == false)
{
var previousPlane = plane(trussPoint * meter, -previousPlaneComponents.normal);
opExtrude(context, id + i + "slotBack", {
"entities" : definition.slot,
"direction" : evOwnerSketchPlane(context, {"entity" : definition.slot}).normal,
"endBound" : BoundingType.BLIND,
"endDepth" : definition.bodyRadius
});
opTransform(context, id + i + "transformSlotBack", {
"bodies" : qUnion([
qCreatedBy(id + i + "slotBack", EntityType.BODY),
]),
"transform" : transform(evOwnerSketchPlane(context, {"entity" : definition.slot}), previousPlane)
});
subtractTargets = qUnion([subtractTargets, qCreatedBy(id + i + "slotBack", EntityType.BODY)]);
}
println(subtractTargets);
opBoolean(context, id + i + "subtract", {
"tools" : qCreatedBy(id + i + "slotInterior", EntityType.BODY),
"targets" : subtractTargets,
"keepTools" : true,
"operationType" : BooleanOperationType.SUBTRACTION
});Thanks,0
Answers
var subtractTargets = [ qCreatedBy(id + i + "trussPoint", EntityType.BODY), qCreatedBy(id + i + "slotForward", EntityType.BODY) ]; subtractTargets = append(subtractTargets, qCreatedBy(id + i + "slotBack", EntityType.BODY)); "targets" : qUnion(subtractTargets);(Protip: qUnion has overloads for 2, 3, and 4 queries, so you don't need to enclose them in an array in those cases.)