Simulate Sheet Metal Bending...

Blitz3D Forums/Blitz3D Programming/Simulate Sheet Metal Bending...

hollifd(Posted February) [#1]

I am looking for a way to accomplish this…
1. Import a 2D DXF CAD file – I have already completed this!
a. This is a “flat” top down view of a unfolded 3D sheet metal part.
2. Identify certain lines on this top view as being “bend” lines – I have already completed this!
3. For each bend line, input an angle to bend Ex: 90, -90, -30, 72, etc. – I have already completed this!
4. Give the 2D flat a thickness Ex: 0.070 inches. – Need help!
5. Tell the 2D part to transform itself into the 3D “folded up” view. Allow the user to set the order of bending up. Show some bends flat while others are bent. Need help!



I was wondering if there is an easy way to attach a joint to the "bend" lines to allow this "bending" to occur. I am looking for some ideas on how this is done in the videos. I can't find any information on how it is accomplished. I want to create my own simulation software that will allow me to simulate the bending process so I can reduce machine setup time in our shop.

Here are some YouTube videos showing what I want to accomplish...
[https://www.youtube.com/watch?v=gZRaOqOEpGE]
[https://www.youtube.com/watch?v=GRfvSPbrMHA]
[https://www.youtube.com/watch?v=PBVmk4eRLU0]

Thanks for any help,
David


RemiD(Posted February) [#2]
You could create a pivot (=a 3dpoint) at a picked position on the surface of the metal sheet, and use this pivot to define where the bend would be.
Then you would have to subdivide (=add more vertices and triangles) the metal sheet where the bend needs to happen.
Then you would have to write a procedure to recalculate the vertices positions of the metal sheet depending on the state of the bend.
Not the easiest thing to do, but doable.
I hope that you are not afraid of maths formulas and vectors !


Kryzon(Posted February) [#3]
Blitz3D doesn't allow you to create or edit joints. It only loads joints from a B3D file. It's pretty rudimentary.

You'd have to code your own way of deforming vertices.


skidracer(Posted February) [#4]
The math for this problem is pretty interesting.

http://www.cadalyst.com/cad/autocad/bend-it-like-expert-13664


hollifd(Posted February) [#5]
I am familiar with the math to calculate the flat sheet dimensions of the unfolded part. I cannot seem to wrap my brain around how to fold / unfold the part using code. Currently, I can read a CAD file (DXF format). Drawing the flat sheet on the screen, rotate it, flip it, and move it around but cannot figure out a way to have it fold back up. I have been thinking about this problem for many years and wonder how it is done. I thought maybe some of you folks might know how it is done or be able to figure it out. I know it is not a video game but I know there are some very smart people here that have helped me with this project in its current state (2D only).

RemiD seems to have an idea how it is or can be done. I am not that good at math. I am a weekend hacker and not a professional programmer. I work in a sheet metal shop and am trying to figure out ways to improve our processes and do some machine programming "offline" so the operators don't have to do it at their machines keep them from making more parts during the day. With help from a lot of you, I have created a very good working 2D version of this tool and would like to add the 3D functionality that would allow us to simulate the machine, tools, and parts in 3D. I have just not been able to get a simple solution for the 3D folding and unfolding.

Currently, to draw the 2D flat part, I have an array holding all of the lines, circles, and arcs that allow drawing of the 2D flat. If I add lines to the array that represent the locations of the bends, so when I use code to loop thru this array, I am not sure how I can tell certain lines that they belong to a certain bend and other lines belong to another bend. So when I try to rotate the coordinates of lines that are related to a bend, only the lines in the array related to the bend get rotated. I am murdering this explanation but perhaps some of you might understand the problem I am having.

RemiD,
If I know which of the lines in my array are designated as the bend lines, and I know the angle in which to bend, does this make it easier to implement your idea? Imagine an array of lines, circles, and arcs. Some of the lines in the array will have a flag of some sort that signifies that this line is a bend line. It will also have data for the bend angle. Does any of that simplify things or is it still really complicated?

Thanks,
David


skidracer(Posted February) [#6]
My guess would be that you will need 2 plane equations based on the line equation and angle of bend.

1. Split the shape into two separate meshes A and B with shared common edge created using a new set of "weld points"

2. For all verts in A (on the bent side) transform so they are relative to their plane, and then transform again into bent plane space.

Hopefully floyd will be along shortly to address the problem properly:)


Floyd(Posted March) [#7]
Depending on how complex the original flat, unfolded model is this could be quite difficult.

But let's suppose that somehow for each bend line you can decide for each vertex which side of the line it is on.

Then when bending around the line you want to leave vertices on one side fixed while rotating those on the other side around the line. I think this can be done without any calculation.

To turn around one of the bend lines do the following:

Create a copy of the mesh you are going to deform. We will operate on this copy.
Attach a Pivot to one vertex on the bend line.
Use AlignToVector to aim one axis of the pivot at another vertex on the bend line. Let's say we use the Z axis.
(Now the pivot is on the bend line and its Z axis points along the line.)
Use EntityParent to make the pivot the parent of the mesh.
Turn the pivot by the desired angle around the appropriate axis. This drags the mesh along with it.

This has turned the entire ( temporary copy ) mesh. The new vertex locations can be copied from the rotated temporary mesh to the corresponding vertices in the original. You would "read" positions in the temporary mesh with VertexX() etc. and write them into the original with VertexCoords. Do this for all the vertices on the side of the line which is to move.

I haven't written any code but this seems like a workable scheme, provided you have a way to decide which side of the bend line each vertex is on.


hollifd(Posted March) [#8]
OK. Currently, my tool is 2D only. I am drawing 2D lines on the screen. Your solution seems to be working in 3D. I do have a very old version of my tool in 3D that I might be able to resurrect and experiment with. I am not really a game programmer so I'll have to do some learning about the things you are describing. I'll check the help files.

Do you have any ideas how this can be accomplished in the 2D world? I have all of the coordinates for every line that I am drawing loaded into an array and I am looping thru that array to draw the stuff on the screen.

Also, the flat shapes that I am working with can be very complex...lots of edges, holes, arcs. Image things like the sheet metal cage inside of your computer that holds all of the components. Now image flattening this cage out from a 3D cage into it's flat sheet. These are the types of flats that I am needing to work with. Perhaps, if I could have a way to do a simple part, then I might be able to figure out a way to do more complex shapes.

Thanks,
David


skidracer(Posted March) [#9]
Just thinking out loud:

For each bend line you have priority of order and angle.

Cut each piece out. With each, selecting highest priority edge, change origin of piece to left end of edge (using CW rule) and add a virtual "hinge".

Once all pieces have been oriented with hinges @ 0,0 THEN use child parent entity relationship to glue pieces together and select entityyaw I think to animate the solution.


This solution could also be used for origami and paper model building perhaps.

My preferred method of constructing cardboard boxes would be to use multiple bends and angles so as to hatch a self reinforcing bottom and top - a hard concept to explain without said diagram.


RemiD(Posted March) [#10]

Blitz3D doesn't allow you to create or edit joints. It only loads joints from a B3D file.


with the addons by Bobysait (vB.002), it is possible to create joints/bones and skinnedvertices and set the influences (weights) of some joints/bones over some vertices.
See : http://www.blitzbasic.com/Community/posts.php?topic=105408


Kryzon(Posted March) [#11]
On second thought, Blender can load DXF: the importer is built-in and official.
Is there any reason why you can't make a Blender scene all with the proper units and grid snapping configured, import your DXF designs and then do what you want in there (animating the folds)?
This software has accumulated improvements over time on navigation and usability, you'd have to go through the same if you coded something original.

Time is really the most valuable resource you have. You can literally start tomorrow training everyone at using Blender.


hollifd(Posted March) [#12]
OK. I'll have a look at Blender. I am not a game programmer and am not familiar with it. It would be great if it is possible to quickly and easily add some hinges to a flat part and then be able to animate those hinges later in Blitz.

Ideally, I would like to quickly add some hinges in the appropriate locations on my DXF part. Name each hinge as bend1, bend2, bend3 etc. Then be able to tell each (or a specific bend) of those hinges to animate from 0 degrees (unbent) to the maximum or final angle.

Perhaps, I will start trying to make a simple model with Blender that is say 6 inches x 4 inches x 0.070 inches thick. Then, I'll figure out how to add these hinges to create bends along each of the ends of this rectangle. Then, I am guessing that I need to export out a model that can be opened in Blitz, Then write some code to tell the hinges to bend / unbend.

After getting a solution for bending / unbending the part, I will need to model the machine and tooling that bends the part. I think I can figure those out on my own.

Thanks for the help.
David


RemiD(Posted March) [#13]
If the "bending" happen at a position following a ruler (for example each 1mm, or each 1cm or each 1dm) it is quite easy to do, you can use a subdivided metal sheet (= a subdivided cuboid), then choose a point on the sheet, and choose an axis around which to bend the sheet (preferably around one of the global axises (x or y or z), then position a pivot (like a joint) at this position, then rotate the pivot with the wanted orientation, then recalculate the positions of the vertices using tformpoint() (since you know the position of each vertex related to the pivot before the "bending" happens (=before the pivot changes its orientation), you can then use tformpoint() to find the new position of each vertex during/after the "bending", considering the new orientation of the pivot)

No need for Blender, no need for a rigged skinned mesh...


hollifd(Posted March) [#14]
RemiD,
Sounds like a good working idea. Not having to add another tool (Blender) to the mix would be good. I am not a game programmer and don't really understand everything you suggested. Could someone viewing this provide a simple example...a rectangle with a bend in it?

I am not sure what you mean by subdivided metal sheet. I am assuming that you mean a sheet metal part where each of the bends has been separated from the rest of the part and then you can "attach" these separate pieces back to the rest of the part with a "hinge".


RemiD(Posted March) [#15]
Give me an idea of the width, depth, height of the sheet, and the minimum unit that you plan to use to make the bends (1mm ? 1cm ? 1dm ?),

And i can provide a subdivided mesh of a flat sheet and maybe a code example to demonstrate the use of a pivot + tformpoint() to recalculate the position of a 3dpoint (in this case the vertices of the sheet) depending on its initial position and depending on the pivot orientation.

It would be easier to use a premade rigged skinned mesh, but it would take time to create. (i suggest to use Fragmotion to do that, the exported b3d file is clean)


Kryzon(Posted March) [#16]
Here's a Blender scene if you're interested:



http://pasteall.org/blend/index.php?id=45841

The sheet is flat, but is given thickness with the Solidify modifier, and the bending\folding happens with the use of a Hook modifier (represented by the green cuboid, there could be several hooks, one for each folding part).

Good luck.


hollifd(Posted March) [#17]
RemiD,
Our sheet metal parts range in size of about 1 inch square up to 48 inches by 96 inches. The thicknesses range from 0.020 inches thick up to 0.500 inches thick. As for the minimum unit to make the bends, the shortest bend would be about 5 mm. So if you took a flat sheet of steel and bent up one edge, the height of that bent area would be 5 mm or longer. Hopefully, that is what you were asking about. If you were talking about the smallest feature we might have on a sheet metal part, then we have certain features on sheet metal parts that are small as 0.007 inches.

As for the premade rigged skin mesh...I am not completely sure I know what you are talking about but I have a CAD system for the 3D models. I can export those CAD models to various formats. Does that help and if so, what is the best format to make this easiest?

Kryzon,
That looks impressive and exactly what I am trying to accomplish. How did you get that model? Create it yourself or find it on the web somewhere?

Let's see if I understand how it works. You found a model or created a model in Blender. You added a "Hook modifier" at each bend location on the model and entered some properties. All of this allows the bending and unbending. I am assuming now that you can export this model from Blender into Blitz and write some code to allow the user to set the angle for each and every bend on the model and see what it looks like? For example, if the part had 4 separate bends on it. The user could set 3 of the 4 bends to 90 degrees and the 4th to 0 degrees and view the results? Then the user could set the 4th bend to something like 45 degrees and then view the results? Is that how it would work?

For a model having 10 bends, how much time would it take to apply this "hook modifier" to them in Blender then export it out so that it could be used in Blitz?

...and to all of you guys...Thanks for all of your time helping and offering ideas. I am not quite sure why you do it.

Thanks,
David


RemiD(Posted March) [#18]
@hollifd>>"subdivided" means that the shape is structured in a way that the "bend lines" already exist on the shape.


The solution proposed by Kryzon seems interesting, maybe try it...


What kinds of shape the sheet will have ? Obviously it will be flat but what do you want to bend ? A square/rectangle shape or some arbitrary shape like a symbol/thing ?


hollifd(Posted March) [#19]
"subdivided" Got it now. Yes. My current 2d solution is drawing shapes with lines, arcs and circles. Some of the lines are designated as "bend lines". As for the shapes, they can be as simple as squares or rectangles. They also can be very complex with many sides, various holes in the shapes. Sometimes, the bends cross some of these holes. Kryzon's example above is a very simple example of the shapes we are working with. They can be much more complex though.

I will download Blender and see if I can duplicate what Kryzon has created to see if it might be a solution. I am really hopeful for a solution that does not involve another piece of software we will have to learn and utilize. Your (RemiD) idea seems more appealing if it can work.

Here is an image I found that might help communicate the types of flat sheets I am working with.



I can get either a 3D unfolded model of a part similar to the picture above or I can import the 2D DXF file and display this flat sheet on the screen in 2D. In any case, I would want to provide some way to allow the user to provide some information about each bend and then be able to tell the software to fold up the flat sheet according to the information the user has provided. Does this help your understanding of my problem?


hollifd(Posted March) [#20]
OK. I have Blender installed. I imported a flat .3DS file and am trying to figure out how to add the cube and then apply the hook modifier. I am not able to figure it out. I did add a cube to my model and located it where I want to create the bend. Not sure if this is what I needed to do or not. Can't figure out how to add the hook. There are too many windows and I don't yet understand how everything works. Can someone point me in the right direction.

Thanks,
David


Kryzon(Posted March) [#21]
In my post there's a link to the .blend scene file that has that animation. You can open it in Blender.
But you need to study the program to some extent or you won't know how to navigate, modify objects and meshes, apply modifiers etc.

This is a great way to start: https://gumroad.com/l/blendingawaythepain
It's a pay-what-you-can (meaning, you can insert $0 if you don't have cash) course on starting with Blender.

Besides that one:

• The Blender documentation (I had to look at this to know how to use the hook modifier properly, so you're always gonna use it).

• Google searches for "Blender how to [...]" which usually lead to StackExchange threads with good answers.

• This cheat-sheet for the default keyboard shortcuts: https://i.imgur.com/E42hJ7I.jpg

• This forum for users, plenty of helpful people there if you can word your questions right: https://blenderartists.org/forum/forumdisplay.php?7-Support

edit: Also, make sure to change the "Select with" mouse button configuration to "Left" so left-click selects things, like in most software. Blender's default selection works with right-clicks and may feel unusual.

The more things you do directly in Blender (fold visualisation, animation etc.) the less work you'll have to do outside, obviously.


hollifd(Posted March) [#22]
OK and Thanks for the helpful links. I had a frustrating time last night trying to figure out how to navigate Blender to test this idea out. I'll have a look at these links / documentation tonight after I get off work.

Thanks again,
David


eNano(Posted March) [#23]
Hi hollifd, (sorry for my english)
I totally understand you, you have an industrial job and you really like coding, is more or less what happens to me, I build and design homes and at the same time I'm making my own design software, let me give you an advice: don't try it! is very addictive but will cause you a lot of waste of time.
Let me share with you my poor knowledge, Cad/cam softwares used for simulations uses other type of geometric representation called B-Rep (boundary representation), blitz is made to work with simple meshes so if you want to manipulate complex geometries you will have to reinvent the entire wheel. Topology based software lets you do very complex operations in the geometry because every feature of the shape if based on equations. To give thickness to a flat geometry in blitz you will have to have a 3D offset algorithm, mesh triangulation algorithm and work with transform matrices at vertex level.
My first advice would be to try SolidWorks, it has a specific module for metal sheet working (I needed to do a design in steel for the first time of my life and toke to me 2 weeks to learn how to do it on youtube, is very intuitive).
You can redefine at any moment any feature of your project (thickness, shape, holes...) and the final plans are updated automatically with technical dimensions
My second advice would be to use a language like blitzmax and search for some pre-made cad/cam libraries to develop your tool (for example libigl or CADability to mention something)
My very last advice would be: try to do it in blitz and see what you get :)


hollifd(Posted March) [#24]
eNano,
I don't want to give up just yet. I am so close now. I have the entire press brake machine modeled in CAD. I have all of the parts exported out of our CAD system as .3DS files. I have written the code to import these into Blitz3D and I can move all of the parts of the machine in any way I need to move them. I just need a solution for the part folding /unfolding. I have been on this forum for a very long time and there are some very smart people here. I think someone will invent a solution. I have been in the bed for the last 4 days with the flu. I want to learn more about Blender to see if Kryzon's hook modifier idea might be a solution.

RemiD has an idea that does not involve a third party software tool like Blender.

I think if the right person sees this problem, someone will invent a working solution.

I can do some of the things I want to do in our CAD system but it is much more time consuming than the tool I am working on. If I can find a solution for the bending / undbending then my tool will be a very useful tool and save a tremendous amount of time in our shop. There are other people out there developing software like my tool but it is very expensive. If others can do it, then why not me or the people on this forum? Just need a idea / solution that is simple and quick.

As for the parts I am working with, they are designed in our CAD system. I don't really need to change the design, add features or anything like that in my tool. I only need to unfold / fold the part. I can export a 3DS file from our CAD system that can be opened in Blitz3D. I just need to find a way to fold / unfold it in my tool. Other CAD software can fold / unfold these CAD files. Why can it NOT be done in Blitz?

Perhaps I will not be able to solve this problem. I have been thinking about it for years and only recently have I tried to actually do it. I can see the finish line so I don't want to give up just yet.

Let me know if you come across some sort of idea that might work.

Thanks,
David


Flanker(Posted April) [#25]
I worked a little on this kind of machines when I was in industry, what I remember is that you have to think twice before each bend you do or you'll get stuck at some point. I presume that's why you want to make a software, to "predict" the order of the bends ?


hollifd(Posted April) [#26]
Yes. You do have to plan the order of the bends carefully or you will get to the last bend and discover that it is not possible and you should have done that bend earlier. We have some very complex sheet metal parts that we do. I have a guy on my team that is very good at this sort of thing but I am trying to create a software tool to help us get better and faster at it.

My purpose for this software is:
1) determine the proper bend sequence
2) determine tooling that will allow the bends to be made
3) see any interferences between part, tools, and machine
4) take the data that the user is creating with this software and format that data in such a way that a program can be made to run the actual machine.

If I can simulate the bends in this software, then I don't necessarily need to software to predict the bend sequence. The user can pick a bend sequence then view it in the software to see if there are any collisions with part, tooling and machine.

There is software on the market that can do all of this automatically but it is very expensive. I was hoping someone here could figure out how those guys are doing it and be able to duplicate it in Blitz.


Thanks,
David


hollifd(Posted April) [#27]
Kryzon had a way to do it in Blender but it is too complicated and takes too long. I am hoping to find another way that is simpler and faster.


Flanker(Posted April) [#28]
But do you need to take into account bends radius and things like the neutral line ?

As I'm interested I can have a try, but only for a flat mesh with no thickness.


hollifd(Posted April) [#29]
If you wanted to be extremely accurate and produce commercial level results then yes, you would want to be concerned about the inside radius and neutral axis. At this point, I was not going to be too concerned about those details until a solution was found. I believe I could develop a way to handle those details once bending and unbending is possible.


hollifd(Posted April) [#30]
Let me know if I can provide you with any files or drawings or any other details or information you think might be useful.

... and thanks for having a go at it.

David


skidracer(Posted April) [#31]
When building boxes, i like to interleave the bottom folds of the standard cardboard variety at critical points along the final bend so the four flaps become naturally reinforcing.

As I am interested in origami and paper construction - cutout and folding as craft is fun, I am considering the simulation needed to output such an animation.

If I was going to tackle the general case in blitz3d I would use multiple bones per hinge and build a simple animation system. To build bone networks in Blitz3D dynamically it may be simplest to save your object to b3d file (collection of plates connected to a collection of hinges made from a collection of double bone joints) and load result into separate animation module in which final form is at t=1.0


Flanker(Posted April) [#32]
Here is a first throw, I ended up using the idea submited by Floyd. It will work well for a mesh with no thickness, but only if triangles are build from vertices on the out bound (meaning no vertices "inside" the surface).

You can get from that :


To that easily :


Here is the test mesh from above : https://1drv.ms/u/s!AmRLc37qlFbZi0xae8yMVU4yN1U1

And the (crappy) code :


Now it needs a way to align the edge to bend with a reference (the machine), and eventually bend it in realtime to check for collision.


hollifd(Posted April) [#33]
Exciting to see a potential solution already. I want to see it in action but I cannot seem to download the mesh.

To align the edge to bend, I was thinking when you select the bend line, the code would re-orient the mesh (...and bend line) from whatever angle it may be TO perfectly horizontal and then move the part (...and bend line) from wherever it may be to where the bend line is Y = 0. The centerline of the machine is at Y=0. All tooling used to bend the part is centered on Y=0. Currently, my tool views the machine from the top as if you were on the ceiling looking down onto the machine.

If this is too difficult, then I already have code to manually rotate the part and move the part wherever it needs to be moved.


Flanker(Posted April) [#34]
Here is another link for the mesh : https://ufile.io/gexgq

Or you can use any flat mesh. I'll try later to align the mesh according to the selected edge.


hollifd(Posted April) [#35]
Flanker...Thanks for the new link. I got the mesh and your solution is very impressive.

Concerning the flat mesh...All of the models we will be working with have a thickness. Can I take any of my meshes and scale the thickness to achieve a flat mesh with very little thickness or is it more complicated? Your geometry seems very simple (squares, rectangles, no holes in the part, etc). I would like to test a few other more complicated geometry...with holes in the parts, parts that have a bend in the center of the part and surrounded by material, etc.

In order to allow the user to "setup" the bends and machine parts, I think there must be a way for the user to "save" the part, tooling, and machine locations for each bend. Currently, in my tool, I allow the user to add bends to the setup and once the user has moved everything into position, I allow the user to "save" all of these locations to a TYPE. At the end, after the user has "setup" all of the bends and machine locations for each bend, I take the information from the TYPE fields and I use that data to create a program that will run the machine. The machine is a Cincinnati Autoform with a 6 axis backgage system. Not sure if you are already familiar with that machine or not.

What ideas do you have that would allow the user to create bends on a part, move the part into position and move the backgages on the machine into position and then save all of this stuff so that it can be "replayed" or viewed later for collisions, sequencing, etc.?


Flanker(Posted April) [#36]
The Cincinnati you have seems to be a big machine. The one we had was smaller and older, as far as I remember it didn't have a system to control the back depth, you had to position and align the sheet manually with a guide. It had a screen where you could set the desired angle and eventually make an automatic sequence but that's all. I was in maintenance mainly on classic lathe and CNC milling machines but I've never coded them.

I don't know how much a dedicated software costs, but I think that it's a full-time programer job, it's specific and complicated to achieve what you want :-/

My code would support holes and bends in the middle with a little modification, but only for a perfectly flat input mesh. Eventually it can import a model with thickness and transform it to a flat mesh... I think that you can use flat meshes to simulate your machine, unless you bend very thick sheets it won't be far from reality.


hollifd(Posted April) [#37]
We have investigated software. There are lots of choices that are quite good and simulate the bending process quite well and accurately. The software is very expensive...about $25,000 USD. Our leadership has decided not to spend the money and that is why I am trying to develop something that might help us.

Perhaps if there was enough interest on this board, a team could be formed to develop a lower cost but still effective solution for simulating the bending process.

You are right that we only bend very thin sheet metal parts. The thickness is 0.125 inches and thinner. The most common thickness is 0.070 inches thick. Our machines are very big (10ft long bed with 175 tons of hydraulic squeezing force) and computer controlled. They are 20+ years old but there is not much more capable machines out there these days...only newer but not much more capable. I have gotten to know them pretty well. I have studied the program format for the machines and that is why I am able to take raw data from another system and format it in such a way to create a program that will run the machines.

We have lathes and milling machines in our shop too.

I am still a little confused about the perfectly flat meshes. I don't know how to get a perfectly flat mesh. Everything out of our CAD system will have a thickness. Is there a way to start with a mesh having thickness and transform it to make a mesh perfectly flat?


RemiD(Posted April) [#38]

Is there a way to start with a mesh having thickness and transform it to make a mesh perfectly flat?


if the structure of your mesh is a sheet, you can analyze the top vertices/triangles and rebuild a flat mesh using these datas... (and discard the bottom, and sides)
But you need to have a "triangulated mesh" (= a mesh made of vertices and triangles, without duplicated vertices or overlapping triangles (this can happen if you have a bad exporter))