Tiling and the path workbench

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!
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Tiling and the path workbench

Post by Russ4262 »

Evening.
Attached is version 3.0 of the job tiling utility macro. It appears to be working on 0.19, but is throwing some GUI-related errors along the way. I also updated the custom branch linked earlier in this thread with the equivalent version, but integrated into 0.20_pre for those who want to use it with fewer errors.

Start version 3.0 macro.
Select the source job and set the X and Y shift values.
Select "Tile_ ..." in the job selection that pops up, with the "..." being the label of the source job.
Click OK in the PathCustom task panel that opens, leaving settings unchanged.

There will be errors thrown, but the desired custom tile operations will be created. The object tree will not look normal, but the actual gcode of the CustomTile operations in the new job Operations group will be visible in the view port.

The version in 0.20_pre linked earlier in this thread has fixes for the GUI problems. I have some ideas about fixing some of the some of the GUI errors in this v3.0 macro for 0.19, but it will take some time.

Here in v3.0, the 100 mm max shift values are fixed, changed to 1000000 mm. Also, the new job can now be simulated without modifications to the simulator that I placed in the custom branch mentioned, which is nice for 0.19 users as well. The caveat is that the simulation has to be done in stages and then the output meshes repositioned manually per the tile size values, but it can be done relatively easily.

EDIT: 6 May 2021 - Removed macro attachment here. Newer version posted later in thread.

Cheers,
Russell
Last edited by Russ4262 on Thu May 06, 2021 11:35 pm, edited 1 time in total.
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Tiling and the path workbench

Post by Russ4262 »

Happy Saturday FreeCADians.
Some dev thoughts on this issue of tiling a job. So far the macro work has been successful. Working on this macro has lured me a bit further into scripting with the Path workbench. Some issues I have encountered pertain to:

1. GUI support, or objects with view provider support, but not initiated with Task Panel support. For example, I would like to script a new Job object with a view provider so it is workable in the GUI, but I do not want to initiate it with Task Panel interaction. I have found a few strategies to accomplish this in the code, but it will take some small changes to some core Path modules and a PR to accommodate.

2. how tiling is achieved, and at what point the actual `tiling` is applied. The current macro in this thread uses PathDressupBoundary applied to each operation within the source job, and this process is performed on a per-tile basis. The job model(s) are shifted for each tile to place the target area of the model(s) within the tile area, and then all the ops have to be recomputed. These recomputes can take major time, especially when 3D Surface is involved. So, this lead me to thinking about how and when the tiling is actually performed. I have a cut_pattern branch started that uses Python to build cut patterns. This could easily be upgraded to allow for tiling input values that would cut and separate the over all cut patterns into tiles prior to conversion to gcode. Or, I am thinking of modifying the current PathDressupBoundary module to accept a vector shift that applied to each edge created from the gcode, and also applied to the boundary shape (so as to keep the edges and boundary area in sync geometrically). This would allow the tiling operation to use the gcode from the existing source job without having to shift models and recompute operations.

3. how jobs are created or copied. I would like to modify the current PathJob module to allow for easier job creation from template attributes. This action mainly focuses on refactoring one or two existing methods in the module to isolate and expose more control over job creation with template data. A new helper method or class could be created as `CreateFromTemplateData`. Currently creation from template data appears to require a specific template file. Whereas I would like to see a method or class to copy a job by creating a new job object, then extracting and applying template data from the source job. I used the `copyObject()` method of the `ActiveDocument,` but I don't need the source job's base object(s) copied with it, nor its operations.

On the matter of features for a tiling operation that is discussed here, a few come to mind:
1. directional processing order of tiles - The current macro processes all the tiles in a single X row before applying a positive Y shift to access the next row of tiles. I know some users want to reverse this order, processing a column of Y tiles before shifting X.

2. vertical layer inclusion - adding a Z-thickness factor to the tiling process.

3. margins between tiles

4. custom vector shift applied to gcode output for all tiles

5. custom start point for tile grid


Just some thoughts with this post, no decisions made or actions taken at the moment. Thanks for the feedback. Thanks for helping to push FreeCAD further into the realm of possibilities.


Russell
Paula
Posts: 48
Joined: Tue Jan 26, 2021 10:06 pm

Re: Tiling and the path workbench

Post by Paula »

Hi Russell,

I think the code needs to be fairly smart about the directional processing of the tiles. I think most people who would use this feature will have a smallish/hobbyist CNC router with a physical limit to the width of the X axis but room to overhang stock on the Y axis. So I expect that in most cases they won't want an X shift at all. Contrast that with the owner a more traditional vertical mill where the Y axis is very limited who might only be interested in tiling in the X direction. My suggestion is to keep it simple, in line with modern Agile practice, and allow tiling along either the X or Y axis as specified by the user.
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Tiling and the path workbench

Post by Russ4262 »

Morning,
Have done a little more work on this macro. I am attaching version 4.1 here.
Changes include:
- improved documentation throughout code,
- addition of tiling direction rotation from X then Y, to Y first then X,
- fewer recomputes of base operations (elimination of recomputes is the goal, but this will require a PR to refactor the Boundary Dressup code a little to make the actual algorithm independent and accessible without creation of a Boundary Dressup object),
- limits on tiling to G0, G1, G2, and G3 gcode commands with ability to include other commands relatively easily,
- preparations for integration into Path WB as a permanent command,
- cleaner code structure,
- synchronization of tool controllers with component operations of each tile,
- synchronization of coolant mode with component operations of each tile,
- maintain ability to use simulator as is with minor post-simulation placement required.

This version is compatible with 0.19, but throws a number of GUI-related errors due to forced use of the GUI version of the Custom operation so that resulting tile paths can be visualized. The new Tile Job object is not GUI accessible with Task Panel in this version. I have started a few simple modifications for a PR to allow for full, normal GUI functionality and will also aid general scriptability of some aspects of job and operation creation with GUI support.

Tip: Create a Group folder in the object tree before running the macro. Run the macro, then select all the new objects created and drag them into the new Group folder. This will make your object tree cleaner and will allow for easier deletion when desired.

EDIT: 6 May 2021 - Removed macro attachment here. Newer version posted later in thread.

Russell
Last edited by Russ4262 on Thu May 06, 2021 11:36 pm, edited 1 time in total.
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Tiling and the path workbench

Post by Russ4262 »

Afternoon,
Posting a minor update to the macro, version 4.2.
Changes:
* more code organization and internal documentation
* add GUI selection check for pre-selected job object as source job (If user pre-selects job in object tree, that will be the source job used.)
* add units indicator to job labels in job selection combobox
* set default tile width (x) to 500 mm

EDIT: 6 May 2021 - Removed macro attachment here. Newer version posted later in thread.

Have a great day.

Russell
Last edited by Russ4262 on Fri May 07, 2021 3:25 am, edited 1 time in total.
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Tiling and the path workbench

Post by Russ4262 »

Evening,
Here is another minor update, but useful one. Version 4.3 of the Tile Job Utility is attached. The primary improvement is the presentation and observance of user-preferred units and decimal places as declared in the User Preferences for FreeCAD. This will aid those who do not work regularly with millimeters, as is the internal unit of length.

I successfully added an internal method with this version release that places all output objects of this tiling macro into a single group folder, but doing so breaks the integrity of the new tile job created. Since it is more important for job integrity and editability, I commented out the calling of this new method. This leaves the new tile job and its sub-components ungrouped within the object tree. A bit of an eye-sore, but better for usability and modification of the output as it pertains to a cohesive, functional job object.

I have successfully integrated this macro as a permanent command into Path WB in a personal, slightly-modified, test branch. In so doing the new tile job object is normal, as any other job object, including structurally and visually in the object tree. Some time in the future I might submit a PR for said integration after discussion of the same here in the forum.

EDIT: 9 May 2021 - Removed macro attachment here. Newer version posted later in thread.

Good night,
Russell
Last edited by Russ4262 on Sun May 09, 2021 5:53 am, edited 2 times in total.
memfis
Posts: 586
Joined: Tue Nov 15, 2016 7:58 pm

Re: Tiling and the path workbench

Post by memfis »

Russ4262 wrote: Tue Apr 27, 2021 11:16 pm
I also made some light modifications to the current Path simulator to allow for a crude method of simulating the output of the script. The branch is here.
Hi all. Unexpectedly (for myself) saw a link to another FC fork. I myself use https://github.com/realthunder/FreeCAD/ ... LinkStage3. Question - what is the basis of Russ fork?

Regarding the tile theme itself. In my experience of this kind of tasks "you can't just do that". Connections of this kind should (should) be planned with the ability to quickly correct the trajectory in the joints (gap, tension), which always change when you change the thickness of the material, type of material (ductility? elasticity?), working cutter, speeds. All the more so when it comes to at least a minimum of mass (tile = many pieces).


Obviously, any part of the set consists of "simple lines" and "complex lines", the simple ones can be very long (compared to the complex ones) = high feed rates are possible there, on complex parts the speed should be reduced and allow for correction by codes, for example -
G42.1 D[#<_dp2>] (compensation + or -)
Reduce speed!
after passing the section turn off - G40.


Well and transfer to any places of any created code can be easily done by this pattern -


o<baza2> sub
G0 Z[#<_bz>]
G92.2
G92 X[#<_x> - #1] Y[#<_y> - #2]

....
kod progr
.....

G0 Z[#<_bz>]
G17
G92.2
o<baza2> endsub


use -
o<baza2> call [X coord] [Y coord]
Attachments
Снимок экрана от 2021-05-07 11-52-17.png
Снимок экрана от 2021-05-07 11-52-17.png (1.26 MiB) Viewed 1958 times
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Tiling and the path workbench

Post by Russ4262 »

Morning sir.
memfis wrote: Fri May 07, 2021 9:01 am ... Question - what is the basis of Russ fork? ...
Fun, experimentation, collaboration, and contribution when possible. Otherwise, there is nothing special or unique. Neither does my personal fork have any long-term set objectives or significant advancements as does RealThunder's fork. Mine should not in any way be compared with the work he and other's are doing to advance FreeCAD in such grand style.

memfis wrote: Fri May 07, 2021 9:01 am ... Regarding the tile theme itself. In my experience of this kind of tasks "you can't just do that". Connections of this kind should (should) be planned with the ability to quickly correct the trajectory in the joints (gap, tension), which always change when you change the thickness of the material, type of material (ductility? elasticity?), working cutter, speeds. All the more so when it comes to at least a minimum of mass (tile = many pieces).
Agreed. There are many cases where as you say, "you can't just do that." So, that leaves the other set of cases where, indeed, you can just do that. Therefore, to those who have a need for a simple job-tiling utility here in FreeCAD and whose situations fall into the "yes, I can do that," I gladly offer this macro as one possible solution. As mentioned above by Sliptonic, G-Code Ripper is a much more customizable and robust piece of software for tiling and more.

Your comments here have also got me thinking about another feature to the macro that might be quite useful. Perhaps a "Border Path Overlap" feature [BPO for short] would help with the path cuts that initiate on the border(s) between the current tile and previous tiles. For example, Tile 1 does not need BPO. When cutting Tile 2, BPO would only be applied to the shared edge between Tile 1 and Tile 2. This BPO would affect the path cuts that were initiated in Tile 1 and must continue across the joint into Tile 2. This BPO will allow the cutter to reach back into Tile 1 to start these cut paths rather than plunge down on the joint to initiate them. I think this could be beneficial. I'll have to think on it some more.

Thanks for your comments. I regularly learn more here in the forum. Thanks also for reminding me of the complexities of CNC milling that must be considered in order to produce the desired product at the desired quality without damage to anything or anyone in the process.

ADDITION: I did remove the link to my custom branch that is link in your quote, pointing to an earlier post in this thread. Newer versions of this macro do not need any modifications to the Path simulator in order to simulate these new tile jobs created by the macro. The user does have to assemble the partial simulation meshes to see the finished simulation solid.

Have a great day Memfis.

Russell
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Tiling and the path workbench

Post by Russ4262 »

Evening fellow FreeCADians.
Here is version 5.0 of the Tile Job Utility macro. I am making this a major release with the following changes:
* Users now have the choice to put all tiling operations created into a single job, as is with previous versions of the macro, or choose to have operations grouped on a per-tile basis with one job created for each tile. This aids in post-processing and simulation, IMHO.
* More internal documentation of code
* Mile code restructuring and cleanup for better organization
* Removal of `Tile Id` property for the custom tile operations created
* Addition of `Source Operation` property to identify the source operation for the custom tile operation
* Addition of `Tile Details` property that contains some simple information for the custom tile operation in string form
* Removal of obsolete methods and code
* Fix decimal precision error for Y tile dimension input
* EDIT: Improve custom tile operation labels with simpler naming convention

I will likely update my Path integration branch for this macro in the coming days or weeks. I am excited to see a simple tiling utility taking shape.

I have not begun work on the `Border Path Overlap` feature mentioned in my last post. Nor do I have a timeframe in mind. Also, I have not made any integration of translation (language) awareness. I will likely add that important feature if this utility makes it into the Path workbench, since I am not sure how language translation is handled or done differently within macros.

EDIT: 9 May 2021 - Removed macro attachment here. Newer version posted later in thread.

Have a pleasant tiling weekend.

Russell
Attachments
Screenshot of version 5.0 GUI window
Screenshot of version 5.0 GUI window
Snip macro screenshot-d4a28a.png (13.01 KiB) Viewed 1833 times
Last edited by Russ4262 on Sun May 09, 2021 5:53 am, edited 1 time in total.
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Tiling and the path workbench

Post by Russ4262 »

Morning,
Caught some bugs and regressions and made a minor upgrade:
* Fix undefined index variable with single job usage - threw error
* Fix regression of no `Tile_` prefix for parent job selection on initial custom tile operation creation
* Fixes for permanent integration into Path workbench and macro usage from same file with only two simple code changes required
* Swap two radio buttons for checkboxes to allow the user to change an option selection instead of cancelling and restarting macro

Also, I updated my tile_job branch that integrates this macro into Path workbench without the odd object tree chaos. I still get some minor PathJob errors about an object not being in a list, but the tile jobs created appear to be intact and stable and able to be edited as needed. I will have to research the errors and their source.

EDIT: 15 May 2021 - Removed macro attachment here. Newer version posted later in thread.

Good night,
Russell
Last edited by Russ4262 on Sat May 15, 2021 6:49 pm, edited 1 time in total.
Post Reply