Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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_lockgraham_lock Member Posts: 262 PRO
edited December 13 in FeatureScript

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

  • ry_gbry_gb Member, csevp, pcbaevp Posts: 93 PRO
    edited December 13

    Maybe try to use qCreatedBy?

    Ramon Yip | glassboard.com

  • Konst_ShKonst_Sh Member Posts: 105 PRO

    Try using upperHalfQ = makeRobustQuery(context, upperHalfQ);

    before boolean operation

  • graham_lockgraham_lock Member Posts: 262 PRO

    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

  • Konst_ShKonst_Sh Member Posts: 105 PRO

    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.

  • graham_lockgraham_lock Member Posts: 262 PRO

    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!

  • Konst_ShKonst_Sh Member Posts: 105 PRO

    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

  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 412 PRO

    Does this also work for opSplit? I've been relying on spatial checks between my split tools and the inputs to disambiguate the results.

  • Konst_ShKonst_Sh Member Posts: 105 PRO

    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

Sign In or Register to comment.