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.

The areQueriesEquivalent method does not work when compared to evaluateQuery?

charles_randolphcharles_randolph Member Posts: 12

I'm developing a simplistic feature that takes two inputs:

  1. A face
  2. An edge

My only constraint is that the edge belong to the face. In other words, if I query the face for all edges, I expect that the edge selected will also be in the set. To accomplish that, I've written a simple FeatureScript function called faceContainsEdge

function faceContainsEdge(context is Context, faceQuery is Query, edgeQuery is Query) returns boolean
precondition
{
    !isQueryEmpty(context, qEntityFilter(edge, EntityType.EDGE));
    !isQueryEmpty(context, qEntityFilter(face, EntityType.FACE));
}
{
    // Extract my edges
    const faceEdgesQuery is Query = qAdjacent(faceQuery, AdjacencyType.EDGE);
    
    // Verify whether the given edge query evaluates to one of the edges of the face
    for (var faceEdgeQuery in evaluateQuery(context, faceEdgesQuery))
    {
        if (areQueriesEquivalent(context, faceEdgeQuery, edgeQuery))
        {
            return true;
        }
    }
    return false;
}

The problem (obviously) is that this doesn't work. I can see via the addition of debug lines that both the edgeQuery and faceEdgesQuery evaluate correctly:

SCR-20260711-oqug.png

If I try to print the two queries, I see the following:

  1. Each faceEdgeQuery in the loop is a map with structure: Query 1: { queryType : TRANSIENT , transientId : JIV }
  2. The invariant edgeQuery is a map with structure: Query 2: { queryType : UNION , subqueries : [ { flatFilter : NO , queryType : SM_FLAT_FILTER … ]

And the function returns false always. How is this areQueriesEquivalent supposed to function? Do I need to convert the results of evaluateQuery in some way? How can I make the comparison meaningful?

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 6,069 image

    Correct - a Query (the "search" term) and an evaluated Query (the result) are not the same thing, If you find the edges of the face using qAdjacent then all you need to do is check if qIntersection(edges of face, selected edge) is empty or not.

    Senior Director, Technical Services, EMEA
  • charles_randolphcharles_randolph Member Posts: 12

    Thanks Neil. I interpreted the evaluated Query to be a list of sub 'search terms', one of which would have an identical 'term' to that being sought. I think I still have to get used to working with queries a bit.

  • lanalana Onshape Employees Posts: 771 image

    Sketch face has a certain peculiarity. The sketch segments you can select on the screen are wire bodies. Edges of the sketch face are not selectable.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.