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.
Repeat the function's action for each selection of the UI

I have a simple function to split face using a text. I want to be able to select multiple faces and have the function executed for all of them.
How do I go about it?
Thank you
// Define the function's action var center = evPlane(context, { "face" : definition.faceToSplit }); debug(context, center, DebugColor.RED); var sketch2 = newSketchOnPlane(context, id + "sketch2", { "sketchPlane" : center }); var text = skText(sketch2, "text1", { "text" : definition.text, "fontName" : "Poppins-Regular.ttf", "firstCorner" : vector(0, 0) * inch, "secondCorner" : vector((1 * inch), definition.fontSize) }); skSolve(sketch2); var textEdges = qSketchRegion(id + "sketch2"); var loop = qLoopEdges(textEdges); debug(context, loop, DebugColor.GREEN); opSplitFace(context, id + "splitFace1", { "faceTargets" : definition.faceToSplit, "edgeTools" : loop }); opDeleteBodies(context, id + "deleteBodies2", { "entities" : qCreatedBy(id + "sketch2", EntityType.EDGE) });
0
Comments
I'd recommend looking into using a for loop here - though you may run into challenges for any non-planar face as your code requires a planar face to create a plane which you then sketch on. I'd imagine that WHERE you want to split each face is a fairly specific location and that simply solving for 'a plane' on that face does not get you the resolution you're looking for. I'd recommend something similar to what follows:
Cheers,
-j
try putting the above in a 'forEachEntity'
https://cad.onshape.com/documents/37fa98fdc1a0b9ce78ff38bb/w/257085d868fb32e6998b6a89/e/11361fdeab998371aea29978