[SOLVED] gcode generated twice?

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Giulio Buccini
Posts: 541
Joined: Fri Aug 26, 2016 9:07 pm
Location: Munich - Gemany

Re: [SOLVED] gcode generated twice?

Post by Giulio Buccini »

Hi,

I will try to explain it by drawing a rough example. Give me 5 mins.
Giulio Buccini
Posts: 541
Joined: Fri Aug 26, 2016 9:07 pm
Location: Munich - Gemany

Re: [SOLVED] gcode generated twice?

Post by Giulio Buccini »

When you are married with child, 5 mins easily became 5 hours... :D

Here we go!

SLIDE 1 - Freecad world vs Real life
Selection_7640.jpg
Selection_7640.jpg (45.72 KiB) Viewed 1740 times
When making a single exemplar of a shape, Freecad-Path works great!
Unfortunately, for small/medium size of batches you would prefer a more smart way to deal with a single Job. When you deal with many copies to be produced then the main problem IS NOT the milling strategy, but the most efficient way to layout your shapes on a flat plate of raw material.

Here some considerations.

1. Rarely you want to move the origin of every single 2D-shape before milling it out of the material like the Path Workbench workflow normally suppose.
2. You often buy material with different sizes, searching for the cheaper one, and you need to change your layout quickly and in a straightforward manner.
3. To easily manage the space over the work table of your router, you often fix your working offsets (G54, G55, etc.) on the fixture. This will be a general reference for all of your shapes for all of the different sizes of your raw material.
4. To save money (alu costs have raised as a rocket here in Europe) you want to reduce the waste of material. This is an easy task when you deal with regular shapes with a simple geometry (rectangles, squares, triangle, etc) but it becomes a nightmare with the irregular ones.
5. Sometimes you need to produce left/right/up/down symmetric copies of your shape. Mostly simply because they will be mounted on the left/right/up/down side of your finished product.
6. Not of all controller fully support the g-code for rotation, mirroring, translation. Or have strong limitations on that.
Giulio Buccini
Posts: 541
Joined: Fri Aug 26, 2016 9:07 pm
Location: Munich - Gemany

Re: [SOLVED] gcode generated twice?

Post by Giulio Buccini »

SLIDE 2 - The problem
Selection_7641.jpg
Selection_7641.jpg (25.81 KiB) Viewed 1727 times
The main problem is depicted in the image above: how to start from the single "friendly" shape on the left, to the well packed messy-set of shapes on the right (whereas some shapes are mirrored also).

A preparatory study of the best layout for the set of shapes can be easily done by exporting you original shape in a vector-format (i.e. the SVG) and then playing with it by using a graphical application to find the most convenient arrangement on a plane.

By using a graphical applications (like Inkscape, Photoshop, Gimp, etc.) you can rapidly find the best result by an iterative trial-and-error process.
But, then?
Once you found the best solution, how you can use the Path WB to realize it?

Moving the original n 3D-objects on the plane and then manually creating n jobs for each of the can be an exhausting task if n is greater than 5.
Also the Path WB seems designed with one idea on mind: 1 project = 1 Object = 1 Job. If the job is quite complicated, then even a fast computer can reach soon the limit.
Giulio Buccini
Posts: 541
Joined: Fri Aug 26, 2016 9:07 pm
Location: Munich - Gemany

Re: [SOLVED] gcode generated twice?

Post by Giulio Buccini »

SLIDE 3 - A possible approach

One possible solution would be to have one or more tools dealing with an entire job as a whole. I don't know if this tools should be located in a new "Job Manager" Workbench, or be added to the Path WB. In any case they should offer the possibility to pipe on or more transformations applied to a Job:

1. translation;
2. rotation;
3. mirroring.

By referring the above slides, the following pipe produces one of the shapes depicted before:
Selection_7642.jpg
Selection_7642.jpg (33.24 KiB) Viewed 1716 times
So, in the most basic form, one pipe produces one new job. To get n different job, one has to specify n pipes.

Some implementation hints

1. Since every object in Freecad has his own origin, it would be much simpler to assume that the origin of every job in the pipe is the left-bottom corner of his bounding box.
2. Initially, the mirroring axis can be restricted to the X or Y axis of the job-origin only.
3. Initially, the rotation point can be restricted to the origin of the job only.

One arrangement on the tree-view could be the adding of a "Transformation" node with n-pipes as child inside the main Job node:

Code: Select all

Job
.
.
.
Transformation
  |
  +--> Pipe 01
  |     |
  |     +--> rotate 01
  |     +--> translate 01
  |     +--> mirror 01
  |
  +--> Pipe 02
  |     |
  |     +--> rotate 02
  |     +--> mirror 02
  .
  .
  .
User avatar
onekk
Veteran
Posts: 6222
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: [SOLVED] gcode generated twice?

Post by onekk »

Yes but this involve some "convex hull" calculation to do nesting, it is not a simple tasks.

I have had this problem, and the only thing I've found is a javascript thing that take a svg image and rearrange things, but SVG is not the most useful format when you start from a 3d model.

This will be an interesting and "crucial" addon to FreeCAD Path, but if you follow some other discussions here, you will se that there are more "urgent" things, like a "complete refactoring" of Path as told recently "very recently" by @sliptonic.

Stay tuned, and maybe if you are able to give some help.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Giulio Buccini
Posts: 541
Joined: Fri Aug 26, 2016 9:07 pm
Location: Munich - Gemany

Re: [SOLVED] gcode generated twice?

Post by Giulio Buccini »

Hi, thanks for the reply.

to provide a "layout" on the XY plane, the simple 2D shape produced by the Top View is more than enough in my experience.
A rough representation of the object outline (and his bounding-box) is all you need to move around your Job by using an external graphic tool.
A 2D vectorial format seems the most suitable format for this task.

My idea is that the lay-outing work has to be done with an external tool, not with Freecad. After you get a bunch of coords and rotations, then you come back to Freecad-Path to enter those numerical values in a "Transformation" object under the Job three.
In the first rough version, this can be done by entering the numbers directly in the properties of one Transformation.

I didn't explored all of the details of the supposed workflow associated with this use-case, but basically I have this basic command in my mind:

Job -> add Trasformations
Trasformations-> Add Pipe
Pipe -> add Translation
Pipe -> add Rotation
Pipe -> add Mirroring
(Where the Translation/Rotation/Mirroring could be added in any order.)

Furthermore, when exporting a Job to a g-code file, a boolean tick-value should be exposed to ask the user if also the transformed Paths should be appended to the output file or not.

In other words, in the initial version the user has not a direct visual feedback in Freecad of the results of his applied transformation. This can be done, for example, by using some free gcode-visualizer available online (e.g. NC Viewer)
bmsaus4ax
Posts: 258
Joined: Sat Nov 14, 2020 9:16 pm
Location: Bargara, Queensland, Australia UTC+10

Re: [SOLVED] gcode generated twice?

Post by bmsaus4ax »

Giulio Buccini wrote: Wed Nov 24, 2021 9:11 pm When you are married with child, 5 mins easily became 5 hours... :D

Here we go!

SLIDE 1 - Freecad world vs Real life

Selection_7640.jpg

When making a single exemplar of a shape, Freecad-Path works great!
Unfortunately, for small/medium size of batches you would prefer a more smart way to deal with a single Job. When you deal with many copies to be produced then the main problem IS NOT the milling strategy, but the most efficient way to layout your shapes on a flat plate of raw material.
Hi, I don't know if you want to do this much manipulation of the shapes within FreeCAD but I you go into the DRAFT Work Bench and clone your desired piece you can the manipulate the clones to position them.
It can be a bit of messing around as you may have to adjust values in the Rotation Axis's ( combinations of X, Y, and Z ) after doing the basic rotation.
For some the Z-axis may be below the origin plane.

On returning to the Path WB, select all the shapes to make the Job.
When setting the Z'0' for the Job you need to select the top (or bottom if you prefer ) surface for each and every piece or they will not all stay aligned.

I experimented on your original file. This is not necessarily a good nesting but may give the idea.
It is obviously a long way from a streamlined FreeCad operation but can get the job done.
Attached a modification of your file with a basic job with Profile Path
Attachments
nest_trial.png
nest_trial.png (9.69 KiB) Viewed 1605 times
modified_alu-bracket-1.5.0.FCStd
(800.36 KiB) Downloaded 22 times
Giulio Buccini
Posts: 541
Joined: Fri Aug 26, 2016 9:07 pm
Location: Munich - Gemany

Re: [SOLVED] gcode generated twice?

Post by Giulio Buccini »

To create a decent layout of the shapes over a plane I simply exported the outline by using the Draft Workbench. Then I imported the SVG file into Inkscape.
With such application you can easily move around you shapes with few clicks of your mouse until you find a good results. This is a "long" manual process and doing that with the Draft WB could be frustrating, IMO.

The main problem with your approach is that every single operation is replied over all of the shapes in sequence before passing at the next one. In other words, if you have m operations O over n shapes then the mill-sequence will be something like

O1.1,....O1,n
O2.1,... O2,n
.
.
.
Om.1,... Om,n

This where the real world breaks the virtual world of freecad.
In real production world you have situations like this ones:

- you plate of material has a defect in the center area, and you would like to skip the shape in that zone,
- you get interrupted during the job, so you get only half of the plate used, now you want to start milling in the remaining half
- the vendor selling you the plates is disappeared, now you have to use smaller ones from another vendor, so you would like to erase some shapes from your gcode
- you broken the bit when milling the shaper number X, now you would like to run the job again and skip that one
- and many other abnormal situations too.

Also, in your workflow, even if you apply a little variation in you design, you have to create all of the n shapes, from the scratch again. Lay them down by using the Draft WB and then... and then... non thanks.

A unique centralized shape is the way to go in my opinion. No doubts about this.
Post Reply