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.
Extruding in a for loop
Wyatt_Thomas
Member Posts: 2 ✭
I am trying to extrude this sketch in a for loop but it doesn't work when I have multiple selections. I will create multiple sketches if I remove the extrude tho. Any Ideas? Here is the code:
var sketchQueries = [];
var recId = "rectangle1";
var sketchid = id + "sketch";
for (var i = 0; i < numberOfEdges; i += 1)
{
sketchid = sketchid + i;
var edge = edges[i];
filletid = filletid + i;
extrudeid = extrudeid + i;
var midPoint is Line = (evEdgeTangentLine(context, {
"edge" : edge,
"parameter" : .5
}));
//debug(context, midPoint);
var cSys is CoordSystem = coordSystem(midPoint.origin, xDirection, zDirection);
//debug(context, cSys);
var planeSketch is Plane = plane(cSys);
var sketch1 = newSketchOnPlane(context, sketchid, {
"sketchPlane" : planeSketch
});
// Create sketch entities here
skRectangle(sketch1, recId, {
"firstCorner" : vector(.25, 0) * inch,
"secondCorner" : vector(-.25, -.06) * inch
});
skSolve(sketch1);
sketchQueries = qSketchRegion(sketchid);
// debug(context, sketchQueries);
opExtrude(context, id + i + "extrude", {
"entities" : sketchQueries,
"direction" : zDirection,
"endBound" : BoundingType.BLIND,
"endDepth" : .15 * inch
});
0
Comments
Tl;dr, the code can be fixed in this way: https://cad.onshape.com/documents/63114e47fbe4507b5fc804dd/w/38141d746384f6a4b5bece89/e/a1bf5ac2532b92dd7e5cd54e