Nesting tool platform independent

More
15 Jul 2020 18:59 - 15 Jul 2020 19:25 #174766 by Grotius
Hi,

I have made a nesting interface in Java Netbeans :woohoo: based on textfile input and textfile output.
It can be implemented into Linuxcnc programs quite easy. But is also suitable for excel, python, c++, Inkscape, etc.
It depends on a java install. It works on every platform.

This is so far i can see the best opensource nesting algoritme. It can handle concave polygons. Recognize inner contours.
It's more advanged then the prusa nester wich can handle only convex polygons.

It's source algoritme : github.com/grotius-cnc/Nest4J (a deepnest.io clone with more interfacing).

How it works :

1. You have to provide a text input file, named "nest_in.txt".

- The file has a few setting parameters on top and contains contour points.
- The parameters can be placed at different places in the text file.

2. After input file is ready, you have to execute : "java -jar grotius_nest_interface.jar".

- This can be done easy by a script.

3. Output file is "nest.out.txt" + "ready.txt"
- The file ready is a trigger for linuxcnc when the nesting is completed and can be deleted by linuxcnc after nesting is loaded with succes.

4. On request i can provide a expanded interface providing the nesting contour coordinates.

Github source:
github.com/grotius-cnc/Nest4J

Terminal output:


Nest example:


User settings of file "nest_in":

binwidth 3050 //nest area x
binheight 2030
rotation 4 //0=no rotation, 4=full rotation
use_hole true //or false
population_size 10
mutation_rate 10
spacing 5 //part spacing
bid 0 //contour id nr.

If you have any questions, no problem.

Attached the zip file, containing :
grotius_nest_interface.jar
lib folder
nest_in.txt
nest_out.txt
ready.txt -> delete this one.
Attachments:
Last edit: 15 Jul 2020 19:25 by Grotius.
The following user(s) said Thank You: phillc54, Clive S

Please Log in or Create an account to join the conversation.

More
15 Jul 2020 19:05 #174767 by Clive S
Just a quick question from a novice . Can it nest with spaces between the items?
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

More
15 Jul 2020 19:14 - 15 Jul 2020 19:20 #174769 by Grotius
Yes Yes of course !!!

In the input file "nest_in.txt" you see :
binwidth 3050
binheight 2030
rotation 0
use_hole true
population_size 10
mutation_rate 10
spacing 5
bid 0
0.0 0.0
0.0 100.0
100.0 100.0
100.0 0.0
0.0 0.0
end

Here the spacing between parts is 5mm.
Rotation 0 is that parts may not rotate. Rotation 4 is full rotation parameter, see documentation at the above github link.

The java code is part of CadCam nesting.
Last edit: 15 Jul 2020 19:20 by Grotius.
The following user(s) said Thank You: tommylight, Clive S

Please Log in or Create an account to join the conversation.

More
16 Jul 2020 19:32 - 16 Jul 2020 19:51 #174883 by Grotius
Today did some test with the java nesting tool.
I am impressed. The calculation time was about 10-15 seconds.

Nesting input :


In the nesting output the plate is 3050x2030mm. See cyan colered line.
Items that not fit, are left untouched. This is a startpoint for a new plate nest routine.

Nesting output :


For the rotation parameter output, this is how to calculate the new contour coordinates, on github the information is giving wrong.
Its not rotating around the contour center, but rotating around 0,0.
//for every xy coordinate, translate + rotate :
//datas[i][3]=rotation angle from nest_out.txt
//it2->start.x=orginal input x
//it2->start.y=orginal input y
//xnew and ynew are rotated + translated, tested oke, see picture output.

double fangle=datas[i][3]*(M_PI/180); //std::cout<<"fangle: "<<fangle<<std::endl; //ok
double xnew=it2->start.x*cos(fangle)-it2->start.y*sin(fangle); //std::cout<<"xnew: "<<xnew<<std::endl;
double ynew=it2->start.x*sin(fangle)+it2->start.y*cos(fangle); //std::cout<<"ynew: "<<ynew<<std::endl;
xnew+=datas[i][1]; //std::cout<<"xnew + transx: "<<xnew<<std::endl;
ynew+=datas[i][2]; //std::cout<<"ynew + transy: "<<ynew<<std::endl;
it2->start.x=xnew;
it2->start.y=ynew;

For above example the nesting parameters in the file nest_in.txt are :
myfile << "binwidth 3050" <<std::endl; 
    myfile << "binheight 2050" <<std::endl;
    myfile << "rotation 4" <<std::endl;
    myfile << "use_hole false" <<std::endl;
    myfile << "population_size 10" <<std::endl;
    myfile << "mutation_rate 10" <<std::endl;
    myfile << "spacing 10" <<std::endl;

File input + file output included.
Attachments:
Last edit: 16 Jul 2020 19:51 by Grotius.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

Moderators: Skullworks
Time to create page: 0.146 seconds
Powered by Kunena Forum