Optimizing plywood usage

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
Amigatech
Posts: 18
Joined: Mon Jan 18, 2010 12:55 am

Optimizing plywood usage

Post by Amigatech » Sat Feb 01, 2014 9:55 pm

I have an idea. I make things with plywood, but often have wasted leftover pieces. Interestingly enough, standard plywood size per sheet closely matches a standard computer screen resolution. A 4ft x 8ft, or 48in x 96in sheet can be multiplied by 16 to achieve 1/16in per pixel accuracy (for display). So, we can show a sheet with a 1536 x 768 pixel rectangle graphic.

Starting with the above grc called "plySheet", and having a list of "cut pieces" which are all smaller than the sheet, but varying in width and height, how can I mathematically create an optimized overlay onto the sheet, minimizing waste? The pieces left over would remain in the list to be compared against available space on the next sheet. I want the computer to help me determine where the cuts will be.

Is there existing already, a livecode script that does this or similar?

--
Amigatech

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6082
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Optimizing plywood usage

Post by dunbarx » Sat Feb 01, 2014 10:42 pm

Well.

I do this often with a CAD program, but still pretty much by hand. Such a process, though certainly optimizable with very clever software, is mostly heuristic, similar to packing a large box with smaller, differently shaped boxes. It is an intelligent trial-and-error task.

That said, I have written several programs, all related to finding the best fit of a library of linear shapes that must fit into a much longer linear space. This is a much simpler task than you are thinking about, since yours is two (not one) dimensional. But perhaps it can be attacked in the same way. I generally set up a series of pathways (I am not capable of that very clever sort of software) that start off subtracting the largest sub-shape, and continue to deduct from the whole in a sequential manner ever smaller ones. These paths must be tested at each step to see if the assembly is optimal, and if not, another pathway (or a sub-pathway) is inserted at that point.

With linear shapes, I always get the best use of the sub-shapes. I am sure this will work in 2-D, though I bet the task is considerably larger. Might I suggest that you try the 1-D problem first? If you get that down, move on to 2-D. In other words, take, say, a group of 3,4,6,and 8 foot boards, and find a way to fit them with minimal waste into, say, 30, 50, 75 and 83 foot space.

Write back. I have written the stuff I spoke about above with Hypercard, but the scripts will be nearly identical, and the process the same.

Craig Newman

Klaus
Posts: 11062
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Optimizing plywood usage

Post by Klaus » Sun Feb 02, 2014 1:49 pm

Hi guys,

plywood? :shock:

OK, after looking up this in the dictionary, I am glad that it does not have to do anything with CHEESE!
In that case I would have had to close this thread! :D


Best

Klaus

Amigatech
Posts: 18
Joined: Mon Jan 18, 2010 12:55 am

Re: Optimizing plywood usage

Post by Amigatech » Sun Feb 02, 2014 3:47 pm

Klaus,

Theoretically, the same problem could be applied to a large slice of cheese, but measured in millimeters, of course. 8)

Back to plywood though, the complexity of the problem will increase if we consider that with each cut, 1/16in of the remaining piece is lost to sawdust, allowing for the width of a saw blade. At first, I am not going to consider this. So it might as well be a big ole slice of cheese, and a very sharp knife.

We should still refer to it as "plywood", but we all know what we really mean. :wink:

--
Amigatech

Klaus
Posts: 11062
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Optimizing plywood usage

Post by Klaus » Sun Feb 02, 2014 4:02 pm

Amigatech wrote:We should still refer to it as "plywood", but we all know what we really mean. :wink:
:D :D :D

Amigatech
Posts: 18
Joined: Mon Jan 18, 2010 12:55 am

Re: Optimizing plywood usage

Post by Amigatech » Sun Feb 02, 2014 4:08 pm

dunbarx wrote: With linear shapes, I always get the best use of the sub-shapes. I am sure this will work in 2-D, though I bet the task is considerably larger. Might I suggest that you try the 1-D problem first? If you get that down, move on to 2-D. In other words, take, say, a group of 3,4,6,and 8 foot boards, and find a way to fit them with minimal waste into, say, 30, 50, 75 and 83 foot space.

Craig Newman
With 2D, we also have the option to rotate the blocks to achieve a better fit. /tetris flashback!

--
Amigatech

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6082
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Optimizing plywood usage

Post by dunbarx » Sun Feb 02, 2014 4:19 pm

The loss due to the width of the cut is trivial. It can be applied to each step as a matter of course. The trick is to determine the resultant rectangles after each section is removed. For example, in a 4' x 8' raw board, if you cut out, say, a 3' x 3' square from a corner, you are left with an "L" shaped remainder. But that is really:

1' x 8' and 3' x 5'
or
1' x 3' and 4' x 5'

You would have to assume that these two options were available as if those rectangles were separated. Now what to do with the several possible new rectangles that need to be taken from these two possible starting shapes? And so it goes...

Craig

Amigatech
Posts: 18
Joined: Mon Jan 18, 2010 12:55 am

Re: Optimizing plywood usage

Post by Amigatech » Mon Feb 03, 2014 2:09 am

I've created a basic drawing board (pun) with the ability to manually drag pieces around. If I can't use logic to smartly lay out the pieces, at least I can see the options. I want the pieces to stay inside the sheet, and not overlap any other pieces. Can I lock them to a grid?
PlyCut.zip
it's a start
(107.93 KiB) Downloaded 51 times
--
Amigatech

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6082
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Optimizing plywood usage

Post by dunbarx » Mon Feb 03, 2014 4:43 am

Aw, you are back to the heuristic playing around that I do in CAD.

But anyway, read up on the "grid" and the "gridSize" properties.

But if you really want to do it this way,especially if you want to do it a lot, I would recommend a simple, maybe free, drawing program. I use MacDraft (which incidentally is quite a bit more that just that) because I am that old. And it is not free. But it is as much fun in the CAD world as LC is in the RAD world.

Craig

FredBeck
Posts: 77
Joined: Fri Nov 01, 2013 3:07 pm
Location: Paris
Contact:

Re: Optimizing plywood usage

Post by FredBeck » Mon Feb 03, 2014 4:28 pm

Hi Amigatech,
This problem is known as nesting

As far as I'm concerned I do my cad on rhinoceros (still only on windows) and my 3d scripting with grasshopper.
You may find interesting info in the links of this post (some of them are broken)
http://www.grasshopper3d.com/forum/topi ... -resources

@ dunbarx : OMG I didn't knew MacDraft still existed! and it runs on OSX? I think last time I played with it it was on a Classic II...

Cheers
Fred.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6082
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Optimizing plywood usage

Post by dunbarx » Mon Feb 03, 2014 4:43 pm

Fred.

MacDraft is still alive and well, up to v6, and still the most intuitive and prettiest of all mid-level CAD software.

And I did not know that Rhinos and Grasshoppers nested in windows.

Craig

FredBeck
Posts: 77
Joined: Fri Nov 01, 2013 3:07 pm
Location: Paris
Contact:

Re: Optimizing plywood usage

Post by FredBeck » Mon Feb 03, 2014 5:15 pm

Hehe rhinos need big windows obviously!

Amigatech
Posts: 18
Joined: Mon Jan 18, 2010 12:55 am

Re: Optimizing plywood usage

Post by Amigatech » Tue Feb 04, 2014 4:22 am

You may find interesting info in the links of this post (some of them are broken)
http://www.grasshopper3d.com/forum/topi ... -resources

Cheers
Fred.
Interesting, but way to complex for me to follow. I wonder if a simpler nesting algorithm exists.

--
Amigatech

FredBeck
Posts: 77
Joined: Fri Nov 01, 2013 3:07 pm
Location: Paris
Contact:

Re: Optimizing plywood usage

Post by FredBeck » Mon Feb 01, 2016 3:36 pm

Hi!
In case anyone is interested, here's a link to a github repo that could be useful :)
https://github.com/Jack000/SVGnest/
F.

Post Reply

Return to “Talking LiveCode”