question about creating objects for Path processing.

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!
Post Reply
memfis
Posts: 589
Joined: Tue Nov 15, 2016 7:58 pm

question about creating objects for Path processing.

Post by memfis »

Colleagues,

There is a need (sometimes) to create a solid based on a photo, a picture. "Not parametric. In the sense that it is not ... in general, Art.
There is such a workbench Litophane, somehow I already tried it in work. Since then the workbench formally got new features, such as the button "create a body from a set of...". There you can import a picture + Creaty box (= get a set of points). Click on the button "create body" and get eternal thinking program without getting results (after an hour to process the picture nailed it). Hence the question - how exactly from the created Litophane Mesh you can get a body suitable for processing in PAth?

The second way - there is a great utility image-to-gcode, give the input picture (prepared) = at the output we get a file g-code. The utility is sane, it is clear what affects what and how to use it. Created g-code can be imported into FC. Further (up to this point) I managed to use this imported object only for the sight - move, place, do something around. And I would like to get a solid body from it again. Are there any such solutions?
Attachments
gcode.zip
(72.12 KiB) Downloaded 23 times
Снимок экрана от 2022-05-07 16-41-30.jpg
Снимок экрана от 2022-05-07 16-41-30.jpg (203.59 KiB) Viewed 1173 times
litophane.FCStd
(936.68 KiB) Downloaded 27 times
path.FCStd
(93.06 KiB) Downloaded 21 times
bmsaus4ax
Posts: 258
Joined: Sat Nov 14, 2020 9:16 pm
Location: Bargara, Queensland, Australia UTC+10

Re: question about creating objects for Path processing.

Post by bmsaus4ax »

memfis wrote: Sat May 07, 2022 1:43 pm Colleagues,

There is a need (sometimes) to create a solid based on a photo, a picture. "Not parametric. In the sense that it is not ... in general, Art.
There is such a workbench Litophane, somehow I already tried it in work. Since then the workbench formally got new features, such as the button "create a body from a set of...". There you can import a picture + Creaty box (= get a set of points). Click on the button "create body" and get eternal thinking program without getting results (after an hour to process the picture nailed it). Hence the question - how exactly from the created Litophane Mesh you can get a body suitable for processing in PAth?
I can not see any images in the Lithophane file.
.
The second way - there is a great utility image-to-gcode, give the input picture (prepared) = at the output we get a file g-code. The utility is sane, it is clear what affects what and how to use it. Created g-code can be imported into FC. Further (up to this point) I managed to use this imported object only for the sight - move, place, do something around. And I would like to get a solid body from it again. Are there any such solutions?
This is possible in FreeCAD but the simulator will not work with the file as it the generated code is formatted for the G19 planes. FreeCAD simulation is limited to G17 paths from my experience.

In Part WorkBench create a Cube to cover the displayed Path.
In Path Workbench create a Job for the Cube,
Select "Inspect Path Commands", select all, and copy, and close.
In the Job create a Custom operation and Paste copied code into it.
Post-process.

You can see the code simulated in an external simulator, like NC Viewer.
https://ncviewer.com/

Of course your machine needs to be able to run G19 also.
Can you select which plane to use for processing in the utility, that is force to use G17 ?
.

Code: Select all

OS: Ubuntu 20.04.4 LTS (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.28793 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 5386d4e)
Hash: 5386d4ed864cd03edd026e1d3d128cccedf568df
Python 3.9.12, Qt 5.12.9, Coin 4.0.0, OCC 7.5.3
Locale: English/Australia (en_AU)
Installed mods: 
  * Curves 0.4.2
  * CurvedShapes 1.0.3
.
Attachments
mod_path.FCStd
(301.23 KiB) Downloaded 21 times
memfis
Posts: 589
Joined: Tue Nov 15, 2016 7:58 pm

Re: question about creating objects for Path processing.

Post by memfis »

To the moderator - this topic probably doesn't belong in Path = please move it "to the right place".

I probably didn't explain the goals and objectives correctly. It is not the goal to see a simulation - LinuxCNC can handle that too. The task is this, using a fork as an example - there is an Art object (conventionally - a woman). It should be integrated with the projected object - let's assume, as in this case, with a fork. Before integration, the Art object should be created. The use of "library" models is rejected - they have written on their faces (and other body parts) that they don't fit the style ("цыганщина так и прет").
Now massively practiced (not by me) using Blender, Brush, but their result is similar and gives something like "mermaid". Which then somehow have to be inserted into the drawings and used.

The task and the question was to prepare the "raw material" for use in FC. The prerequisites for this are, from what I know (I may not know everything) = Litophane & import g-code. Import g-code gives a set of lines on the screen = FC sees and understands them. It remains to connect these lines and create an object. HOW? Litophane creates a Mesh from the picture, FC sees it. But how to get the "body" out of it?
If we use the script to process the file we get from i-to-g, removing G commands etc. from it, leaving only coordinates in each line, what will we get in terms of export capabilities? - If this is the "working path", then we can upgrade the i-to-gcode script itself.

Code: Select all

Start: Group Faces (1/6)...
Finished: Group Faces (1/6) (270.862 s)
Start: Calculate Wires from Groups (2/6)...
Finished: Calculate Wires from Groups (2/6) (0.404 s)
Start: Calculate Faces from Wires (3/6)...
Traceback (most recent call last):
  File "/home/memfis/.FreeCAD/Mod/Lithophane/base_lithophane_processor.py", line 59, in run
    lastReturnValue = self.executeStep(step, lastReturnValue)
  File "/home/memfis/.FreeCAD/Mod/Lithophane/base_lithophane_processor.py", line 25, in executeStep
    lastReturnValue = step(lastReturnValue)
  File "/home/memfis/.FreeCAD/Mod/Lithophane/make_solid.py", line 114, in calculateFaces
    return ([Part.Face(wire) for wire in wires], meshData)
  File "/home/memfis/.FreeCAD/Mod/Lithophane/make_solid.py", line 114, in <listcomp>
    return ([Part.Face(wire) for wire in wires], meshData)
Part.OCCError: 16Standard_Failure Not planar


And there is a picture in the litophane file!
The appimage reference build hangs on this -
Снимок экрана от 2022-05-08 12-49-26.jpg
Снимок экрана от 2022-05-08 12-49-26.jpg (177.42 KiB) Viewed 1022 times
Attachments
litophane.FCStd
(899.49 KiB) Downloaded 27 times
Last edited by memfis on Sat May 21, 2022 9:54 pm, edited 1 time in total.
jescombe
Posts: 90
Joined: Tue Mar 09, 2021 4:19 pm

Re: question about creating objects for Path processing.

Post by jescombe »

I've no experience of the lithopane workbench (I tried it, but I don't see an image in your attachment either). However, if you are starting out with a mesh, you can convert this to a solid that you can then work with in the Path workbench.

These steps in the wiki work for me - though haven't tried with anything as complex as your pictures.. https://wiki.freecadweb.org/FreeCAD_and_Mesh_Import
memfis
Posts: 589
Joined: Tue Nov 15, 2016 7:58 pm

Re: question about creating objects for Path processing.

Post by memfis »

With the picture I figured out - the file FC inside itself records the path to the picture and only. That's why I also posted the original picture.

This task can be found in many different forms, in fact, it is about creating a set of sections of the bas-relief according to its image. On the X and Y axis it is perfectly coped with by image-to-gcode, and on the Z axis Inkscape copes with it. But it is only half-measures, it is not yet possible to "pour" it into the "body". I do not think there is a complete solution. There are fragments of the solution, which would be correct to combine into one tool, which, unfortunately, I can't do myself, given my skills in Python. But setting the problem is already part of the way to its solution and there is something to say.
Let's consider a variant of an image.

To use it in an application, of course, it has to be prepared in the Gimp. And to use it in drawings, FC models in order to use it later in Path, you need to get a body.
Now the following tools are known and used

1. image-to-gcode https://github.com/robomechs/image-to-gcode. This script is reasonably controllable, creates a set of sections perpendicular to the X or Y axis, depending on the settings. Well not exactly sections - a set of g-code that you can import into FC and see there as a set of lines. But that's all - it is impossible to turn it into a "body" yet. And it would seem, here's a set of coordinates, in blocks as a sketch with an offset, go ahead and make the body in the PartDi layout
2. the layout plugin Litophane can take an image, convert it into Mesh, and that's it. It would seem that there is no button (opportunity) to convert the Mesh into the body, but it doesn't work (neither with blender, nor opencascade).

This option could be a working scheme today.
3. inkscape and vectorize image by layers - good tool, through the menu "vectorize image" => save svg file => import into FC = get sets of Path, which can be turned into a Sketch. But!!! all Paths are imported at the same height Z=0. The numbering system of the imported Paths is quite clear - the first digits = the number of the decomposition layer (you have to make the right number of layers in Inkscape first and sort everything there) . This can be sorted into groups (when imported into FC) and cleaned within each group (remove unnecessary, nested contours, noises). In this particular example, 8 layers of decomposition in Inkscape, and numbering - for some reason, the layers have only even numbers, in this case, one layer is superfluous (background), the remaining numbers 62ХХХ-74ХХХ . After removing the excess, you can select the remaining Path and click the "merge into thumbnail" button. Each thumbnail can be shifted to the desired height Z and then you can create the body.


It seems to me that the most promising further solution - on the basis of image-too-gcode + inkscape = should make an import plugin in FC, layering. Or even "drag" these tools into FC, providing the ability to adjust the algorithm of transformation "blackness => Z coordinate" (now the linear transformation is implemented, and should be cos^^3. Proof? https://www.cnc-club.ru/forum/viewtopic.php?p=560044 - Create a circle in Inkscape, fill it with a gradient fill so that it looks like a ball, convert it with the image-to-gcode script to a g-code file, and see what cone you get instead of a ball).
Attachments
Снимок экрана от 2022-05-08 17-15-47.jpg
Снимок экрана от 2022-05-08 17-15-47.jpg (158.69 KiB) Viewed 977 times
рисунок2.svg
(516.44 KiB) Downloaded 28 times
Снимок экрана от 2022-05-08 17-14-04.jpg
Снимок экрана от 2022-05-08 17-14-04.jpg (208.91 KiB) Viewed 977 times
memfis
Posts: 589
Joined: Tue Nov 15, 2016 7:58 pm

Re: question about creating objects for Path processing.

Post by memfis »

jescombe wrote: Sun May 08, 2022 1:55 pm I've no experience of the lithopane workbench (I tried it, but I don't see an image in your attachment either). However, if you are starting out with a mesh, you can convert this to a solid that you can then work with in the Path workbench.

These steps in the wiki work for me - though haven't tried with anything as complex as your pictures.. https://wiki.freecadweb.org/FreeCAD_and_Mesh_Import
Brilliant! Thank you!
My mistake (once again) was looking for the button on the toolbar instead of looking at the entire list of features through the menu!
Attachments
Снимок экрана от 2022-05-08 17-31-30.jpg
Снимок экрана от 2022-05-08 17-31-30.jpg (248.71 KiB) Viewed 959 times
Post Reply