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.
"Fixing" a query so it doesn't change
jack_gregory
Member Posts: 3 ✭
First post. I have a sketch point that I am using for a kind of fancy counterbore feature. Essentially, I take the point, and drill a hole there (normal to the planar face the point must be on). When I first get the face, I also get its owning solid so I can do the boolean later. But of course that solid is a query, not a thing, and later operations result in more solids being found that match the original faceContainsPoint. Then my boolean fails.
So I want to somehow "lock" that first query, which does get the one solid I want to be the target.
I know I can probably subtract the new solids I have created from the query. But that seems pretty painful when I have the culprit at the very beginning of the script.
Any hints appreciated. I am willing to work for it, but am on the steep part of the learning curve right now. Reading the std hole feature is mind-boggling-complex, even though I know it does almost exactly what I want.
0
Comments
If we make the assumption that the body is not going to be split or destroyed, you call this code before making modifications to get a more "solid" (pun intended) reference to the body you care about:
Here is the documentation for evaluateQuery:
https://cad.onshape.com/FsDoc/library.html#evaluateQuery-Context-Query
In essence, it returns an array of queries, each representing exactly one entity which the query resolves to. It represents each entity using a transient id, which may change if the body is altered in some major way (splitting is a good example).
A more robust query to represent that body may look as follows:
transientBodyQ will resolve to the body if its transient id HAS NOT changed. The tracking query will resolve to the body if its transient id HAS changed. So, unioning those queries together will ensure that you have a reference to that exact body whether or not its transient id changes.
You'll probably be fine with the first approach, and can incorporate the second approach if the first seems to lose the body along the way.
Hope this helps!
Jake
IR for AS/NZS 1100