qSubtraction part edges vs sketch edges?

MichaelPascoe
MichaelPascoe Member Posts: 2,965 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:


RENDERCAD - Photorealistic product rendering.
CADSharp - Professional CAD + software consulting.

▚▞▚▞▚▞▚▞▚

Best Answer

  • lana
    lana Onshape Employees Posts: 782 image
    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

  • lana
    lana Onshape Employees Posts: 782 image
    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));
    
  • MichaelPascoe
    MichaelPascoe Member Posts: 2,965 PRO
    @lana

    Thanks for the quick response, I will try this.

    RENDERCAD - Photorealistic product rendering.
    CADSharp - Professional CAD + software consulting.

    ▚▞▚▞▚▞▚▞▚
  • MichaelPascoe
    MichaelPascoe Member Posts: 2,965 PRO
    This worked great! I would not have figured that one out.

    RENDERCAD - Photorealistic product rendering.
    CADSharp - Professional CAD + software consulting.

    ▚▞▚▞▚▞▚▞▚
  • lana
    lana Onshape Employees Posts: 782 image
    @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.