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

Trying to extrude text but can't filter out inner loops.

jakefrommars64jakefrommars64 Member Posts: 2
I am trying to extrude text and am encountering a similar problem to this post (which was solved for them), however after implementing the "qSketchRegion" with filterInnerLoops set to true nothing changed and any letters with inner loops have those loops extruded too. How can I exclude those loops so my "o"s aren't cylinders when I cant query a point in those regions as eventually the text will be parameter driven?

FeatureScript 2221;
import(path : "onshape/std/common.fs", version : "2221.0");
import(path : "onshape/std/geometry.fs", version : "2221.0");

const MARGIN = 0.85 * millimeter;

// annotation { "Default Units" : ["cubicMillimeter", "degree", "degreePerSecond", "footPoundForce", "gram", "meterPerSecondSquared", "millimeter", "newton", "newtonMeter", "pascal", "second", "squareMillimeter"] }
annotation { "Feature Type Name" : "RatioText" }
export const ratioText = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {

        annotation { "Name" : "Body", "Filter" : EntityType.BODY, "MaxNumberOfPicks" : 1 }
        definition.body is Query;
        
        // On which face should the text be shown?
        annotation { "Name" : "Surface", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
        definition.surface is Query;
        
        annotation { "Name" : "Baseline", "Filter" : EntityType.EDGE && GeometryType.LINE, "MaxNumberOfPicks" : 1 }
        definition.baseline is Query;
        
        
        // Height of the text (font size)
        annotation { "Name" : "Text Height" }
        isLength(definition.textHeight, { (millimeter) : [0.5, 4, 20] } as LengthBoundSpec);

        // How deep to extrude the text into the object
        annotation { "Name" : "Depth of Text" }
        isLength(definition.depth, { (millimeter) : [0.01, 0.4, 5] } as LengthBoundSpec);

    }
    {
        // Create a sketch on the given plane
        var sketchPlane = evPlane(context, {
                "face" : definition.surface
            });
        var sketch1 = newSketchOnPlane(context, id + "sketch1", {
                "sketchPlane" : sketchPlane
            });
        var cSys = coordSystem(sketchPlane);

        var firstCorner = vector(0, 0) * millimeter;
        var secondCorner = vector(100 * millimeter, definition.textHeight);

        // Create the text and move it to be centered on the part
        skText(sketch1, "textId", {
                    "text" : "Hello World!",
                    "fontName" : "NoboSans-Regular.ttf",
                    "firstCorner" : firstCorner,
                    "secondCorner" : secondCorner
                });

        skSolve(sketch1);

        var bbox = evBox3d(context, {
                "topology" : qCreatedBy(id + "sketch1", EntityType.BODY),
                "cSys" : cSys,
                "tight" : true
            });

        opTransform(context, id + "transform1", {
                    "bodies" : qCreatedBy(id + "sketch1", EntityType.BODY),
                    "transform" : transform(vector(
                                -(bbox.maxCorner[0] - bbox.minCorner[0]) / 2.0,
                                -(bbox.maxCorner[1] - bbox.minCorner[1]) - MARGIN / 2.0,
                                0 * millimeter))
                });

        // Extrude the text
        var sketchQuery = qSketchRegion(id + "sketch1", true);
        extrude(context, id + "extrude1", {
                    "entities" : qSketchRegion(id + "sketch1"),
                    "endBound" : BoundingType.BLIND,
                    "depth" : definition.depth,
                    "oppositeDirection": false,
                    "operationType" : NewBodyOperationType.ADD,
                    "defaultScope" : true
                });
                
        opDeleteBodies(context, id + "deleteSketch", { "entities": qCreatedBy(id + "sketch1") });
    });

Answers

  • Options
    DavisCCRDavisCCR OS Professional Posts: 2
    I had the same issue in my Labeler Feature and eventually solved it by making a robust query right after the skSolve(). Then later using it after the transforms.

    skText(...);
    skSolve(...);
    const sketchRegions is Query = makeRobustQuery(context, qSketchRegion(sketchId, true));
    opTransform(...);
    opExtrude(... { "entities" : sketchRegions, ... });
Sign In or Register to comment.