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.
Anyone already wrote a feature script for "slotted bending" (sheet metal)?
jonaskuehling
OS Professional, csevp Posts: 16 PRO
Hey,
I am currently trying to write a quick feature script to transform a sheet metal bend corner into a "slotted bend" (like described nicely over at Hackaday a while back: https://hackaday.com/2016/05/18/the-art-and-science-of-bending-sheet-metal/ ). This can already be easily done manually by drawing a sketch with a slot pattern along the bend center line onto the flattened sheet metal part in order to extrude (remove) from the part, so I thought it should be pretty easy to be automated using feature script.
Now, my practice with feature script is limited so far and it would probably take me some effort to work my way through it the hard way, that's why I'd like to kindly ask if anyone already implemented something similar? Or at least would find a feature like that useful as well and would be interested in joining me to write the script together? After all I wouldn't want to reinvent the wheel if it was already done before
I assume the feature wouldn't need much more of an input rather than selecting the corresponding bend center line (the dashed construction line) and maybe additionally one of the tangent bend lines. From there I guess you can read out the related sheet metal part, the sheet thickness and then draw some slots along the center line according to your desired configuration. Llike illustrated in the Hackaday article linked above:
Looking forward to any help and/or interest in this
Regards,
Jonas Kühling
Jonas Kühling
Tagged:
0
Best Answer
-
jonaskuehling OS Professional, csevp Posts: 16 PRO@MBartlett21 @lanaAwesome, thanks a lot for your input!I've come a long way in the meanwhile and had to dive a little into sparsely documented feature script terrain with regards to sheet metal functionality it seems - nonetheless, learned a ton, the feature script is done and does everything I would have hoped for.I decided to make the document public in case anybody would like to just use it, build on top of it or get inspiration for similar feature script projects. The feature is called "smPerforateBend" or "Perforate sheet metal bend" and can also be found via the link here:While I tried to comment the code where possible, it might not be the most elegant solution in every way, but it's the solution I made to work In case anyone has suggestions on how to improve the feature, I'd love to hear.Regards,
JonasTags: Sheet metal, Perforation, Slotted bending, hand bending, manual bending4
Answers
Twitter: @onshapetricks & @babart1977
Jonas
Jonas
Here is a quick example of navigating from bend centerline to its geometry in flat https://cad.onshape.com/documents/31a6fe1973cd763943f93411/w/e4d5dc964f4b13c1c43380f5/e/464e02f4cf38942dbd62a644
to create sketch. You could use the flattened bend face as faceInFlatQ.
When you sketch on the flat, you need to use
newSketch
, rather thannewSketchOnPlane
, like @lana said above.To get the plane that you need to have you sketch coordinates relative to, use an
evPlane
on the face that you passed tonewSketch
An example of sketching on the flat is in the Calculate Bounds feature by @Jake_Rosenfeld here. The flat option on it sketches a rectangle on the flat pattern and optionally highlights it using
debug
.You could possibly look through the extrude.fs sheet metal flat code here to see how it does
smFlatOperation
s.IR for AS/NZS 1100
Jonas
That looks great!
Couple notes:
1. @NeilCooke pointed out that in order to be robust flatFaces query needs to be wrapped into qSheetMetalFlatFilter.
to ensure robustness of downstream references to perforation geometry.
4. If you look at extrude feature definition, you'll see that it has whole bunch of default parameters
that you don't need to specify when calling feature programmatically.
5. You don't need to make both body and centerlines parameters of the feature. You can find the body as qOwnerBody(topFace). There is a way to find all centerlines of sheet metal body as well ( if you want to have a simple ui to perforate all bends of sheet metal bodies, handling bodies from different models should be possible as well and will be an optimization). Let me know if you are interested in this option - I'll write something for you.I couldn't finally figure out why it is a problem being close to the edge with a cutout, though. Any thoughts on this?
Cool!
Would you be able to try adding the code below to the precondition? It will generate a better error when either of the queries are empty
IR for AS/NZS 1100
Sorry. I meant to place it directly after, just before you declaration for
var smattributes...
IR for AS/NZS 1100
Although the slightly more correct thing to do here is actually:
So that on hover, the errored feature reports to the user "Select bend lines" (which is the common grammar we use when there is a box that needs a selection).
@MBartlett21
I have just written a note internally to add a `verifyNonemptyQuery` overload that takes a raw string to throw instead of an ErrorStringEnum, to make it possible to do this. I think it would be useful in custom features.
I often have used this function in my custom features. Could you also add an overload that does not take an error parameter and instead just throws
ErrorStringEnum.CANNOT_RESOLVE_ENTITIES
?IR for AS/NZS 1100
My proposal is to use that code to replace the calls to `verifyNonemptyQuery`, and yes you would want a copy of it for each query that you want to verify.
@MBartlett21
Probably will not do that because it would be considered bad UX to throw CANNOT_RESOLVE_ENTITIES from a feature, instead of giving a specific string of what the user needs to select.
Twitter: @onshapetricks & @babart1977
External disambiguation is exactly the way I'd expect it to be. I don't think you need sketchIds and sketches arrays any longer either, you can use a local variable inside the loop. It might be easier to read if you set outside of the loop and use it everywhere.
I'll need to investigate the failure close to bend end. If you can share an example of such failure with me, it'll be great.
Here I've improved flat face query by wrapping it into qSheetMetalFlatFilter() and written allModelCenterlineEdges()
For the allModelCenterlineEdges() function.... When I'm using it to get the centerlines of a body like in the below image, it's giving me the the bendlines for all the other bodies as well.. I'm trying to use your function for a script that I'm writing so I'm hoping to get help on how to modify the function so that it gives me just the centerlines in the actual body that I select.. Thanks in advance