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

Thicken doesn't seem robust

marcosinethetamarcosinetheta Member Posts: 2
I'm trying to make a thin-extrude feature in featurescript.  I want to be able to pick a face (or faces) and have it extrude a surface using the edge of that face, thicken that surface, and then delete the body.  I thought I had it right but I noticed that when I use it, if I select multiple faces, some thicken in different directions than I want them to.  Also, when it regenerates, the parts will sometimes switch which direction they thickened.  It doesn't seem very robust. Any suggestions on how to fix this?  I currently want to use the feature to make square rectangular tubing slightly easier.  Here's the code:

annotation { "Feature Type Name" : "Thin Extrude" }<br>export const thinExtrude = defineFeature(function(context is Context, id is Id, definition is map)<br>&nbsp;&nbsp;&nbsp; precondition<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Define the parameters of the feature type<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; annotation { "Name" : "Select Faces", "Filter" : EntityType.FACE}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; definition.faces is Query;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; annotation { "Name" : "Thickness" }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isLength(definition.myThickness, LENGTH_BOUNDS);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; annotation { "Name" : "Length" }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isLength(definition.myLength, LENGTH_BOUNDS);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Define the function's action<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opExtrude(context, id + "extrude1", {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "entities" : qEdgeAdjacent(definition.faces, EntityType.EDGE),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "direction" : evOwnerSketchPlane(context, {"entity" : definition.faces}).normal,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "endBound" : BoundingType.BLIND,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "endDepth" : definition.myLength<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opThicken(context, id + "thicken1", {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "entities" : qCreatedBy(id + "extrude1", EntityType.BODY),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "thickness1" : 0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "thickness2" : definition.myThickness<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opDeleteBodies(context, id + "deleteBodies1", {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "entities" : qCreatedBy(id + "extrude1", EntityType.BODY)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br>&nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp; });



Comments

  • Options
    kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    Thicken chooses which side is "thickness1" or "thickness2" based on the direction of the surface normal (I believe thickness1 extends in the normal direction, thickness2 in anti-normal direction). The issue is that an edge (potentially bordering multiple faces) isn't going to naturally be oriented with respect to any single face (even if you found that edge via qEdgeAdjacent).

    The good news is that when you extrude a solid, we do guarantee that all faces on that solid will have their normals pointing to the outside of that solid.

    So the easiest fix I see is to opExtrude the face into a solid, query for all the non-cap faces of the solid (via qSubtraction and 
    qCapEntity), thicken those faces, and delete the solid.
  • Options
    marcosinethetamarcosinetheta Member Posts: 2
    Finally got around to using this.  It worked!  I might mess with the UI a bit more but here is what I currently have that works.

    annotation { "Feature Type Name" : "Thin Extrude" }<br>export const thinExtrude = defineFeature(function(context is Context, id is Id, definition is map)<br>    precondition<br>    {<br>        // Define the parameters of the feature type<br>        annotation { "Name" : "Select Faces", "Filter" : EntityType.FACE }<br>        definition.faces is Query;<br><br>        annotation { "Name" : "Thickness 1" }<br>        isLength(definition.myThickness_1, NONNEGATIVE_ZERO_INCLUSIVE_LENGTH_BOUNDS);<br><br>        annotation { "Name" : "Thickness 2" }<br>        isLength(definition.myThickness_2, NONNEGATIVE_ZERO_INCLUSIVE_LENGTH_BOUNDS);<br><br>        annotation { "Name" : "Length" }<br>        isLength(definition.myLength, LENGTH_BOUNDS);<br><br><br><br>    }<br>    {<br>        // Define the function's action<br>        opExtrude(context, id + "extrude1", {<br>                    "entities" : definition.faces,<br>                    "direction" : evOwnerSketchPlane(context, { "entity" : definition.faces }).normal,<br>                    "endBound" : BoundingType.BLIND,<br>                    "endDepth" : definition.myLength<br>                });<br>        thicken(context, id+"thickness1", {<br>            "entities":qSubtraction(qCreatedBy(id + "extrude1", EntityType.FACE),<br>             qUnion([qCapEntity(id+"extrude1",true),qCapEntity(id+"extrude1", false)])),<br>            "operationType":NewBodyOperationType.NEW,<br>            "thickness1":definition.myThickness_1,<br>            "thickness2":definition.myThickness_2<br>            });<br>        opDeleteBodies(context, id + "deleteBodies1", {<br>                "entities" : qCreatedBy(id + "extrude1", EntityType.BODY)<br>        });<br><br><br>    });<br><br>



Sign In or Register to comment.