Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
2. Need support? Ask a question to our Community Support category.
3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
4. 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.

# Sheet Metal Fold

Member, OS Professional, Developers Posts: 1,953 EDU
I am in the middle of trying to make a FeatureScript that lets the user "fold" a sheet metal part.
However, I am having trouble determining the rotation axis once I have split the underlying sheet metal model.

I have modelled up a sample cross-section of a sheet metal part here

I have determined the rotation axis using a sketch, however, I would like to make a FeatureScript formula to get the location.
@konstantin_shiriazdanov , could you help?
MB - I make FeatureScripts: View FeatureScripts
«1

• Member Posts: 1,149 ✭✭✭✭✭

Hi, I found raius "r" which is the horizontal distance from rotation axis to the line of length "l1", so you can transform this result in terms of coordinates of the rotation axis origin. Is that what was needed?

• Member, OS Professional, Developers Posts: 1,953 EDU
@konstantin_shiriazdanov
Could you make it in FS code?
MB - I make FeatureScripts: View FeatureScripts
• Member, Developers Posts: 3,277 PRO
@konstantin_shiriazdanov
Could you make it in FS code?
Now you're starting to sound like me XD
• Member, OS Professional, Developers Posts: 1,953 EDU
edited November 2018
I'm assuming the angle is in radians.
Is that right?

Also, what are c and g?
MB - I make FeatureScripts: View FeatureScripts
• Member Posts: 1,149 ✭✭✭✭✭
Yes, in radians. In Featurscript you just need to get axis of the sketched fold line and transform it at the s+r distance in the direction, opposite to sketch plane normal.
• Member, OS Professional, Developers Posts: 1,953 EDU
@konstantin_shiriazdanov
What do c and g mean?
MB - I make FeatureScripts: View FeatureScripts
• Member Posts: 1,149 ✭✭✭✭✭
If you mean c and g in ctg(a/2) it is cotangens, you might know it as cot() function
• Member, OS Professional, Developers Posts: 1,953 EDU
edited November 2018
Oh ok.
In Onshape it is atan().

And i suppose tg() is tan()
MB - I make FeatureScripts: View FeatureScripts
• Member Posts: 1,149 ✭✭✭✭✭
Yes, its a miracle that when even triginometric functions have different names, we still can understand each other
• Member Posts: 1,149 ✭✭✭✭✭
Atan() should be arctangens, if it doesnt exist you can express it as ctg(x) =1/tan(x)
• Member, OS Professional, Developers Posts: 1,953 EDU
@konstantin_shiriazdanov

I have got it working in my part studio and here is the FS:
MB - I make FeatureScripts: View FeatureScripts
• Member, Developers Posts: 3,277 PRO
Nice guys!
• Member, OS Professional, Developers Posts: 1,953 EDU
PS: look in the flat before and after.
Nothing changes
MB - I make FeatureScripts: View FeatureScripts
• Member, Developers Posts: 3,277 PRO
Perfect
• Member, Developers Posts: 3,277 PRO
Are you going to add in bend side? or will it always be based on center of bend?
• Member, OS Professional, Developers Posts: 1,953 EDU
@john_mcclary
You should be able to use it for angles in the opposite direction now.
MB - I make FeatureScripts: View FeatureScripts
• Member, OS Professional, Developers Posts: 1,953 EDU
@john_mcclary

You just can't fold it directly from a flat face (I don't know why, so maybe @lana could help)
MB - I make FeatureScripts: View FeatureScripts
• Onshape Employees Posts: 609
You just can't fold it directly from a flat face.
Operations in flat are not very FS friendly. We'll try to improve that in the future.
• Member, OS Professional, Developers Posts: 1,953 EDU
@lana what i am meaning is from a sheet metal model without any bends
MB - I make FeatureScripts: View FeatureScripts
• Member Posts: 1,149 ✭✭✭✭✭

I have got it working in my part studio and here is the FS:
looks like you are going to compete with OS devs in the sheet metal features implementation rate
now you just left to add unbend capability for existing bends
• Member, OS Professional, Developers Posts: 1,953 EDU
edited November 2018
@konstantin_shiriazdanov
MB - I make FeatureScripts: View FeatureScripts
• Member, OS Professional, Developers Posts: 1,953 EDU
@lana
It doesn't seem to work if the edge selected to be "fixed" is on the face that is bent. (The edge's id seems to change internally after the sheet metal internal body is split)
MB - I make FeatureScripts: View FeatureScripts
• Moderator, Onshape Employees, Developers Posts: 1,639
@mbartlett21

Are you using split part or split face?  Split part has to create new tags internally because it creates a new body.  This should be somewhat stable due to our tracking, but once it goes through the sheet metal system it probable loses that associativity.  My recommendation would be to split the face, and then use move face-rotate to rotate the faces in question.  You may already be doing this, I haven't looked into the code.

re: hems, you found our big secret
Jake Rosenfeld - Modeling Team
• Member, OS Professional, Developers Posts: 1,953 EDU
@Jake_Rosenfeld
I am using split part, then boolean.

The reason I found out about the hems was because, when I updated my feature to FS Version 937, it told me that that symbol already existed.
MB - I make FeatureScripts: View FeatureScripts
• Member, OS Professional, Mentor, User Group Leader Posts: 2,097 PRO
@mbartlett21 I love your Fold SM tool.  I just tried it with an imported dxf, but found it was able to do the fold but failed on the flat pattern.
Engineer ı Product Designer ı Onshape Consulting Partner
• Member, OS Professional, Developers Posts: 1,953 EDU
@Jake_Rosenfeld
If i do this:
```var fixed = getSMDefinitionEntities(definition.fixedFlange)[0];
// Split the part ...
debug(qOwnerBody(fixed));```
It highlights the wrong side of the sheet metal part (the one that's going to be transformed)
MB - I make FeatureScripts: View FeatureScripts
• Member, OS Professional, Developers Posts: 1,953 EDU
edited November 2018
@brucebartlett
You will have to make a flange somewhere on the sheet metal and select that as the fixed part.
You can then use the bend feature.
Once you're done, you can do an extrude+remove on the flange (the sketch you use must include the bend)
MB - I make FeatureScripts: View FeatureScripts
• Onshape Employees Posts: 609
@mbartlett21
Sorry it took me some time to get back to you on fixed reference stabilization.
I did:

`<div>&nbsp;const bodyForTransform = evaluateQuery(context, qSubtraction(robustSMBodiesQ, qOwnerBody(fixed)))[0];</div><div> const bodyForTransformTrackingQ = qUnion([startTracking(context, bodyForTransform), bodyForTransform]);</div>`
And then used bodyForTransformTrackingQ in
`var wallAttFace = qIntersection([qOwnedByBody(bodyForTransformTrackingQ, EntityType.FACE), qEdgeAdjacent(edgeForTransform, EntityType.FACE)]);`

• Member, OS Professional, Developers Posts: 1,953 EDU
@lana Thanks!
I also had to make my own function remapCornerBreaksForSplitFaces to deal with the walls that were split (It is based on remapCornerBreaks)
MB - I make FeatureScripts: View FeatureScripts
• Onshape Employees Posts: 609
@mbartlett21
I also had to make my own function remapCornerBreaksForSplitFaces to deal with the walls that were split (It is based on remapCornerBreaks)
That makes sense.
Thank you for extending sheet metal functionality.