Android Question Text to GCode CNC Machine

fernando.oliboni

Active Member
Licensed User
Longtime User
Hi, I need to create an app that transforms texts into GCodes. Example:
upload_2018-7-27_8-22-8.png


Can someone help me?

Thank you
 

fernando.oliboni

Active Member
Licensed User
Longtime User
Yes I know. I have to write the codes, but I do not know how to transform a letter into an object and work with the points of that object.
 
Upvote 0
D

Deleted member 103

Guest
Yes I know. I have to write the codes, but I do not know how to transform a letter into an object and work with the points of that object.
A GCode has nothing to do with objects, it is pure text.
Here is a part of Gcode:
;Print time: #P_TIME#
;Filament used: #F_AMNT#m #F_WGHT#g
;Filament cost: #F_COST#
;M190 S80 ;Uncomment to add your own bed temperature line
;M109 S220 ;Uncomment to add your own temperature line
G21 ;metric values
G90 ;absolute positioning
M107 ;start with the fan off
G28 X0 Y0 ;move X/Y to min endstops
G28 Z0 ;move Z to min endstops
G1 Z15.0 F3000 ;move the platform down 15mm
G92 E0 ;zero the extruded length
G1 F200 E3 ;extrude 3mm of feed stock
G92 E0 ;zero the extruded length again
G1 F3000
;Put printing message on LCD screen
M117 Printing...

;Layer count: 40
;LAYER:0
M107
G0 F3000 X95.98 Y95.23 Z0.20
;TYPE:SKIRT
G1 F1200 X96.82 Y94.44 E0.04788
G1 X97.69 Y93.68 E0.09582
G1 X98.58 Y92.95 E0.14377
G1 X99.50 Y92.25 E0.19170
G1 X100.44 Y91.58 E0.23965
G1 X101.40 Y90.94 E0.28763
G1 X102.38 Y90.34 E0.33555
G1 X103.38 Y89.77 E0.38343
...
 
Upvote 0

fernando.oliboni

Active Member
Licensed User
Longtime User
I know how to write an NC code for machines, what I need is to transform a user-entered text of the app into Gcode. To do this, I need to find the points of the letters, I need to find the coordinates of the points of the letters that were typed.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
It' s crazy job. Nobody do it. Any CAM software will do it for you, with any font you like ....
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
I need to find the coordinates of the points of the letters that were typed

Everybody in this thread has answered your initial question. It seems this is the question you should have asked from the very beginning.

I'm not aware of an android based solution where you can convert characters to actual coordinates, perhaps somebody else in the forum knows more about this.

If we for the moment assume it's not possible, one working solution could be including a svg file per character in your app. The user types in YOLO and you grab the files Y.svg, O.svg and L.svg and offset them according to a pre-generated character width file.

Of course, if that's the route you're interested in, there's nothing stopping you from skipping the svg step entirely and just have GCode coordinates instead. One thing that might be interesting with svg though is the ability to preview the output using the svg library from @agraham.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Sandman gave you the solution. Use a cad/cam software and generate a text file for each characters.
I use this solution because I can quickly generate serial number (But I just need chars from 0 to 9) without modifying the source design and build gcode everytimes.
You just need to adjust the distance from each characters (after a "I" you need less distance for example).
But is a fixed height and font solution.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
if you have already the gcode for each letter you just need to create a map with the letter as the key and the gcode output string as the object. then if the user want to engrave "B4X" just out put that string from the map.

i am a CNC programmer for almost 12 years, if you need any help in gcode let me know.

(some parts i did lately)

20170119_113359.jpg 20180726_170923.jpg 20180726_170932.jpg
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
the only thing you will need to calculate is the new X location after each letter. it should not be hard at all to do that. so just keep a map of all letters and their GCode and then always calculate the new X Position after each letter so you know how much to move to the left and start the new letter. you can use also a code module for that and use types that will hold a string and a letterWidth amount. string is the gcode and letterWidth is the amount to move after that letter was engraved.

EDIT: if i think about it, it would be really interesting to create such a lib for b4x :)
 
Last edited:
Upvote 0
Top