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.
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
-
Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646Hi @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
The psuedocode for what you're trying to do will look something like this:
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: