opSplitFailing for some reason

thomas_fieguth
thomas_fieguth Member Posts: 10 EDU

Hello, I cannot figure out this error. It is a relatively simple bit of code.
I can see that the bodies variable is a valid body (using debug entities)
Additionally, I can split using the planes created using opPlane.

The error is:
@opSplitPart : SPLIT_SELECT_TARGETS

Code:

FeatureScript 2960;
import(path : "onshape/std/common.fs", version : "2960.0");
annotation { "Feature Type Name" : "Flat Detection Split", "Feature Type Description" : "" }
export const flatDetectionSplit = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
    annotation { "Name" : "Body", "Filter" : EntityType.BODY}
    definition.bodies is Query;

    annotation { "Name" : "Other cSys" }
    definition.otherCsys is boolean;
    
    if (definition.otherCsys) {
        annotation { "Name" : "Plane", "Filter" : EntityType.FACE && GeometryType.PLANE, "MaxNumberOfPicks" : 1 }
        definition.basePlane is Query;
    }
}
{
    if (!definition.otherCsys) {
        definition.basePlane = plane(WORLD_COORD_SYSTEM);
    }
    
    var count = 0;
    
    
    for (var body in evaluateQuery(context, definition.bodies)) {
        var bodies = body;
        const allFaces = qGeometry(qOwnedByBody(body, EntityType.FACE), GeometryType.PLANE);
        const parallelFaces = qParallelPlanes(allFaces, definition.basePlane);
        
        for (var parallelFace in evaluateQuery(context, parallelFaces)) {
            opPlane(context, id + ("plane" ~ count), {
                    "plane" : evPlane(context, {"face" : parallelFace})
            });
            
            // addDebugEntities(context, body, DebugColor.RED);
            
            try {
                opSplitPart(context, id + ("splitPart" ~ count), { //Error occurs here
                    "targets" : bodies,
                    "tool" : parallelFace
            });
            }
            catch (error) {
                print("Could not split");
                println(error);
            }
                            
            bodies = qUnion(bodies, qCreatedBy(id + ("splitPart" ~ count), EntityType.BODY));
            
            count += 1;
        }
    }
});

Thanks in advance

Thomas

Comments

  • joshtargo
    joshtargo Member Posts: 693 EDU

    Are any of those faces in the middle of the body?