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.
Insight into queries?
traveler_hauptman
Member, OS Professional, Mentor, Developers Posts: 419 PRO
I feel like I'm not getting the query system. I get the basics. But then I see something like this:
export function evLength(context is Context, arg is map) returns ValueWithUnits
<snip>
var edges = qEntityFilter(arg.entities, EntityType.EDGE);
var ownedEdges = qOwnedByBody(arg.entities, EntityType.EDGE);
return @evLength(context, { "edges" : qUnion([edges, ownedEdges]) }) * meter;
and I get confused.
Why did qEntityFilter not capture the edges owned by entities, making the qUnion necessary?
Does qEntityFilter only work on things that are not owned?
0
Comments
-
In this case, arg.entities queries for a mixture of edges and bodies. qEntityFilter just extracts the edges that are directly queried for. qOwnedByBody just looks at the bodies -- and then gets their owned edges. Another way to thing about it is that the result of a qEntityFilter query is always a subset of the subquery passed in -- that's what it means to filter -- so it would be weird if you pass in one body into qEntityFilter and out comes a whole bunch of edges.
I'm not sure if that makes it more or less clear...Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0 -
That clears it up. It did not occur to me that bodies would be the query passed to qOwnedByBody. I thought it was taking a list of edges and returning edges that were owned by a body.
0 -
Ah, ok. Actually, *every* edge (and face and vertex) is owned by some body. You can get that body using qOwnerBody.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0

