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.
Can't seems to query BodyType.POINT and BodyType.MATE_CONNECTOR separately
konstantin_shiriazdanov
✭✭✭✭✭
I made a test feature that tries to separate point bodies and mate connector bodies from a query that contains both, but looks like qBodyType doesn't filters points and MC's, and debug shows both body types simultaneously.
https://cad.onshape.com/documents/86e57adcf32da1e02e501076/w/b4948803110e67bebb9cd951/e/cc3cd72cb2890c2387d19d08
Test feature code:

https://cad.onshape.com/documents/86e57adcf32da1e02e501076/w/b4948803110e67bebb9cd951/e/cc3cd72cb2890c2387d19d08
Test feature code:
FeatureScript 675;<br>import(path : "onshape/std/geometry.fs", version : "675.0");<br><br>annotation { "Feature Type Name" : "Point query test" }<br>export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)<br> precondition<br> {<br> annotation { "Name" : "Query", "Filter" : EntityType.VERTEX || BodyType.MATE_CONNECTOR }<br> definition.q is Query;<br><br> annotation { "Name" : "Show points" }<br> definition.showP is boolean;<br><br> annotation { "Name" : "Show MC's" }<br> definition.showMC is boolean;<br> }<br> {<br> if (definition.showP)<br> {<br> debug(context, qBodyType(qEntityFilter(definition.q, EntityType.VERTEX), BodyType.POINT));<br> }<br><br> if (definition.showMC)<br> {<br> debug(context, qBodyType(qEntityFilter(definition.q, EntityType.VERTEX), BodyType.MATE_CONNECTOR));<br> }<br><br> });
0
Comments
-
Hi @konstantin_shiriazdanov ,
I looked into this for you and it appears to be a bug in our system. I've logged it for you, thanks for pointing this out.
EDIT:
As reflected in the FeatureScript documentation, the MATE_CONNECTOR body type is only for filtering UI selections (as you've done in the precondition of your feature):
https://cad.onshape.com/FsDoc/library.html#BodyType
https://cad.onshape.com/FsDoc/uispec.html
If you would like to differentiate between mate connectors and other bodies you could use the following code:for (var q in evaluateQuery(context, definition.q)) { var isMateConnector = try silent(evMateConnector(context, { "mateConnector" : q })) != undefined; println(isMateConnector); }Although it does seem like there should be an easier way to do this. Maybe raise an improvement request to get BodyType.MATE_CONNECTOR implemented for qBodyType(...).
Jake Rosenfeld - Modeling Team1 -
-
thanks @Jake_Rosenfeld , i'm afraid that not so much users pay attention to featurescript IR, so i don't see the point.
In my case this behaviour of qBodyType means that my Curve generator feature relies only on the sort order of point and MC bodies inside the query ( possibly qBodyType affects on it). However, it somehow works
.
https://cad.onshape.com/documents/d8aab1e0e7ae10038a6830e0/w/9dfdd631d025960813b8f2df/e/ba4054f79173536a994fd0da
0 -
Hey again,
Maybe this can help with preserving ordering for you?var queriesInDesiredOrder = evaluateQuery(context, qIntersection([superSetOfQueriesInDesiredOrder, queriesPossiblyOutOfOrder]));
So if you have a query that's in the order you like (say, the original ordering from the definition, or some geometric sort constructed with `qUnion(arrayOfSortedPointBodies)`), you can intersect that sorted query with an unsorted query and an evaluation of the intersection will preserve the order of the first query in its input array.Jake Rosenfeld - Modeling Team0 -
@Jake_Rosenfeld
thanks, i now trying to query mate connector created by feature pattern explicitly by its id.
I can get the id of original MC obtained as FeatureList with keys(), for example the id of feature pattern is (id+"applyPattern"), and it creates one instance of MC with instance name "patternedMC", but when i try to query that patterned mc by
qCreatedBy(keys(definition.mc)[0] + (id + "applyPattern") + "patternedMC") i see that query resolves to nothing. So is there any way to query patterned entity based on it of original id, feature pattern id and instance name?
0 -
@konstantin_shiriazdanov
As long as your feature pattern is regenerating correctly, try:qCreatedBy((id + "applyPattern") + "patternedMC")
or justqCreatedBy(id + "applyPattern")
if you want everything (all the MCs) created by the pattern.
You shouldn't need the original id at all.Jake Rosenfeld - Modeling Team1

