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 disconnected components created by opBoolean
lemon1324
Member, Developers Posts: 225 EDU
Occasionally, doing a laser joint where three plates meet at a corner at non-right angles creates disconnected components like this (originally part of the light blue plate):
This bit is created when a boolean ends up also splitting a part. I can't figure out how to query for this. qCreatedBy doesn't work, since the body isn't "created" by the boolean, only the edges, which are then difficult to categorize. I don't think qSplitBy would work as it's not an opSplit. qEverything would only work if I assumed the only objects in the part studio were part of the joint, which is a terrible assumption (aside: what's a proper use of qEverything? It seems like all it does is create unnecessary possible dependencies where a more specific query could be constructed).
Assuming the disconnected bit is part of "definition.A" (a Query pointing to the light blue body), I noticed that qOwnerBody(qOwnedBy(definition.A)) returned two bodies in my MWE test document, but didn't work buried deeper inside my Laser Joint feature, where it only returned one body. This query was placed immediately after the boolean in both cases. The only difference I could tell was that in the working MWE, "definition" is actually the one built in the precondition, and in the non-working Laser Joint version was, effectively, "localDefinition.A" after assigning localDefinition.A = qNthElement(definition.parts, i) and passing localDefinition a few function calls deep. Does qNthElement not necessarily return the same body if intervening non-body-creating operations happen?
The eventual goal is to detect the creation of disconnected components and warn the user or automatically delete small-enough bits and message the user.
This bit is created when a boolean ends up also splitting a part. I can't figure out how to query for this. qCreatedBy doesn't work, since the body isn't "created" by the boolean, only the edges, which are then difficult to categorize. I don't think qSplitBy would work as it's not an opSplit. qEverything would only work if I assumed the only objects in the part studio were part of the joint, which is a terrible assumption (aside: what's a proper use of qEverything? It seems like all it does is create unnecessary possible dependencies where a more specific query could be constructed).
Assuming the disconnected bit is part of "definition.A" (a Query pointing to the light blue body), I noticed that qOwnerBody(qOwnedBy(definition.A)) returned two bodies in my MWE test document, but didn't work buried deeper inside my Laser Joint feature, where it only returned one body. This query was placed immediately after the boolean in both cases. The only difference I could tell was that in the working MWE, "definition" is actually the one built in the precondition, and in the non-working Laser Joint version was, effectively, "localDefinition.A" after assigning localDefinition.A = qNthElement(definition.parts, i) and passing localDefinition a few function calls deep. Does qNthElement not necessarily return the same body if intervening non-body-creating operations happen?
The eventual goal is to detect the creation of disconnected components and warn the user or automatically delete small-enough bits and message the user.
Arul Suresh
PhD, Mechanical Engineering, Stanford University
PhD, Mechanical Engineering, Stanford University
0
Best Answers
-
konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭maybe obtain the edges by qCreatedBy(..., EntityType.EDGE), then obtain the bodies by qOwnerBody(), then possibly filter solids by qBodyType() and then qSubstraction(newSolidsQuery, initialSolidsQuery). By the way we definitely need some universal syntax to combine multiple query functions into one conveyor when output of prevous query function would be processed consistently without need for multiple and messy nesting.
5 -
ilya_baran Onshape Employees, Developers, HDM Posts: 1,211Yeah, as far as I understand (Lana is the boolean expert) a boolean doesn't "create" bodies, it splits existing ones. So the original query you passed into the boolean should find all of the split bodies (which I think you discovered when trying qSubtraction). For your case, I think qLargest on the original body query should work.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc5
Answers
I ended up using qCreatedBy to find edges, finding the owner bodies, and then sorting by size to find which parts are unlikely to be relevant.
PhD, Mechanical Engineering, Stanford University