Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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_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
Tagged:
0
Comments
Are any of those faces in the middle of the body?