C coded dxf to g-code converter, the building process...

More
7 years 8 months ago - 7 years 8 months ago #126262 by Grotius
For info.

I made a study for the past 2 day's to try to converse a dxf file into a g-code file with C programming language.
At this moment a few thing's are working. See my comments inside the read.c file for more info.

I have good hope, when the project is some time ahead, we can make great profit of this code.
Trough the compiling the code works really fast. Python scripting is not my thing, so that's why i started in C.

Feel free to make suggestion's about my coding style. I am just learning C.

Here a drawing of type dxf, also attached :


Informative terminal output during file conversion :


G-code ouput example :


** the attached read.txt has to be renamed to read. It is the executable file. Terminal command : ./read

To test this code, see intro section of read.c
Be sure all files are in the same directory.
Be sure all file names are : read.c read.dxf

Have fun !
Attachments:
Last edit: 7 years 8 months ago by Grotius.
The following user(s) said Thank You: tommylight

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

More
7 years 8 months ago #126268 by pl7i92
There is a DXF2Gcode Plugin for Linuxcnc
The following user(s) said Thank You: Grotius

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

More
7 years 8 months ago #126282 by Grotius
I know :laugh: :laugh:

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

More
7 years 8 months ago #126303 by Grotius
Okey,

Tonight i have tested some cosinus and sinus functions in c for converting dxf arc's to g-code arc's.
I did not know the c language is working standard with radian's.
I expected normal degrees. Even my linux on board calculator was set in radian's.
Okey i must make a conversion strike for cosinus and sinus in C.

When the arc section is finished, it hopely can be called a very powerfull arc/polyline tool. I do not segmentate polylines into short lines. So the import is 1:1 without segmentation. Full arc's !!
The following user(s) said Thank You: tommylight

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

More
7 years 8 months ago - 7 years 8 months ago #126347 by Grotius
Hi,

I have good new's about arc's to g-code.

In this dxf drawing there are 8 arc's with different position's and shapes.


G-code output for arc's :


I had to add -lm to the geany compiler to connect the math.h library.

I used only cosinus and sinus function's to calculate the x,y start and x,y end point's of the arc.
Autocad works with circle centerpoint, radius, start angle and end angle. So i had to calculate it to
x,y start and x,y end of the arc. And that is done now. It's currently only for G02 movements.

The code for calculating dxf arc's to g-code output :


Next thing to do is to look about arc's that form a closed contour and what do do with that.
Last edit: 7 years 8 months ago by Grotius.
The following user(s) said Thank You: tommylight

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

More
7 years 8 months ago - 7 years 8 months ago #126392 by Grotius
I can use some advise.

Is it wisely to use a 2 stage methode for converting a dxf file to g-code?

1. First stage : read in the dxf and output g-code, oke this works for line, circle, arc etc now.
-- The output is it's a raw g-code file without optimalisation.
2. Second stage :
-- Make g-code optimalisation by checking closed contours, user input for inner or outside or no offset's etc.
(this one is the most difficult, i maybe must make a 2d-6d array to check all invidual correspondenting start and end points.)
-- Add line numbers, optional.
-- Add tools, Add G40, G41 & G42.
-- Later on make a cut sequence input direction or maybe a idea for automated optimalisation start points.

Input is welcome !
Last edit: 7 years 8 months ago by Grotius.

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

Time to create page: 0.217 seconds
Powered by Kunena Forum