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.
Modeling a Square Tube in different ways to lear featurescript
emerson_bottero
Member, Developers Posts: 37 ✭✭
I think is the best when you can get something done in more than one way and feature script allows that. I don't mean to find the easy way, I want to learn from it.
1 - Create 2 square sketchs, Extrude both, remove the smaller from the biggest with Boolean. That one was easy!
--> Create 2 Sketchs
2 - Create 2 square sketchs, extrude the region in between. Couldn't query this region
3 - Create a sketch, extrude as surface, Thicken the surfaces. Couldn't Extrude as surface
--> Create a Sketch
extrude(context, id + "extrude1", {
Can Someone show how to make options 2 and 3 possible?
1 - Create 2 square sketchs, Extrude both, remove the smaller from the biggest with Boolean. That one was easy!
--> Create 2 Sketchs
skRegularPolygon(sketch1, "polygon1", {
"center" : vector(0, 0) * inch,
"firstVertex" : vector(1/2,1/2) * mysize,
"sides" : 4
});
skRegularPolygon(sketch2, "polygon2", {
"center" : vector(0, 0) * inch,
"firstVertex" : vector(1/2,1/2) * (mysize - mythick),
"sides" : 4
});
--> Extrude Both
extrude(context, id + "extrude1", {
--> Extrude Both
extrude(context, id + "extrude1", {
"entities" : qSketchRegion(id + "sketch1"),
"endBound" : BoundingType.BLIND,
"depth" : definition.myLength
})
extrude(context, id + "extrude2", {
"entities" : qSketchRegion(id + "sketch2"),
"endBound" : BoundingType.BLIND,
"depth" : definition.myLength
});
--> Booleans
opBoolean(context, id + "boolean1", {
"tools" : qCreatedBy(id + "extrude2", EntityType.BODY),
"targets" : qCreatedBy(id + "extrude1", EntityType.BODY),
"operationType" : BooleanOperationType.SUBTRACTION
});
opDeleteBodies(context, id + "delete1", {
"entities" : qCreatedBy(id + "sketch1", EntityType.BODY)
});
opDeleteBodies(context, id + "delete2", {
"entities" : qCreatedBy(id + "sketch2", EntityType.BODY)
});
2 - Create 2 square sketchs, extrude the region in between. Couldn't query this region
3 - Create a sketch, extrude as surface, Thicken the surfaces. Couldn't Extrude as surface
--> Create a Sketch
skRegularPolygon(sketch1, "polygon1", {
"center" : vector(0, 0) * inch,
"firstVertex" : vector(1/2,1/2) * mysize,
"sides" : 4
});
--> Extrude as Surface gives me this ERROR "throw EXTRUDE_NO_DIRECTION" |
extrude(context, id + "extrude1", {
"bodyType": ToolBodyType.SURFACE,
"entities" : qSketchRegion(id + "sketch1"),
"surfaceEntities" : qCreatedBy(id + "sketch1"),
//"direction" : evOwnerSketchPlane(context, {"entity" : qSketchRegion(id + "sketch1")}).normal,
"depth" : definition.myLength,
});
--> Thicken the surfaces (couldn't test)
--> Thicken the surfaces (couldn't test)
opThicken(context, id + "thicken1", {
"entities" : qCreatedBy(id + "extrude1", EntityType.BODY),
"thickness1" : 0.1 * inch,
"thickness2" : 0.1 * inch
});
Can Someone show how to make options 2 and 3 possible?
Tagged:
0
Comments
3. - pass "surfaceEntities" : qCreatedBy(id + "sketch1", EntityType.EDGE) , no need for "entities" field to extrude.
We recommend using opExtrude in feature script instead of extrude for better performance.
2 - you nail it. I'm using opExtrude.
3 - using extrude because didn't found BodyType option in opExtrude.
Didn't work and I could'n find why, I still get EXTRUDE_INVALID_ENTITIES. But
Worked but it forms an SOLID, not SURFACE Body, I debug the query and both are working.
opExtrude doesn't need BodyType option. If you pass it edges in the "entities" field, it will make surfaces:
https://cad.onshape.com/FsDoc/library.html#opExtrude-Context-Id-map
If you post the URL of your document here, we'll be happy to take a look at why that extrude() is failing.
here it is.
https://cad.onshape.com/documents/04194902b685ea2fdd1ea39e/w/d56fefaa6afcbf2753009eeb/e/4fc1173c8bd6628cd5713f2e
I did what I never saw in the documentation but I use ons sub-node of the LookupTable as valuewithunits, works as long as the entry has units in it.
You have it pinned down when you ask "Shouldn't this be 4 edges, not 8?" Due to the way our sketching system works, there are actually two sets of edges created when you sketch: the wire bodies that you directly create in your sketching operations, and the edges around the sketch regions that you create indirectly.
Long story short, the query that you want is:
qOwnedByBody(qBodyType(qCreatedBy(id + "sketch1", EntityType.BODY), BodyType.WIRE), EntityType.EDGE);
a.k.a. "All the edges of wire bodies created by the sketch operation"
edit1: I did this and it worked.
and used like that.
A correction from my coworker: qBodyType actually happily filters entities based on the body type of their owner, so a simpler Query is:
Nice function!