Sheet Metal Workbench

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
jan
Posts: 13
Joined: Sat Sep 12, 2015 12:13 pm

Re: Sheet Metal Workbench

Post by jan »

First post here, please bear with me.

Shai, your sheet metal workbench is really handy, straightforward and simple to use. Apparently there's another in the works, but I needed one now, yours is here, and it mostly did the trick for me. I also liked its simple code, as that has helped me to get started with hacking on FreeCAD modules. Somewhat.

The attached patch adds a new property "lenfixed" to its bend objects.

Rationale:

I found the workbench's functionality impractical for bigger projects, since it's not possible to nail the total outer width of an object to a given value. In most cases, a part's outer dimensions are what I'd like to define when designing sheet metal parts, but these dimensions are hardly predictable with the current implementation. The patch does just that. It predicts the space a bend is going to take up and squeezes a suitable pad between the unbent leg and the bend until the specified total extent is taken up by the whole pad-bend-leg-thingy.

"lenfixed" defaults to zero, which should give a backwards-compatible behaviour, i.e. a bend unrestrictedly growing out of a selected face. If a non-zero lenfixed is specified but doesn't cater for the whole assembly with given radius, bent leg and all, an exception is thrown.

I was somewhat iffy about the attribute's name "lenfixed", it admittedly sounds clumsy. Maybe a native speaker could help out. The term does, however, allow a "lenfree" or "lenbent" or so to be introduced at a later point, which could equally clamp the dimension perpendicular to the base plate to a defined value. I might do that, too, I wanted to try and see first if this patch gets accepted.

Does it look mergeable to you?

Jan
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Sheet Metal Workbench

Post by jmaustpc »

jan wrote:First post here, please bear with me.
Your first post, welcome to FreeCAD. :-)
User avatar
shaise
Posts: 486
Joined: Thu Jun 11, 2015 8:11 am

Re: Sheet Metal Workbench

Post by shaise »

Jan,

No need to rationale this, as I agree this type of feature is very important, and in fact I was planning on doing it my self. Anyway this thing poses some problems when adding bends that because of the fix length collide with others. I will take a look at your solution, If it is handling all these issues, I will gladly merge it.

shai
jan
Posts: 13
Joined: Sat Sep 12, 2015 12:13 pm

Re: Sheet Metal Workbench

Post by jan »

This thing poses some problems when adding bends that because of the fix length collide with others. If it is handling all these issues, I will gladly merge it.
Thanks Shai. I don't see how there could be geometrical collisions with other bends, since "lenfixed" only constrains the bend itself. BUT:

Some more testing reveals a problem with my patch. Compared to the original implementation the patch changes the order in which things happen. The resulting solids are equal - except for the face names. Which breaks drawings saved without the patch, because face names are stored with the drawing.

Please let me have a look into this again before you waste your time on it. I'll post an updated version as soon as I have an idea on how to tackle this.
User avatar
shaise
Posts: 486
Joined: Thu Jun 11, 2015 8:11 am

Re: Sheet Metal Workbench

Post by shaise »

Jan,

I played with your implementation, Indeed it gives some advantage, but it was not what I thought off.
First of although the length stays fixed, the height changes each time you change the radius.
Second, lets say you start with an 80 by 80 plate and add a fixed 10mm bend on each side to get a 100 by 100 box. The spacing between the walls an in the corner are too big.
What I was thinking off, is if I know I want a 100 by 100 box, I will start with a 100 by 100 plate, and each bend will "cut" from the original plate such that the it will stay 100 by 100. In this case instead of another "lenfixed" parameter, you just need to add a Boolean that's determins if you use fixed length or not. this way, in the case of fixed length, the height will also be set to fixed.
This is where collisions might occur if you want to bend several sides. (they cut one over the other)
Another issue to take into account, is what will be the behavior when the bend is not 90 degrees.

Regarding backward compatibility. This is an important issue, specially if you add parameters.
You must take 2 things into consideration:
1. there are no edge "names" only list of edges which get an automatic "EdgeX" name based on its position in the array.
2. old models loaded must be detected and a new "lenfixed" parameter added to them so it will no crush when looking for this missing parameter.

shai
jan
Posts: 13
Joined: Sat Sep 12, 2015 12:13 pm

Re: Sheet Metal Workbench

Post by jan »

Thanks very much for your feedback!
First of although the length stays fixed, the height changes each time you change the radius.
Yes. That's a feature my implementation shares with yours. Leaving that untouched for now was an intentional choice, see my first post. I find "height" ambiguous for restricting the bent leg, but I proposed to introduce "lenbent" for that second parameter at a later point, as opposed to "lenfixed" for the fixed leg.

Let me add a drawing to clarify the terms.
bend.png
bend.png (17.86 KiB) Viewed 6797 times
The base solid is yellow, "radius", "length" and "angle" are status quo parameters, "lenfixed" and "lenbent" are what I'd like to add, with "pad" being squeezed in automatically.

I chose to try and introduce "lenfixed" and "lenbent" incrementally, because:
  • a) "lenfixed" in itself is already an improvement over the current situation, and I have trouble seeing how a parameter of sorts could be avoided in the future anyway, see below. Currently, a bend will take up 21.7543 mm, depending on radius and length. With the patch, you can nail that to 20.0 mm lenfixed off the base face and go from there.
    b) "lenfixed" is lenbent's prerequisite, but it can be implemented independently.
    c) "lenbent", while mathematically easier without 3d-rotation, will clutter your code beyond recognition with a distinction of cases (< 90°, 90°, overbent)
    d) "lenbent" will introduce an overconstrained situation between the parameters "angle", "length", "lenfixed" and "lenbent" which needs to be discussed. My plans for the semantics were:
    - as long as there are enough parameters lenfixed or lenbent disabled (i.e. equal zero), solve it
    - as soon as an overconstraint is specified, make "length" the dependent variable, and have FreeCAD adapt it accordingly
    This way, the current semantics of "length" would be mostly left intact. As good as it gets.
Second, lets say you start with an 80 by 80 plate and add a fixed 10mm bend on each side to get a 100 by 100 box. The spacing between the walls an in the corner are too big. What I was thinking off, is if I know I want a 100 by 100 box, I will start with a 100 by 100 plate, and each bend will "cut" from the original plate such that the it will stay 100 by 100. In this case instead of another "lenfixed" parameter, you just need to add a Boolean that's determins if you use fixed length or not. this way, in the case of fixed length, the height will also be set to fixed. This is where collisions might occur if you want to bend several sides. (they cut one over the other)
I see. Let me try to respectfully win you over to my approach, as it avoids the problem altogether and leaves collision resolution to the user. Bends are created as seperate animals within your workbench, and I find that a good thing. Why make them depend on one another? It would break the semantics of adding independent bends. I'm very new to FreeCAD, but it would seem to me that this would also break the typical FreeCAD way of doing things.

In my book, a bend is a bend is a bend. If I were to make a part by hand, I would want a drawing with dimensions spanning the whole part. That's because putting a calliper around the whole thing is easier than finding the line where a bend starts. But for modeling? I fail to see how blending multiple bends into an interconnected entity could integrate well with a generic workflow. For your example, I would design an 80x80 base plate and add two bends, each of them constrained to 10 mm lenfixed, job done. But then again, maybe that's just my lack of imagination.
Another issue to take into account, is what will be the behavior when the bend is not 90 degrees.
Yeah, seconds my point, I'd say. The patch already handles over- and underbent legs in a sensible way, have you tried?
Regarding backward compatibility. This is an important issue, specially if you add parameters.
Agreed.
You must take 2 things into consideration:

1. there are no edge "names" only list of edges which get an automatic "EdgeX" name based on its position in the array.
Hm. No edge names involved, but there are face names stored with a bend object, see Document.xml in the .fcstd-file:

<Sub value="Face6"/>

That's the name of the base object's face the bend grew out of. Your workbench bases all of a bend's existence on that name. Now, if you have Bend2 hanging off Bend1, and Bend1 has changed its face names during Save - Restart FreeCAD - Open, Bend2 will try to grow out of the wrong face upon redraw and fail miserably. I've changed the patch to replay the order of fuse operations of the original implementation, and that seems to work. Not sure though if that will guarantee deterministic face naming under all circumstances, also given that I optionally want to fuse in the pad solid in the process, but for the few older drawings I have, it worked.
2. old models loaded must be detected and a new "lenfixed" parameter added to them so it will no crush when looking for this missing parameter.
You are absolutely right, that's a bug in the last patch. The attached updated patch hopefully fixes that. I added compatibility checks to SMBendWall.execute() and SMViewProviderTree.attach(), which did the trick all situations I have tested. That might well be overkill or the wrong places, though. FreeCAD's API is still lots of guess-work for me, I must admit.
Attachments
fc-sheet-metal-add-lenfixed-20150915.patch.zip
Cleaned-up patch
(2.14 KiB) Downloaded 118 times
User avatar
shaise
Posts: 486
Joined: Thu Jun 11, 2015 8:11 am

Re: Sheet Metal Workbench

Post by shaise »

jan wrote:For your example, I would design an 80x80 base plate and add two bends, each of them constrained to 10 mm lenfixed, job done. But then again, maybe that's just my lack of imagination.
Hi Jan,
Indeed for a single direction bends, your system works very well. However when it comes to multiple directions its not optimal. Going back into my example, if you start with an 80x80 base plate, and add four bends to make a box, you are left with 10x10mm missing corners. lets say the sheet thickness is 2mm and your bend inner radius is 1mm, in this case the bend total width is 3mm, so, the optimal base is 94x94mm that leaves you only 3x3mm missing corners. this means the optimal base size must take into account the bend radius to get optimal results, making lenfixed in this case redundant, because you will have to recalculate the optimal base size each time you change bend radius or sheet thickness. (Hopefully, I explained myself correctly)
<Sub value="Face6"/>
Faces are exactly like edges. Though it is marked as "Face6" it is still the sixth face in the face array. It will indeed stay the same face location when saving and loading fcstd - this is good, but sometimes when you play with the base object parameters, it might reorder the faces moving "Face6" to another location. (for example, lets say you have en extruded sketch as a base and you added a bend to one of its faces. Later on, you decided to add a hole into the base sketch. In many cases when you apply the change, your bend will suddenly move to another face, because the added hole reshuffled all face names)
But this is an inherent FreeCAD issue, so there is nothing much to do about it, just to take this into account.
FreeCAD's API is still lots of guess-work for me, I must admit.
Same here...
That's why I want you to please wait with your patch until I finish fixing the current version which is buggy. There is a function "valueAt" for edges which returns a 3D point along the edge. I was under the impression that this function accepts values from 0.0 to edge.Length(), and many of my calculations where based on this, but it seems that this is not always the case. Values are from "FirstParameter" to "LastParameter", and now I'm the middle of going through all the code and fixing that.
When I'm finished I will notify in this thread.
User avatar
shaise
Posts: 486
Joined: Thu Jun 11, 2015 8:11 am

Re: Sheet Metal Workbench

Post by shaise »

Hi all,

I have updated the workbench with several bug fixes. Thank to user deveee, I found out that on several specific scenarios adding bends produced errors or strange parts.
Updated workbench: http://theseger.com/projects/2015/06/sh ... r-freecad/
Source: https://github.com/shaise/FreeCAD_SheetMetal

shai
User avatar
shaise
Posts: 486
Joined: Thu Jun 11, 2015 8:11 am

Re: Sheet Metal Workbench

Post by shaise »

Hi Ulrich,

It seems some sheet metal with 180 degree bends does not unfold correctly. Can you look into it?
Here is a sample: http://theseger.com/projects/wp-content ... unfold.zip
Githup issue: https://github.com/shaise/FreeCAD_SheetMetal/issues/2

shai
Lablab
Posts: 4
Joined: Sat Sep 19, 2015 5:02 am

Re: Sheet Metal Workbench

Post by Lablab »

I think you have made the right choice and I also hope you can find the way to make some money with it (I read the other threads). I do not need funding myself, but I think it would be great to find a way so that paid development produces LGPL code for FreeCAD.
Post Reply