Querying parts created by boolean subtraction
Hi all,
I have a trapezoidal web (upperHalfQ) which I'm cutting into sections using ribs (ribsQ) passed to opBoolean:
opBoolean(context, webId + "_upperMinusRibs",
{
"targets" : upperHalfQ,
"tools" : ribsQ,
"operationType" : BooleanOperationType.SUBTRACTION,
"keepTools" : true
});
After the boolean operation upperHalfQ resolves to nothing which is fine.
How do I get the bodies of the new web sections created by the rib cuts?
I've tried
var beforeQ = qAllSolidBodies(); // resolves to 27 bodies
opBoolean…
var afterQ = qAllSolidBodies(); // resolves to 40 bodies
var newWebBodiesQ = qSubtraction(afterQ, beforeQ);
but newWebBodiesQ resolves to nothing
Thank you.
Comments
-
-
Thanks guys.
qCreatedBy(webId + "_upperMinusRibs", EntityType.BODY); resolves to nothing.
makeRobustQuery(context, upperHalfQ) initially resolves to the unsegmented web but then resolves to nothing after the boolean operation0 -
Thanks @Konst_Sh that did it,
After the boolean operation upperHalfTracking resolves to all of the parts derived from upperHalfQ.
I wasn't aware of that function but it's certainly useful!
1 -
yeah, tracking queries through boolean is tricky, you might want to create a helper function which I call
mixinTracking(context, query){ return qUnion(query, startTracking(context, query));}
in lots of cases related to splitting and boolean especially if the query combines both affected and unaffected entities it will resolve to all entities passed to operation and their children
CADSharp - Onshape custom programming services + Onshape mechanical design services
0 -
Does this also work for opSplit? I've been relying on spatial checks between my split tools and the inputs to disambiguate the results.
0 -
the mixinTracking is right for this type of situations - when you can't be sure which entities were changed by operation and their original queries are irrelevant but tracking queries will resolve to resulting entities, or when original entities are unaffected, then tracking query will result to nothing, but the union of these 2 queries will always be relevant for both affected and unaffected entities
CADSharp - Onshape custom programming services + Onshape mechanical design services
0 -
Just squashed a bug with this that was bothering me for too long.
1

