How to extrude skRegularPolygon ?
frederik_larsen108
Member Posts: 9 EDU
I made a a sketch, and on that sketch a polygon:
var poly1 = skRegularPolygon(sketch, "polygon1", {
"center" : pointArray[0],
"firstVertex" : vector(pointArray[0][0]+(2.5)*millimeter, pointArray[0][1]+(2.5)*millimeter),
"sides" : 4
});
I want to extrude this polygon, but the function above returns a map and the opExtrude function needs a face or the edges of the polygon?
I want to extrude this polygon, but the function above returns a map and the opExtrude function needs a face or the edges of the polygon?
Tagged:
0
Best Answer
-
Hi @frederik_larsen108
The psuedocode for what you're trying to do will look something like this:var sketch = newSketch(context, id + "sketch", { ... }); // or newSketchOnPlane, doesn't really matter. skRegularPolygon(sketch, "polygon", { ... }); skSolve(sketch); opExtrude(context, id + "extrude", { "entities" : qSketchRegion(id + "sketch"), // notice the matching id + "sketch" here and above ... });
As a general rule FeatureScript functions which create geometry do not return the geometry they create. You get at the geometry they create by constructing a Query. Queries are constructed using functions that look like q<Something>().
https://cad.onshape.com/FsDoc/modeling.html
https://cad.onshape.com/FsDoc/library.html#module-query.fs
https://cad.onshape.com/FsDoc/library.html#qNothing
Another random Query example:// All the solid bodies in the part studio except the bodies created by the feature whose id is (id + "extrude1") qSubtraction(qBodyType(qEverything(EntityType.BODY), BodyType.SOLID), qCreatedBy(id + "extrude1", EntityType.BODY));
Jake Rosenfeld - Modeling Team5
Answers
-
Hi @frederik_larsen108
The psuedocode for what you're trying to do will look something like this:var sketch = newSketch(context, id + "sketch", { ... }); // or newSketchOnPlane, doesn't really matter. skRegularPolygon(sketch, "polygon", { ... }); skSolve(sketch); opExtrude(context, id + "extrude", { "entities" : qSketchRegion(id + "sketch"), // notice the matching id + "sketch" here and above ... });
As a general rule FeatureScript functions which create geometry do not return the geometry they create. You get at the geometry they create by constructing a Query. Queries are constructed using functions that look like q<Something>().
https://cad.onshape.com/FsDoc/modeling.html
https://cad.onshape.com/FsDoc/library.html#module-query.fs
https://cad.onshape.com/FsDoc/library.html#qNothing
Another random Query example:// All the solid bodies in the part studio except the bodies created by the feature whose id is (id + "extrude1") qSubtraction(qBodyType(qEverything(EntityType.BODY), BodyType.SOLID), qCreatedBy(id + "extrude1", EntityType.BODY));
Jake Rosenfeld - Modeling Team5

