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.

Finding Concave Faces

Manfred_SManfred_S Member Posts: 3 EDU
Hello All,
I am just a beginner with featurescript and I am having trouble finding concave connected faces of a solid part, using featurescript. When I tried using the code shown below the debug showed all the faces of the selected solid part not just the concave connected faces.
The aim is to find the concave edges using these faces but there may be an easier way than way I am trying to do it currently. I will also want to find all the convex edges of the part eventually.
Could someone help me out please?
Thanks,
Manfred
Here is the code i was trying to use:
FeatureScript 1188;
import(path : "onshape/std/geometry.fs", version : "1188.0");
export const LENGTH_BOUND =
{
            (millimeter) : [0, 2.5, 1e10]
        } as LengthBoundSpec;
export const LENGTH_BOUND2 =
{
            (millimeter) : [0, 2.5, 1e10]
        } as LengthBoundSpec;
annotation { "Feature Type Name" : "Fillet Plus" }
export const myFillet = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        annotation { "Name" : "Parts to Fillet", "Filter" : EntityType.BODY && BodyType.SOLID, "MaxNumberOfPicks" : 1e10 }
        definition.part is Query;
        annotation { "Name" : "Edges to Exclude", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1e10 }
        definition.edgesExcl is Query;
        annotation { "Name" : "Faces to Exclude", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1e10 }
        definition.facesExcl is Query;
        annotation { "Name" : "Convex Radius" }
        isLength(definition.convexR, LENGTH_BOUND);
        annotation { "Name" : "Concave Radius" }
        isLength(definition.concaveR, LENGTH_BOUND2);
    }
    {
       var allEdges = qOwnedByBody(definition.part, EntityType.EDGE);
        var edgesExclEdge = qSubtraction(allEdges, definition.edgesExcl);
        var faceEdges = qEdgeAdjacent(definition.facesExcl, EntityType.EDGE);
        var edgesExclFaceEdge = qSubtraction(edgesExclEdge, faceEdges);
        var partFaces = qOwnedByBody(definition.part, EntityType.FACE);
        var concaveFaces = qConcaveConnectedFaces(partFaces);
        debug(context, concaveFaces);
    });

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    That query takes a seed face (in which case, you selected every face) then searches outwards from there, so that is why everything highlights. You will probably have to loop through each face individually. An example of the geometry you are testing would help.
    Senior Director, Technical Services, EMEAI
  • Manfred_SManfred_S Member Posts: 3 EDU

    Thanks for your help.
    Here is the simple block that I am using to test the script.
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    This works. Not sure it's the most efficient solution:
            var faces = qOwnedByBody(definition.body, EntityType.FACE);
            
            var result = qNothing();
            
            for(var face in evaluateQuery(context, faces))
            {
                result = qUnion([result, qSubtraction(qConcaveConnectedFaces(face), face)]);
            }
            
            debug(context, result);

    Senior Director, Technical Services, EMEAI
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    A solution for both:
            var partFaces = qOwnedByBody(definition.part, EntityType.FACE);
            
            var concaveFaces = qNothing();
          
            for(var face in evaluateQuery(context, partFaces))
            {
                concaveFaces = qUnion([concaveFaces, qSubtraction(qConcaveConnectedFaces(face), face)]);
            }
            
            var convexFaces = qSubtraction(partFaces,concaveFaces);
            
            var convexEdges = qAdjacent(convexFaces, AdjacencyType.EDGE, EntityType.EDGE);
            
            var concaveEdges = qSubtraction(qOwnedByBody(definition.part, EntityType.EDGE), convexEdges);

    Senior Director, Technical Services, EMEAI
  • Manfred_SManfred_S Member Posts: 3 EDU
    That's good. Thank you very much!
Sign In or Register to comment.