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.
Feature Script: How to set the "oppositeDirection"-Tag for extrude?
nikolas_engelhard
Member Posts: 5 ✭
Hey!
I'm starting with feature script and work on a small script that simply needs a thoughhole. I ask the user for a point (around which I draw a circle) and a face to which the hole is going to. This part of the script looks like this:
annotation { "Name" : "Vertex for center", "Filter" : EntityType.VERTEX, "MaxNumberOfPicks" : 1 }
definition.center is Query;
annotation { "Name" : "Back Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
definition.backface is Query;
(...)
var location = evVertexPoint(context, { "vertex" : definition.center });
var sketchPlane = evOwnerSketchPlane(context, { "entity" : definition.center });
const frontSketch = newSketchOnPlane(context, id + "frontSketch", { "sketchPlane" : sketchPlane });
const center = worldToPlane(sketchPlane, location);
// create the outer diameter circle
skCircle(frontSketch, "throughhole_circle", { "center" : center, "radius" : radius });
skSolve(frontSketch);
extrude(context, id + "extrude1", {
"entities" : qSketchRegion(id + "frontSketch", true),
"direction" : sketchPlane.normal,
"oppositeDirection" : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
"operationType" : NewBodyOperationType.REMOVE,
"defaultScope" : true,
"endBound" : BoundingType.UP_TO_SURFACE,
"endBoundEntityFace" : definition.backface
});
I don't understand yet how to set the oppositeDirection-flag. To test the function, I created a sketch with two rectangles on the top-plane and extruded both in different direction. (negative and positive z-space). But only one generates correctly.
So how is the normal of a plane defined? And how can I just create a hole? There should be an easy way to say "Remove into the object", but I haven't found it yet.
I'm starting with feature script and work on a small script that simply needs a thoughhole. I ask the user for a point (around which I draw a circle) and a face to which the hole is going to. This part of the script looks like this:
annotation { "Name" : "Vertex for center", "Filter" : EntityType.VERTEX, "MaxNumberOfPicks" : 1 }
definition.center is Query;
annotation { "Name" : "Back Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
definition.backface is Query;
(...)
var location = evVertexPoint(context, { "vertex" : definition.center });
var sketchPlane = evOwnerSketchPlane(context, { "entity" : definition.center });
const frontSketch = newSketchOnPlane(context, id + "frontSketch", { "sketchPlane" : sketchPlane });
const center = worldToPlane(sketchPlane, location);
// create the outer diameter circle
skCircle(frontSketch, "throughhole_circle", { "center" : center, "radius" : radius });
skSolve(frontSketch);
extrude(context, id + "extrude1", {
"entities" : qSketchRegion(id + "frontSketch", true),
"direction" : sketchPlane.normal,
"oppositeDirection" : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
"operationType" : NewBodyOperationType.REMOVE,
"defaultScope" : true,
"endBound" : BoundingType.UP_TO_SURFACE,
"endBoundEntityFace" : definition.backface
});
I don't understand yet how to set the oppositeDirection-flag. To test the function, I created a sketch with two rectangles on the top-plane and extruded both in different direction. (negative and positive z-space). But only one generates correctly.
So how is the normal of a plane defined? And how can I just create a hole? There should be an easy way to say "Remove into the object", but I haven't found it yet.
Tagged:
0
Answers
and then inside the feature explicitly flip extrude direction like that (or using if operator)