"... and no one shall work for money, and no one shall work for fame; But each for the joy of the working, and each, in his separate star, shall draw the thing as he sees it, for the god of things as they are"

-Kipling

 

NamePlateGenerator:
Fast, Automated Generation of GCode Files to Engrave Text

Overview

One of my projects required many 4 x 2.5 inch bi-color plastic panels (nameplates) be to be engraved with text using a CNC router. These nameplates are the white text on black background labels similar to the type seen at botanical gardens identifying plants. There were over 250 nameplates which needed to be suitably processed - each with five items of distinct and variable length text. Manually creating such nameplates with standard CAD software would be exceptionally repetitive and would take an improbably long time. Clearly there was a need for an automated solution - thus the NamePlateGenerator software was created.

 

The nameplates needed to be able to set arbitrary text in all four corners, a line of text in the middle and also drill two screw mounting holes. In addition, the typeface and font size needed to be configurable and all of the text should be appropriately justified. In other words, whatever text was to be placed in the lower right hand corner needed to have it's start point offset so that the end and lower edge of the text was positioned at a configurable distance (the margin) from the right and bottom edges of the nameplate. Similar calculations are required for every other text item.

Since CNC machines will only accept GCode, the software also needed to be able to convert TrueType fonts into suitable GCode. This conversion involves flattening out the splines and Bezier curves which form the definition of a TTF font character into a sequence of small connected straight line segments. The number of segments used for the curve (the Smoothing Factor) needed to be a settable feature. A low enough Smoothing Factor (smaller means smoother) produces output indistinguishable to the human eye from a normal curve. Too large a Smoothing Factor and you end up with far fewer GCode lines but also have "blocky" segmented text reminiscent of a 1980's video game.

Other required features were a WISIWYG interface to display on the screen a reasonably accurate representation of what will be engraved when the GCode is run and the ability to process a delimited text file with the five text items per line in order to bulk generate a large number of GCode files.

The State of the Project

The NamePlateGenerator software contains on-screen controls which enable the user to manually enter four items of corner text along with a centered string of main text, choose the fonts, sizes, margins and set numerous other CNC things such as depth of cut and size of nameplate. A representation of the output is displayed on the screen. At the press of a button, the NamePlateGenerator software can generate a GCode file which will engrave text identical to the screen display when run on a CNC machine. In addition, a mode which can consume a delimited text file and automatically generate an arbitrary number of such files is available. The generated GCode is displayed in a panel on the right hand side of the screen and can be saved as a file or copy and pasted elsewhere.

This project was created to meet a specific purpose for a given set of input and output requirements. The software is not polished and is not particularly productionised. This means that the operation is not as smooth and generic as might be desired and there are not as many features as there probably should be. There are, however, no known bugs. In addition, please realize that now that the software has done the job for which it was intended, development is essentially over as far as the author is concerned. In particular, please note that the NamePlateGenerator only uses Imperial units (inches) since those are the units of the authors CNC machine and there are no plans to add metric support.

The NamePlateGenerator software is pretty much only offered as a starting point for others who may wish to adapt it. If you do make enhancements that would be useful to others (and which you would like to share) please generate a pull request on the GitHub repo.

The NamePlateGenerator Common Controls

    Plate Width
    The width of the nameplate in inches. Changing this value adjusts the text positioning.
    Plate Height
    The height of the nameplate in inches. Changing this value adjusts the text positioning
    Plate Margin
    The amount of space between the corner text and the edge of the plate. The margin distance is equal on all edges. It would not be hard to add a feature to specify an individual margin for each side.
    Touchdown Offset
    The distance between the margin and the point where the bit touches down to mark the drill hole. This is equal for all margins and touchdowns.
    Touchdown ZDepth
    The depth the bit sinks into the material to mark the drill hole. If an appropriately sized engraving bit is used it is possible to use this feature to sink the bit through the material hence drilling the hole. Otherwise the touchdown just marks the position for later manual drilling with a suitably sized bit.
    CenterZDepth
    The depth to sink the bit when engraving the center text. Since engraving bits are usually conical this setting also determines the width of the lines in center text. This value should be negative since it is below the surface of the material.
    CornerZDepth
    The depth to sink the bit when engraving the corner text. Since engraving bits are usually conical this setting also determines the width of the lines in corner text. This depth is used for all corner text values - it would not be hard to add support for individual depths for each corner text value. This value should be negative since it is below the surface of the material.
    ClearZHeight
    The height at which to retract the bit in order to move it off the work at the start and completion of the run. This height should be high enough to clear any hold down clamps etc. This value should be positive since it is above the surface of the material.
    FastMoveZHeight
    The height at which to retract the bit in order to move it to the next letter in the text. This should be fairly small so that the Z axis does not spend an excessive amount of time moving up and down every time it needs to engrave a new letter. This value should be positive since it is above the surface of the material.
    TextFeedRate
    The XY feed rate to use when engraving text.
    FastFeedRate
    The XY feed rate to use when performing fast moves between engraving positions.
    ZFeedRate
    The feed rate at which the Z axis will move.
    UL Text
    The text to engrave in the upper left corner.
    LL Text
    The text to engrave in the lower left corner.
    UR Text
    The text to engrave in the upper right corner.
    LR Text
    The text to engrave in the lower right corner.
    Center Text
    The text to engrave centered in the nameplate.
    Add Boundary Rect
    If enabled, this option engraves a boundary rectangle around the outside of the plate.
    Add Vert. Touchdowns
    If enabled, this option places two touchdowns on the vertical centerline a Touchdown Offset distance from the margin. These appear as little white dots on the GUI display.
    Add Horiz. Touchdowns
    If enabled, this option places two touchdowns on the horizontal centerline a Touchdown Offset distance from the margin. These appear as little white dots on the GUI display.
    Smoothing Factor
    The text to engrave must be converted from TrueType font curves into a simulation which uses small connected straight line segments to approximate the curve. This value indicates how close an approximation is generated. A smaller value here means a better approximation but also more lines in the GCode. A value of 0.25 is quite a fine approximation and is probably a realistic lower bound for smaller font sizes. This value can also go above 1 but when doing so the approximation is not good and the letters tend to look "blocky".
    Center Text Font and Height
    The type face and font size to use for the center text.
    Corner Text Font and Height
    The type face and font size to use for the corner text. All corner text uses the same font and size. It would not be difficult to make this individually adjustable.
    Output Dir
    The output directory. In Manual mode this just provides the default output directory. In CSV mode this is the directory in which the auto-generated files are placed.

The NamePlateGenerator Manual Controls

    Generate from Screen
    Pressing this button generates the GCode from the on-screen values and also updates the GUI display panel.
    Save
    Pressing this button saves the generated GCode to a file.

The NamePlateGenerator Automatic Controls

    CSV File
    The full path and name of a CSV file which contains the values to auto-process into GCode files. The delimiter in this file is a pipe symbol "|" and the order of the values is CenterText|UpperLeft|UpperRight|LowerRight|LowerLeft. Any field which is to be blank can just be left empty. The download comes with a sample input CSV file named nebula.csv to use for practice.
    Generate from 5Col CSV
    Pressing this button generates the GCode from the CSV file. The currently set on-screen values (other than the text definitions) are used to provide all of the generation parameters. The output is written to the location specified by the Output Dir setting. The file name is the content CenterText value with all spaces removed and a filename extension of .ngc.

How to Use the NamePlateGenerator Software

  1. Set the output directory. In CSV mode all files will be written to this directory and in Manual mode it is just the default for the Save button.
  2. Set all of the parameters appropriately.
  3. Press the Generate From Screen button. This will update the GUI display panel and the GCode. Adjust things till you are satisfied and save the GCode file.
  4. Run the GCode on your CNC machine as a test. Note that there is no provision in the software for the bit type or diameter. This means the width of the lines in the engraved text is NOT accurately shown on the GUI display. For conical bits, the engraved text width is entirely dependent on how deep you sink the bit. You will probably have to make a couple of test runs. The default values seem to do a satisfactory job engraving a 4x2.5 inch nameplate with a 0.125 inch, 30 degree conical engraving bit.
  5. If the manual run was satisfactory, and you wish to bulk generate nameplates, compose a delimited CSV and press the Generate from 5Col CSV button.
  6. The bulk generated GCode files will be placed in the output directory and will have a filename based on the center text value with all spaces removed.

What the NamePlateGenerator Software Does Not Do

Other Things You Might Wish to Know

Things Programmers Might Wish to Know

The Source Code

The NamePlateGenerator Application is open source and is released under the MIT License. You can download, clone, fork or create pull requests at the following address:

https://github.com/OfItselfSo/NamePlateGenerator

Download the Binary

The best option is to acquire the code from the Github repo (see above) and compile it yourself (Visual Studio 2019 C# was used for development). However,if you just want to use the code as-is, a pre-compiled binary NamePlateGenerator.exe file is available below. There is no installer - just unzip it where you want it and run.

Acknowledgments

License

The contents of this web page are provided "as is" without any warranty of any kind and without any claim to accuracy. Please be aware that the information provided may be out-of-date, incomplete, erroneous or simply unsuitable for your purposes. Any use you make of the information is entirely at your discretion and any consequences of that use are entirely your responsibility. All source code is provided under the terms of the MIT License.