Trying to extrude text but can't filter out inner loops.
jakefrommars64
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") });
}); 0
Answers
-
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, ... });2 -
@vanowm right click any text input → convert to expression. This will let you use a variable instead of just text.
It would be great if there were a little variable icon in each text input that people could click.
▚▞▚▞▚▞▚▞▚0


