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.

Options

Extruding in a for loop

Wyatt_ThomasWyatt_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
                    });
Sign In or Register to comment.