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.

Having trouble with opExtrude on skText

jason_bennett190jason_bennett190 Member, Developers Posts: 17 PRO
Hello,

I am trying to make 3D text via a Feature script, but having trouble with the "holes" being filled upon opExtrude.

How do I get ride of the extra material?

Thanks


Section of Code:
opPlane(context, id + "plane1", {                "plane" : plane(planeOrigin, planeNormal)        });                var sketch1 = newSketch(context, id + "sketch1", {                "sketchPlane" : qCreatedBy(id + "plane1", EntityType.FACE)        });                    const textItem = skText(sketch1, "text1", {                    "text":definition.label,                    "fontName" : "OpenSans-Bold.ttf"            });                    skSolve(sketch1);                        const textOrigin = vector(0*meter,0*meter,planeOrigin[2]);        const textMove = vector(minPoint[0]+textHeight,maxPoint[1]-2*textHeight,0*meter);
        opTransform(context, id + "transform1", {                "bodies" : qCreatedBy(id + "sketch1", EntityType.BODY),                "transform" : transform(textMove)*scaleUniformly(textScale,textOrigin)        });                opExtrude(context, id + "extrude1", {                "entities" : qCreatedBy(id + "sketch1", EntityType.FACE),                "direction" : planeNormal*-1,                "endBound" : BoundingType.BLIND,                "endDepth" : 3 * millimeter        });

Results:

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,085
    Try qSketchRegion instead of qCreatedBy
    Neil Cooke, Director of Technical Marketing, Onshape Inc.
  • jason_bennett190jason_bennett190 Member, Developers Posts: 17 PRO
    Same results from using qSketchRegion. I thought maybe the transform was doing something, but the debug also highlights the holes in the letters.

     
           opPlane(context, id + "plane1", {                "plane" : plane(planeOrigin, planeNormal)        });                var sketch1 = newSketch(context, id + "sketch1", {                "sketchPlane" : qCreatedBy(id + "plane1", EntityType.FACE)        });                    const textItem = skText(sketch1, "text1", {                    "text":definition.label,                    "fontName" : "OpenSans-Bold.ttf"            });                    skSolve(sketch1);                        const textOrigin = vector(0*meter,0*meter,planeOrigin[2]);        const textMove = vector(minPoint[0]+textHeight,maxPoint[1]-2*textHeight,0*meter);                debug(context, qSketchRegion(id + "sketch1"));                opTransform(context, id + "transform1", {                "bodies" : qCreatedBy(id + "sketch1", EntityType.BODY),                "transform" : transform(textMove)*scaleUniformly(textScale,textOrigin)        });                opExtrude(context, id + "extrude1", {                "entities" : qSketchRegion(id + "sketch1"),                "direction" : planeNormal*-1,                "endBound" : BoundingType.BLIND,                "endDepth" : 3 * millimeter        });
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,085
    There is more than 1 sketch region so try qNthElement(qSketchRegion(id + "sketch1"), 0)
    Neil Cooke, Director of Technical Marketing, Onshape Inc.
  • jason_bennett190jason_bennett190 Member, Developers Posts: 17 PRO
    qNthElement(qSketchRegion(id + "sketch1"), 0) returns one of the numbers. Each X (0->15) in qNthElement(qSketchRegion(id + "sketch1"), X) returns one of the letters or letter holes. Unfortunately there is no pattern in the element order.

    If there is no quick fix or minor thing that I am missing, I think I could build a sorting function. Maybe:

    • Cycle through qNthElement(qSketchRegion(id + "sketch1"), X)
    • if (query adjacent face == 0) {add X to var facesToExtrude}
    • else { if(area of X > area adjacent) {add X to var facesToExtrude}}

  • lanalana Onshape Employees Posts: 453
    @jason_bennett190
    You want to use qSketchRegion() as a query that you pas to opExtrude, not to opPlane - just to make sure.
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,085
    • Cycle through qNthElement(qSketchRegion(id + "sketch1"), X)
    • if (query adjacent face == 0) {add X to var facesToExtrude}
    • else { if(area of X > area adjacent) {add X to var facesToExtrude}}

    That seems reasonable - you could also use evBox3d to see if one region is totally inside another.

    qSketchRegion also has an innerloop filter which may work - 

    qSketchRegion (featureId is Id, filterInnerLoops is boolean) returns Query

    A query for all fully enclosed, 2D regions created by a sketch with the specified feature id.

    ParameterTypeAdditional Info
    filterInnerLoopsboolean

    Optional

    Specifies whether to exclude sketch regions fully contained in other sketch regions. Default is false.

    Neil Cooke, Director of Technical Marketing, Onshape Inc.
  • jason_bennett190jason_bennett190 Member, Developers Posts: 17 PRO
    Yes. I am passing the qSketchRegion() to the opExtrude.

    As a work around, I wrote a filter to remove the internal regions, which is below.

    I would still like to see a simpler solution.

    Thanks for the feedback so far.

    //Filter out character flaws
    
            const sketchFaces = qSketchRegion(id + "sketch1");
    
            const faceCount = size(evaluateQuery(context, sketchFaces));
    
            var extrudeFaces = qNothing();                for (var i = 0; i < faceCount; i += 1)        {
    
                const item = qNthElement(sketchFaces, i);            
    
                const adjacentItem = qEdgeAdjacent(item, EntityType.FACE);            
    
                println(size(evaluateQuery(context, adjacentItem)));            
    
                if(size(evaluateQuery(context, adjacentItem))!=1){
    
                    extrudeFaces = qUnion([extrudeFaces,item]);                            }else            {
    
                    if (evArea(context, {"entities" : item})>evArea(context, {"entities" : adjacentItem}))                {
    
                        extrudeFaces = qUnion([extrudeFaces,item]);                }            }                     }


  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,085
    Yes, so actually you shouldn't need qNthElement at all, qSketchRegion(id + "sketch1", true) should work
    Neil Cooke, Director of Technical Marketing, Onshape Inc.
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 436
    Yup, filterInnerLoops on qSketchRegion is a flag designed for exactly this kind of thing. No need for additional custom filtering.

    @NeilCooke
    It looks like filterInnerLoops used to default to "true" in older versions of std, which is likely why you don't remember needing to specify the flag before.
  • jason_bennett190jason_bennett190 Member, Developers Posts: 17 PRO
    Using qSketchRegion(id + "sketch1", true) works

    Thanks!
  • neil_jackson795neil_jackson795 Member Posts: 3
    edited July 2017

    Unfortunately, filterInnerLoops does not properly handle the case where there is more than one level of nested loops.

    As an example, make a sketchText containing Unicode character 0x0298 (LATIN LETTER BILABIAL CLICK): ʘ  (Use the Tinos font). This character is topologically equivalent to an "O" character with a dot in the middle of the "O". Extrude the sketch with filterInnerLoops, and in the resulting solid, you will see that the middle dot is missing.

Sign In or Register to comment.