Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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
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:
<div>opPlane(context, id + "plane1", {</div><div> "plane" : plane(planeOrigin, planeNormal)</div><div> });</div><div> </div><div> var sketch1 = newSketch(context, id + "sketch1", {</div><div> "sketchPlane" : qCreatedBy(id + "plane1", EntityType.FACE)</div><div> });</div><div> </div><div> const textItem = skText(sketch1, "text1", {</div><div> "text":definition.label,</div><div> "fontName" : "OpenSans-Bold.ttf"</div><div> });</div><div> </div><div> skSolve(sketch1);</div><div> </div><div> </div><div> const textOrigin = vector(0*meter,0*meter,planeOrigin[2]);</div><div> const textMove = vector(minPoint[0]+textHeight,maxPoint[1]-2*textHeight,0*meter);</div><div><br></div><div> opTransform(context, id + "transform1", {</div><div> "bodies" : qCreatedBy(id + "sketch1", EntityType.BODY),</div><div> "transform" : transform(textMove)*scaleUniformly(textScale,textOrigin)</div><div> });</div><div> </div><div> opExtrude(context, id + "extrude1", {</div><div> "entities" : qCreatedBy(id + "sketch1", EntityType.FACE),</div><div> "direction" : planeNormal*-1,</div><div> "endBound" : BoundingType.BLIND,</div><div> "endDepth" : 3 * millimeter</div><div> });</div>Results:
Comments
-
Try qSketchRegion instead of qCreatedBySenior Director, Technical Services, EMEA0
-
Same results from using qSketchRegion. I thought maybe the transform was doing something, but the debug also highlights the holes in the letters.
<div> opPlane(context, id + "plane1", {</div><div> "plane" : plane(planeOrigin, planeNormal)</div><div> });</div><div> </div><div> var sketch1 = newSketch(context, id + "sketch1", {</div><div> "sketchPlane" : qCreatedBy(id + "plane1", EntityType.FACE)</div><div> });</div><div> </div><div> const textItem = skText(sketch1, "text1", {</div><div> "text":definition.label,</div><div> "fontName" : "OpenSans-Bold.ttf"</div><div> });</div><div> </div><div> skSolve(sketch1);</div><div> </div><div> </div><div> const textOrigin = vector(0*meter,0*meter,planeOrigin[2]);</div><div> const textMove = vector(minPoint[0]+textHeight,maxPoint[1]-2*textHeight,0*meter);</div><div> </div><div> debug(context, qSketchRegion(id + "sketch1"));</div><div> </div><div> opTransform(context, id + "transform1", {</div><div> "bodies" : qCreatedBy(id + "sketch1", EntityType.BODY),</div><div> "transform" : transform(textMove)*scaleUniformly(textScale,textOrigin)</div><div> });</div><div> </div><div> opExtrude(context, id + "extrude1", {</div><div> "entities" : qSketchRegion(id + "sketch1"),</div><div> "direction" : planeNormal*-1,</div><div> "endBound" : BoundingType.BLIND,</div><div> "endDepth" : 3 * millimeter</div><div> });</div>0 -
There is more than 1 sketch region so try qNthElement(qSketchRegion(id + "sketch1"), 0)Senior Director, Technical Services, EMEA0
-
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}}
0 -
@jason_bennett190
You want to use qSketchRegion() as a query that you pas to opExtrude, not to opPlane - just to make sure.0 -
That seems reasonable - you could also use evBox3d to see if one region is totally inside another.jason_bennett190 said:- 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}}
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.
Parameter Type Additional Info filterInnerLoopsbooleanOptional
Specifies whether to exclude sketch regions fully contained in other sketch regions. Default is false.
Senior Director, Technical Services, EMEA0 -
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.<div>//Filter out character flaws </div><div> const sketchFaces = qSketchRegion(id + "sketch1"); </div><div> const faceCount = size(evaluateQuery(context, sketchFaces)); </div><div> var extrudeFaces = qNothing();</div><div> </div><div> for (var i = 0; i < faceCount; i += 1)</div><div> { </div><div> const item = qNthElement(sketchFaces, i);</div><div> </div><div> const adjacentItem = qEdgeAdjacent(item, EntityType.FACE);</div><div> </div><div> println(size(evaluateQuery(context, adjacentItem)));</div><div> </div><div> if(size(evaluateQuery(context, adjacentItem))!=1){ </div><div> extrudeFaces = qUnion([extrudeFaces,item]);</div><div> </div><div> }else</div><div> { </div><div> if (evArea(context, {"entities" : item})>evArea(context, {"entities" : adjacentItem}))</div><div> { </div><div> extrudeFaces = qUnion([extrudeFaces,item]);</div><div> }</div><div> } </div><div> </div><div> }<br></div>0 -
Yes, so actually you shouldn't need qNthElement at all, qSketchRegion(id + "sketch1", true) should workSenior Director, Technical Services, EMEA0
-
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.1 -
Using qSketchRegion(id + "sketch1", true) works
Thanks!0 -
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.
0 -
great, that works!!0


