Writing Your Hand Written Text With a Plotter [G-Code]
by Palingenesis in Workshop > CNC
2135 Views, 18 Favorites, 0 Comments
Writing Your Hand Written Text With a Plotter [G-Code]
The video is old, please excuse the noise in the background.
When I was building an XY Plotter I wanted to make my own software to control it.
When writing the software I wanted it to do more than just send G-Code to the Plotter I also wanted to be able to create G-Code from commonly use elements and files, This Instructable is about one of the parts of the Application I wrote to create Text for the plotter to plot.
- One Part called "Text", with this you can write text in different font and converts the text into G-Code you can send to your plotter. This still work in progress, it has a few bugs.
- One Part called "Handwriting" This is the one I want to show in this Instructable. You can input text and create G-Code to replicate your handwriting.
To emulate your handwriting DXF files need creating of the alphabet in your hand.
- The application looks at the text you have typed.
- It then replaces each letter for the equivalent created DXF file.
- When you create the G-Code it uses the DXF files.
Supplies
A Plotter.
- Well, it's useless without one, this is about using you plotter to emulate text in your hand written words.
- I say plotter, but there is no reason you can't use a 3D Printer with a pen attached to the head or a CNC machine.
Flat Bed Scanner.
- A Scanner is needed to scan your hand written characters.
- A camera will do now that we are digital.
Software.
- Tims_XY_Stepper_Controller.zip This is my software. You may want to Read This: It's about trust.
- Vector Graphic software that can convert Bitmap Images to Vector Graphics and export to a DXF file. I have used Corel Draw, but something like Inkscape will do.
- CAD Software. I have use LibreCAD, but AutoCAD will be OK after all DXF is Autodesk's creation.
Create a Character Set
Sorry about the sound quality in the video, I made it quite a while ago.
- The video goes into detail.
For your plotter to know how to draw text in your Handwriting style, It needs to know how characters are draw in your hand.
- We need to create a Character Set, a font so to speak.
- As we are using a plotter the best way to create your characters is as a CAD file.
- We are going to use DXF (Drawing Exchange Format)
I have attached a "Charector_Set.svg" file, load this into your Vector Graphix Software and print it out.
- Try not to scale it, I have a default setting in my software for the height of the text.
Once you have printed "Charector_Set.svg" you need to write all the Characters in your own hand.
- I found it best to use a pencil to give a good line thickness.
- Also using a pencil you can erase mistakes.
Next you need to scan the filled in Charector_Set into your computer.
- A flat bed scanner is best.
- Phones have good cameras these days, I suppose you can do it that way, the imported image is going to be edited.
Once you have images of your handwriting on your computer we need to convert the Bitmap Image to a Vector Graphic Image.
- I used Corel Draw but there are many Vector Graphic Applications to chose from. Inkscape is a free open source Application.
- Each Application will have its own way of converting bitmap into vector graphic, the applications web site is the obvious place to look.
- I found working with an outline is best, so create outlines of all your characters.
- If you chose to convert to single line representations of you characters you will struggle with the next stage.
- Once you are happy how the Vector Line version of your characters look save them as a file of the Applications format, this is so you can edit if you wish later and usually the applications format will same more info than the image itself.
- Then you need to export the file as DXF.
Once you have a DXF version of you Characters you can now start creating your Character Set for my Application.
- The video explains it best, (If you can tolerate the poor sound quality).
- Using your preferred CAD Application, load the DXF file of you Characters.
- Load the Template "Charector_Template.dxf" for a Character.
- Copy one of you Characters into the template.
- The template is a box the default size of a Capital Letter. There is a line mid way for the Lower Case Letters.
- Adjust you Character to suit from the bottom left corner of the box.
- Select the "Handwrite_Line" layer of the CAD file to draw the lines the pen will take to draw the Character.
- Use 3 point curves to draw the lines. using curves makes it look more realistic, no one writes straight lines.
- Draw the lines in the order you write the Character.
- Have a separation between the lines where you lift the pen.
- When you have drawn all the lines you need to make the curves that are one stroke into a polyline.
- LibreCAD will create Polylines in the order they where draw.
- Depending on what Application you use, if there are options to set the direction and order, set the lines so that the order and direction is the same as you write the Character.
- When the file is saved to DXF file, the ENTITIES are written in the same order and that's the way my application reads them.
- Save the file under a new name, I save them at this stage as the ASCII number and Master.
- Look at the "HandwritingData.txt" file to find the ASCII number.
- While you have the "HandwritingData.txt" file open, you need to set the width of the Character.
- The width of the Character goes in the forth column. Take care not to alter the format of this file. There should be a "Tab" separating the columns.
- Once you are happy with the way the Character looks delete all the other layers of the template.
- Save the file under just the ASCII number.
Note!
- If using AutoCAD, you may need to save to an old ASCII version of DXF, say DXF R12.
Do this for all the Characters.
- It may be tedious but you do it only once.
I have created a Character set for you to download
- Each Character Set you create needs to be in its own folder with its own "HandwritingData.txt" file.
- When you use a Character Set you set the path to the folder of the one you want to use.
The files I can upload here are attached.
- The files I haven't uploaded are characters in my hand. (you can find them on my blog)
- All files from "33.dxf to 351.dxf" need to be placed in a folder called "Unicode".
- The file "HandwritingData.txt" also needs to go inside the folder called "Unicode".
- The file "Charector_Set.svg" is a template for you to print on which you can write all Hand Written Characters
- The "Charector_Template.dxf" is a template to help size your Characters in you CAD Application.
Once you have created the folder "Unicode" with all the files inside.
- Copy the folder and rename it to a name of your choice.
- You can the edit the files in this new folder with your Hand Written Characters.
- Remember when creating you characters you need to edit the values in "Charector_Template.dxf" to the correct width of you characters.
Downloads
Convert Text Into Your Hand Written Style G-Code
Open My Application
- Click the "Create G-Code" Button. This will open another window. (1)
In the "Create G-Code" window there are several Tabs.
- Click "Handwriting" Tab. (2)
- The first time you click on the "Handwriting" Tab you will probably get a message the it cannot find the folder containing the Character set.
- Click the "Handwriting Font Path" button. (3)
- The Dialog that opens is a "Folder Dialog" you set the folder not a file.
- You can type text directly into the "Text Input" box. (4)
- You can open a Text File. (5)
- Once you have the text you want, click the "Preview" button. (5)
When you have clicked "Preview" it will give a representation of what it will look like.
- There are some settings to change it slightly.
- You bay have to switch between "Text Input" and "Preview" for the changes to be seen.
- You will need to be in "Preview" to convert to G-Code.
Before converting to G-Code, I have tried to give options, depending on your machine. (7)
- Different machines need different commands to lift and lower a pen.
- Some machines use M03 and M05 to move a servo, there is a check Box for this.
- If you want to try this on a 3D Printer or a CNC machine that has a Stepper Motor for the Z Axis, the "Use Z" Check Box.
- Some pen Plotters also use a Stepper Motor lift the pen.
- Then there is the version of machine that use grbl and the spindle speed to control a laser or servo. That's what the "grbl friendly" Check box is for.
After converting to G-Code. (8)
- You can edit the code in the main code box. (9)
Note!
The text will start plotting from the top of your work area.
- In the "Max Plot Area" you may want to reduce the height of work area if you are doing single lines.
- It was designed wit writing to A4 Page in mind.
Plot
Depending on your machine you may be able to use my application to plot to your machine.
- Load the file.
- When you load a file it will give a preview.
- If you want to see the progress as it plots, clear the preview before plotting.
- My Application now has an editor to change the G-code.
- The preview is colour coded for Move, Plot, Up and Down.
If my application does not work with your machine the G-Code should.
- You will just need to check the commands for Up/Down, On/Off.
Results
I thought I would test it on my laser plotter (CNC)
- Yes I believe you lasered wrote that by hand. :)
The pencil written is close
- Only with the two together you can tell.
- Some tweaks to the DXF files and it will be closer.
Once you have created you Character Set.
- You can write anything and it will be converted.
- Let the plotter write your homework over night, who's to know. haha.