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.

opSplitFailing for some reason

thomas_fieguththomas_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

  • joshtargojoshtargo Member Posts: 537 EDU

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

Sign In or Register to comment.

Howdy, Stranger!

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