Transforming sketch causes inner loops not to be selected when extruding

grant_ottaway
grant_ottaway Member Posts: 2 ✭✭

Hi There

I'm new to featurescript and was experimenting with placing text in a sketch. I was specifically trying to extrude text but couldn't get the inner loops to extrude, eventually I found the issue was caused when the sketch had been transformed.

I've created a very short function below to show the issue where the first opExtrude produces the 6 correctly but the second is missing the inner hole.

Am I doing something wrong or is this a bug?

FeatureScript 2770;
import(path : "onshape/std/common.fs", version : "2770.0");
annotation { "Feature Type Name" : "My Feature", "Feature Type Description" : "" }
export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
// Define the parameters of the feature type
}
{
    var sketch1 = newSketch(context, id + "sketch1", {
    "sketchPlane" : qCreatedBy(makeId("Top"), EntityType.FACE)
    });

    skText(sketch1, "text1", {
                "text" : "6",
                "fontName" : "OpenSans-Regular.ttf",
                "firstCorner" : vector(0, 0) * inch,
                "secondCorner" : vector(1, 1) * inch
            });

    skSolve(sketch1);

    // This works correctly and extrudes the letter 6 with the hole in the 6
    opExtrude(context, id + "extrude1", {
                "entities" : qSketchRegion(id + "sketch1", true),
                "direction" : vector(0, 0, 1),
                "endBound" : BoundingType.BLIND,
                "endDepth" : 1 * inch
            });

    opTransform(context, id + "transform1", {
                "bodies" : qCreatedBy(id + "sketch1", EntityType.BODY),
                "transform" : transform(vector(2, 0, 0) * inch)
            });

    // After transforming the sketch it no longer extrudes the 6 with a hole in it.
    opExtrude(context, id + "extrude2", {
                "entities" : qSketchRegion(id + "sketch1", true),
                "direction" : vector(0, 0, 1),
                "endBound" : BoundingType.BLIND,
                "endDepth" : 1 * inch
            });
});

Comments

  • lana
    lana Onshape Employees Posts: 782 image

    Transforming sketch bodies is not going to work well. If you need to place the sketch differently, use a different plane and newSketchOnPlane instead of newSketch or transform the extruded body.

  • grant_ottaway
    grant_ottaway Member Posts: 2 ✭✭

    Thanks for the help!

    I ended up just extruding the text and then transforming it as you suggested, however it's a bit of a pain as I really want to extrude the text to be offset from a surface and because the text isn't extruded in it's final position I have to move the text body and then trim it using the surface I wanted.

    I could use your other suggestion by creating a new plane for each piece of text but I want the text centered on a point and as far as I know I can only find out the size of the text after I have created it so I would be stuck needing to either transform the sketch or transform the resulting body and then have to trim it with my offset surface?