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.
Querying parts created by boolean subtraction
graham_lock
Member Posts: 262 PRO
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
Maybe try to use qCreatedBy?
Ramon Yip | glassboard.com
Try using upperHalfQ = makeRobustQuery(context, upperHalfQ);
before boolean operation
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 operation
ok, another option to try is tracking - create a query before boolean op:
const upperHalfTracking = startTracking(context, upperHalfQ);
and check what it resolves to after boolean.
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!
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
Does this also work for opSplit? I've been relying on spatial checks between my split tools and the inputs to disambiguate the results.
Derek Van Allen | Engineering Consultant | Meddlerthe 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