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.
Feature script CANNOT_RESOLVE_ENTITIES error
joe_gatling
Member Posts: 3 ✭✭
Hello, I am very new to feature script I am writing a feature script that will automatically add holes to a part at a fixed spacing. The goal is to pass a line along which the holes should be cut, and the spacing desired and have the script decide how many holes will fit, and how to center them along the line. I have the logic of the hole placement working, but the final boolean to actually subtract them from my part is giving me a "CANNOT_RESOLVE_ENTITIES" error. I am pretty advanced in other programming languages like c#, but the concepts involved in FS are really giving me a headache.
The document I am working on is here: https://cad.onshape.com/documents/1bf535513ae3dcbf66a9e1ae/w/949a41da612184a3bb92d3ac/e/1fb9668c48c8b413d51dc58b
When regenerating, the opBoolean line at the bottom throws the error. Any help would be appreciated.
The code is as follows:
The document I am working on is here: https://cad.onshape.com/documents/1bf535513ae3dcbf66a9e1ae/w/949a41da612184a3bb92d3ac/e/1fb9668c48c8b413d51dc58b
When regenerating, the opBoolean line at the bottom throws the error. Any help would be appreciated.
The code is as follows:
FeatureScript 1150; import(path : "onshape/std/geometry.fs", version : "1150.0"); annotation { "Feature Type Name" : "Connection Holes" } export const myFeature = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "Hole Diameter" } isLength(definition.holeDiameter, LENGTH_BOUNDS); annotation { "Name" : "Hole Depth" } isLength(definition.holeDepth, LENGTH_BOUNDS); annotation { "Name" : "Spacing" } isLength(definition.spacing, LENGTH_BOUNDS); annotation { "Name" : "Edges", "Filter" : EntityType.EDGE && GeometryType.LINE} definition.lines is Query; annotation { "Name" : "Merge scope", "Filter" : EntityType.BODY && BodyType.SOLID } definition.mergeScope is Query; } { const lines = evaluateQuery(context, definition.lines); for (var line in lines) { var length = evLength(context, { "entities" : line }); var numberOfHoles is number = floor(length / definition.spacing); var tPerHole is number = definition.spacing / length; var remainingT is number = 1.0 - (tPerHole * numberOfHoles); // debug(context, "Length: " ~ length); // debug(context, "Holes: " ~ numberOfHoles); // debug(context, "t Per Hole: " ~ tPerHole); // debug(context, "test: " ~ (remainingT + (tPerHole * numberOfHoles))); var sketchPlane = evOwnerSketchPlane(context, { "entity" : line }); var normal = sketchPlane.normal; var baseId is Id = id + "cylinder"; for(var i = 0; i <= numberOfHoles; i += 1) { var t = remainingT/2.0 + tPerHole * i; var point = evEdgeTangentLine(context, { "edge" : line, "parameter" : t }).origin; fCylinder(context, baseId + i, { "topCenter" : point, "bottomCenter" : point - normal * definition.holeDepth, "radius" : definition.holeDiameter/2.0 }); } debug(context, qCreatedBy(baseId, EntityType.BODY)); opBoolean(context, id + "boolean1", { "tools" : qCreatedBy(baseId, EntityType.BODY), "targets" : definition.mergeScope, "operationType" : BooleanOperationType.SUBTRACTION }); } });
Tagged:
1
Best Answer
-
joe_gatling Member Posts: 3 ✭✭OMG. Never mind. I turns out I didn't have any entities defined in definition.mergeScope so there were no targets to subtract from.1
Answers