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.

qSubtraction part edges vs sketch edges?

MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO
edited February 2021 in FeatureScript
I'm trying to preform a qSubtraction by subtracting the edges of a face and desired excluded edges. The subtraction works when both selections are on a part, but it doesn't work when the selection is a sketch face and a sketch edge belonging to the sketch face.

How would I preform a qSubtraction between the edges of a selected sketch face, and one of the edges selected on the same face?

Here is the code for the edges:

annotation { "Name" : "Path faces", "Filter" : EntityType.FACE }
        definition.face is Query;

        annotation { "Name" : "Exclude edges" }
        definition.excludeEdges is boolean;

        if (definition.excludeEdges == true)
        {
            annotation { "Name" : "Edges of path to exclude", "Filter" : EntityType.EDGE }
            definition.excludedEdges is Query;
        }
var loopedEdges = qSubtraction( qAdjacent(pathFaces[count], AdjacencyType.EDGE, EntityType.EDGE), definition.excludedEdges ); debug(context, loopedEdges, DebugColor.GREEN);



Part selection results:




Sketch selection results:


Learn more about the Gospel of Christ  ( Here )

CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴

Best Answer

  • lanalana Onshape Employees Posts: 706
    edited February 2021 Answer ✓
    The sketch edges rendered on the screen are not adjacent to the sketch face. They belong to different bodies. You could use
    var trackingQs = [];
    for (var edge in evaluateQuery(context, definition.excludedEdges))
    {
        const edgeTracking = startTracking(context, {"subquery" : edge, "lastOperationId": lastModifyingOperationId(context, edge)});
        trackingQs = append(trackingQs, edgeTracking);
    }
    const remainingFaceEdges = qSubtraction(qAdjacent..., qUnion(trackingQs));
    

Answers

  • lanalana Onshape Employees Posts: 706
    edited February 2021 Answer ✓
    The sketch edges rendered on the screen are not adjacent to the sketch face. They belong to different bodies. You could use
    var trackingQs = [];
    for (var edge in evaluateQuery(context, definition.excludedEdges))
    {
        const edgeTracking = startTracking(context, {"subquery" : edge, "lastOperationId": lastModifyingOperationId(context, edge)});
        trackingQs = append(trackingQs, edgeTracking);
    }
    const remainingFaceEdges = qSubtraction(qAdjacent..., qUnion(trackingQs));
    
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO
    @lana

    Thanks for the quick response, I will try this.

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • MichaelPascoeMichaelPascoe Member Posts: 1,982 PRO
    This worked great! I would not have figured that one out.

    Learn more about the Gospel of Christ  ( Here )

    CADSharp  -  We make custom features and integrated Onshape apps!   Learn How to FeatureScript Here 🔴
  • lanalana Onshape Employees Posts: 706
    @MichaelPascoe
     It is unfortunately rather obscure, very much informed by how we handle sketch geometry. startTracking is a useful mechanism for linking input geometry with results of operations.
Sign In or Register to comment.