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.

Can't seems to query BodyType.POINT and BodyType.MATE_CONNECTOR separately

konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 901 ✭✭✭✭✭
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.
Test feature code:
FeatureScript 675;
import(path : "onshape/std/geometry.fs", version : "675.0");

annotation { "Feature Type Name" : "Point query test" }
export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
annotation { "Name" : "Query", "Filter" : EntityType.VERTEX || BodyType.MATE_CONNECTOR }
definition.q is Query;

annotation { "Name" : "Show points" }
definition.showP is boolean;

annotation { "Name" : "Show MC's" }
definition.showMC is boolean;
if (definition.showP)
debug(context, qBodyType(qEntityFilter(definition.q, EntityType.VERTEX), BodyType.POINT));

if (definition.showMC)
debug(context, qBodyType(qEntityFilter(definition.q, EntityType.VERTEX), BodyType.MATE_CONNECTOR));



  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,295
    edited September 2017
    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.
    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):

    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;
    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 Team
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,295
    Jake Rosenfeld - Modeling Team
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 901 ✭✭✭✭✭
    edited September 2017
    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 :D.

  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,295
    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 Team
  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 901 ✭✭✭✭✭
    edited September 2017
    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?

  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,295
    As long as your feature pattern is regenerating correctly, try:
    qCreatedBy((id + "applyPattern") + "patternedMC")
    or just
    qCreatedBy(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 Team
Sign In or Register to comment.