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.
Wires from Edges? Suggestions?
EvanReese
Member, Mentor Posts: 2,135 ✭✭✭✭✭
I'm trying to create a FS that will create a wireframe from the edges of a solid body (with only planar faces). What I want is for it to start like the body on the left and end up like the part on the right:
Here's a link to this model. I think that the FS operation would just automate the way I did this in the feature tree of the part called "Desired Outcome". Here's a summary of the basic operation steps I'm imagining. I'm new to FS and coding in general, and this is an exercise to help me learn, so let me know if this logic makes sense:
UI inputs:
Here's a link to this model. I think that the FS operation would just automate the way I did this in the feature tree of the part called "Desired Outcome". Here's a summary of the basic operation steps I'm imagining. I'm new to FS and coding in general, and this is an exercise to help me learn, so let me know if this logic makes sense:
UI inputs:
- select body
- wire depth
- wire width
- select all faces belonging to body
- new sketch on those faces (this is where i'm a bit lost. How do I select the planar faces from the body and sketch on them?)
- offset the edges of the faces by the "wire width"
- solve sketches
- hollow the part with opShell = to "wire depth"
- opExtrude all of the sketches into the part by "wire depth" (possibly add 1-2 mm as a buffer)
- opBoolean to subtract it all from the body
- delete all of the sketches.
Evan Reese
0
Comments
I think your current plan going to run into some trouble at step 3: Using/offsetting sketch geometry. Right now, both "Use" and "offset" in Onshape are functions that generate FeatureScript (creating sketch entities and constraints), rather than calling a FeatureScript function. This means it will actually be pretty non-trivial to make a good use/offset tool in FeatureScript right now. Eventually, we do want to make built-in functions that do this stuff (so users don't have to), but that addition has yet to be prioritized.
In the meantime, FeatureScripts 3D tools are a bit more fleshed out than its 2D tools, and you should be able to get the geometry you want without making sketches at all. A good possibility I can see:
- Query all faces of the body
- For each face, extrude it inward by the wire depth, remembering each extrude body
- For each extrude, thicken its non-cap faces inward by the wire width
- Subtract that thicken result from the extrude (giving you the desired offset punch-out)
- Shell the original solid
- Subtract the shrunken extrudes
Does that get you the result you want?thanks for the answer. I think that makes a lot of sense. I'll probably try what you're describing manually first to wrap my head around the function, but it sounds like it would produce an identical result. Then I'll take a stab as writing the script and probably post back here when I hit a snag.
I think where I'm getting hung up is in some of the basic aspects of FS (and code in general). I understand, at a high level, that I want to query the faces of the body, then extrude them in a direction normal to the faces, but I don't know how to set that up. I understand how to extrude one face in one direction, but I'm having a hard time understanding how to extrude all faces in different directions.
Am I anywhere close with this?
// extrude faces inward
I like to think of a Query like faceQuery as an order form for "all the faces belonging to this body" (which can change if your feature modifies that body), while the evaluated query is a list of entities in the context that satisfy the Query right now. Most of the time you can just pass around queries, but if you need the list (to see how big it is or loop through it), evaluateQuery is the tool for the job.
thanks, the evaluateQuery and "for loop" are what I needed for the extrude (or thicken). I've got that working well now. This leads me to some new questions:
1. I've got an extrude and I want the non-cap faces, as you said. I'm trying to find them like this, but it seems to be missing something to work:
2. the "qCapEntity" function says it can do extrudes, revolves, sweeps, and lofts. could I do something like this for opThicken? In thinking about this feature more, I would like to be able to use it for bodies with non-planar faces as well. Thicken would give me that.
by the way, I appreciate your instructive style. You're giving enough info for me to explore and be challenged, but not just leaving me hanging by telling me to "read the documentation". That's helpful. (though, please point me to relevant documentation, as you have been).
We do track cap entities for opThickens, so that should work the same.
I'm this close! I've got the for-loop working right. I'm looping opThicken on each face and looping opOffsetFace on all of the non-cap faces of the thickened bodies. I've also got the main body hollowing out perfectly. Works like a charm. (here's the document link, btw)
My last hangup is in finding the right way to query those bodies that I made with the for-loop. I'm trying qCreatedBy and putting the feature IDs in, but nothing seems to happen. Debugging that query turns up nothing either (further indicating that nothing is happening). Does this have something to do with the "i" variable in the for-loop giving each loop of the opThicken a different ID? If so, I'm not sure how to access them. Or is there a sneakier query to get at them?
Thanks for all of your help so far!
The way to solve the problem is to use id + "thickens" + i + "thicken1" instead of id + i + "thicken1" and then qCreatedBy(id + "thickens") should resolve to the lot.
Try changing the opThicken part of your code to this:
Basically just collect all your bodies you are creating as you create them. Additionally the <id + ("thicken" ~ i)> thing is a minor tweak to simplify your ids a bit (the ~ operator is a string append). You may not need to add the qCreatedBy(offsetFaceId, ...) to relevantGeometryQueries, I'm not sure if offset face alters bodies or creates new ones internally. Experiment and you'll probably be able to get away with just one of those.
Hope this helps!
EDIT: Thanks Ilya! That's much easier than my way.
Thank you both for the input.
Jake, you're saying that by using ("thicken" ~ i) I'm essentially going to output "thicken1", "thicken2", thicken3" etc. am I understanding the string append right?
Ilya, would it be right to think of the id hierarchy as similar to a basic set of folders and sub-folders? Is that a useful mental model?
Also, I made the feature id to be Then I used
When I debug inside of the for-loop I get just one instance of the opThicken (which I think makes sense. It's just getting one instance of the loop, right?). If I debug outside of the for-loop, I get nothing. Thoughts?
The problem now is that opOffsetFace is failing (you can see that as the error) because the id there is still id + i + "offsetFace1". If you change it to id + "thickens" + i + "offsetFace1", it'll work (and because opOffsetFace does not create any bodies, your query will be fine). The folders are a useful mental model -- except that (and this is the problem in this case) once you "close" a folder by starting to put something into a different folder, you cannot reopen it again...
I may eventually add a button to link width and depth dimensions and set dimension defaults to 5mm instead of 25mm, which is a good starting place for 3D printing. I'll work on those a bit in the next few days and report back if I get stuck. Thanks, folks!
thanks for the help!