CAM Helix Hole - QCAD/CAM script for milling helical holes
About this script
CamHelixHole is a script for QCAD/CAM. Its purpose is to generate G-code for helical hole milling directly from the CAD drawing.
At the time of the script development, QCAD/CAM supported only generating toolpaths that plunge straight down into the workpiece (by moving only the Z-axis) and then move horizontally
to remove the material. Usually this results in several passes of stopping the movement of the machine, going one step down and then doing the same horizontal milling for each pass.
To reduce machine time while maximizing the lifetime of the milling tool at the same time, it would be desirable to avoid stops and plunge into the material while moving horizontally.
For circular holes, this can be achieved by doing a helical movement.
This script generates according G-code for helical hole milling directly form the QCAD/CAM drawing.
Simply draw in circles with the desired hole diameters at the desired positions. The script allows you to specify all necessary parameters for the milling process (like speeds and feeds,
selection of the tool, safety and workpiece height, milling depth, direction etc).
The script is written in ECMA / JavaScript and seamless integrates into QCAD/CAM. CamHelixHole adds an icon to the CAM tool bar and a menu item to the CAM menu to easily run the script.
Apart from some images and the translation, all files are text-based. If you are familiar with JavaScript, you can easily adapt the script to your needs. There is no compilation required.
![]() |
![]() |
![]() |
Requirements
To use this script, you will need the QCAD/CAM software.
Please note that the script will not run with the community edition of QCAD or QCAD Pro (since these versions do not have any CAM support).
The script was developed for QCAD/CAM version 3.31.2 and tested on Linux 64-bit and Windows 64-bit. The generated G-code was tested on LinuxCNC version 2.7.8, but it should also run on other machine controllers. Feel free to adapt the script to your needs (see G-Code template files).
Installation
The installation of the script is really simple. If you have downloaded the script as zip archive, just extract all files to the QCAD/CAM directory on your computer. On Windows the location should normally be "C:\Program Files\QCADCAM". If you already have extracted the script files, just copy all files into the QCAD/CAM directory. However, make sure that the directory structure is preserved. The script files must be located in the subdirectory "scripts\Cam\CamHelixHole" after installation.
After installation, there should be an additional menu item in the CAM menu and also an icon in the CAM tool bar.
Language support
The user interface of the script supports english and german. The language is automatically chosen at startup depending on your QCAD/CAM language setting. After changing the language settings, it is necessary to restart the application.
G-Code template files
The script uses three template files go generate the final g-code output. These files can be used to setup the machine or running additional commands before starting or after ending the processing. For example you might want to start / stop your dust extraction or use cooling mist/flood. This can be achieved by adjusting the template files.
The three template files are in the script directory:
- gcode_template_start_notoolchange.ngc: This file is used to setup the machine and start the spindle when no tool change is needed. Its contents is included before the toolpaths are written.
- gcode_template_start_toolchange.ngc: This file is used to setup the machine, doing the tool change and starting the spindle. Its contents is included before the toolpaths are written.
- gcode_template_end.ngc: This file is included at the end of the output file. It is used to stop the spindle / dust extraction / cooling after the toolpaths are done.
Depending on the Perform tool change setting, only one of the two start-templates is used (either or, not both).
Feel free to modify these files according to your machine setup. Please see section Tool change for more information about enabling/disabling the tool change.
Please note that the files contain the following named parameters: #<_zSafety>, #<_feedrate>, #<_toolNumber> and #<_spindleSpeed>. If named parameters are used, the values of these parameter will be written before including the templates. If the option for using named parameters in G-code is disabled, the strings will be replaced with the according values. So if you need the values, you should keep them in your files.
Usage
First of all, you have to do the drawing. Simply use the circle tools in QCAD/CAM to draw circles at the desired positions. The diameter of the circle will define the diameter of the helical toolpath later. Among other options, you can later choose where in relation to the circle's contour the milling tool will run (on the contour, inside or outside - see Side and direction).
You can also place tabs on the circle's contour using the tab tool if necessary (for more information see Using tabs to hold cutouts).
There are two ways of starting the script:
- You start with an empty selection. Click the CamHelixHole icon in the CAM toolbar or in the CAM menu to run the script. You can also use the shortcut K, H or type "camhelix" into the command line. Now the mouse pointer changes to a cross hair and you can select the circles that you want to generate a toolpath for by clicking at them one by one. If you accidentally selected a circle, just click it again to remove it from the selection. If done, click the right mouse button or the ESC key to finish the selection. Then the configuration dialog will show up.
- Select all circles you want to generate a toolpath for before starting the script. This can be easier and faster than than method 1., especially if you want to select lot of circles. QCAD/CAM supports a lot different ways to select items (for example by just dragging a rectangle over the screen with the mouse or by selecting whole layers). Now start the script (using the icon, menu item, shortcut K, H or command "camhelix"). If other entities than circles are part of the selection, they will be automatically deselected (since the script only works on circles). The configuration dialog will show up.
Note: Select only that circles together for which you want to use the same milling settings (like tool, cutting depth, speeds, feeds, side and direction settings). Of course the diameter of the circles may differ since this parameter is taken from the circle entities.
In the dialog you can configure the different settings for the toolpath and the generated G-code.
The information area at the top shows the number of the selected circles and the diameter of the smallest hole. The latter is important if you want to mill at the inside of the. In this case, the diameter of the smallest hole is identical to the largest possible mill diameter. The options are described below.
Options
Tool, spindle speed and feed rate
Select the tool you want to use for milling the helical holes. The list shows all tools that are configured in the CAM settings of QCAD/CAM. You can use the 'Add tool' button at the right to enter a new tool or the 'Edit tool' button to change an existing tool. Please note: 1. The 'Tool Code' in the 'Add tool' and 'Edit tool' windows will be used to the tool change (if enabled).
2. You must select a tool with type 'mill'. Drills cannot be used for this operation.
The spindle speed depends on the selected tool and can be changed using the 'Edit tool' button.
Please specify the correct feed rate in the according input field. Note that changing the tool automatically changes the feed rate (the feed rate specified for that tool is taken).
But after selecting the tool, you can overwrite it by entering a different value.
Tool change
If you have an automatic tool changer (or if you have configured your machine for manual tool change), enable the checkbox 'Perform tool change'. This includes the according G-code template into the G-code and sets the according tool number. If unchecked, you will have to make sure that the correct tool is already in the machine before starting the G-code program!
Height settings, cutting depth and infeed
In the configuration dialog, you can specify the safety height (a), the starting height (b) and the cutting depth (c):
Safety height (a) is the height of the Z-axis used for rapid moving between the holes (using G-code command 'G0'). Make sure that this height is above all obstacles to avoid breaking your tool or clamps.
Starting height (b) is the Z-height where the milling operation will begin. Usually this is identical to the workpiece top. From this height, movements are made with the specified feed rate (using G-code command 'G1').
Cutting depth (c) is the height of the Z-axis where the milling operation will end. Usually this is the value of 'Starting height (b)' minus your workpiece height.
Please see the image at the right of the input fields. The values for these three parameters must be either decreasing or increasing order. This depends on your Z-axis configuration.
If a larger Z-value means a higher tool on your machine, you need to specify decreasing values. This means that 'Safety height a' must be greater than 'Starting height b' which in turn has to be greater than 'Cutting depth c' (a ≥ b ≥ c).
If a smaller Z-value means a higher tool on your machine, you need to specify increasing values. This means that 'Safety height a' must be smaller than 'Starting height b' which in turn has to be smaller than 'Cutting depth c' (a ≤ b ≤ c).
Z-increment per round specifies the infeed amount per turn.
If you are unsure about the correct settings, please make sure to verify the generated G-code before starting the machining!
Side and direction
Side:You can select where the tool should mill in relation to the circle's contour. If you choose 'On circle', the diameter of the contour will be the diameter of the toolpath. 'Inside circle' means that the diameter of the toolpath will be equal to 'diameter of the circle - tool diameter'. So the inside of the circle will be removed. Accordingly 'Outside circle' means that the diameter of the toolpath will be equal to 'diameter of the circle + tool diameter. In this case, the tool removes the material outside the circle (for example if you want to make something with a round outer shape).
Direction:You can choose the cutting direction. Climb cutting or conventional cutting.
The image to the right of the choices clarifies the meanings.
Named parameters in G-code
When this option is enabled, named parameters (or variables) are used in the G-code output. This might increase the readability of the G-code, but it can also make it easier when editing the file. For example, if you want to change the radius of certain holes directly or the cutting depth directly at the machine without regenerating the whole toolpath in QCAD/CAM. In this case it would be easier to adjust the parameters and it is not necessary to change a different numbers in a lot of lines. Since not all machine controllers support named parameters, you can disable this option if your machine does not.
Optimize processing order of holes
If you want to mill several holes with the same parameters, it might be a good idea to think about the processing order. By optimizing the order, the way your machine has to travel can be reduced (and thus the time needed). The CamHelixHole script includes different optimization algorithms. The used algorithms are:
- Brute force: This algorithm calculates all possible combinations of the order of the holes to find the shortest path. It should find the best possible solution (considering the specified start position). Since the computational effort is very high for increasing hole numbers, this algorithm is only used for 10 or less holes.
- Ant colony optimization with 2-opt and 3-opt: This algorithm works like the pheromone-based communication between ants in the real life. The solutions are optimized using the 2-opt heuristic after each loop and the 3-opt heuristic in the last step. It is not claimed that the best solution is found, but a solution that is good enough in most cases. So this is a trade of between good results and computational time and is used for hole numbers from 11 to 100.
- Ant colony optimization with 2-opt: This is the same as above, just without the 3-opt heuristic at the end. It is used for up to 150 holes.
- Nearest neighbour: This very simple algorithm begins at the specified starting coordinates and chooses its nearest neighbour in each step (the hole with the shortest distance to the current position). The result is not very good and often far away from the best possible path. But its computational time is very low and so it is used for more that 150 holes (and should be able to optimize thousands of holes).
All these algorithms use the given start position. For example this may be coordinates of the machine after doing the tool change or the position of the machine after running a previous toolpath.
If you do not need this feature at all, you can disable it using the according checkbox. In this case, the script just writes the G-code in the order it gets the data from QCAD/CAM. However, you can still specify the order you want to use by starting the script using method 1. (see Usage): If you disable optimization, the order in the G-code file will be the order in that you selected the circles.
Using tabs to hold cutouts
Tabs are small connections between a cutout and the surrounding material. They can be used to hold a piece at its position while cutting it out. The script supports generating tabs.
To use them, you will need to place the tabs directly onto the circle's contour. To do this, choose 'On Entitiy' in the snapping tools of QCAD/CAM. Then set the length and thickness of the tab in the propery editor. The length specifies the horizontal amount of material that will remain between the cuts. The thickness corresponds to the height of the tab measured from the bottom of the workpiece. Example: Your material is 10mm thick and you set 'Starting height (b)' to 0mm and 'Cutting depth (c)' to -10mm. You want a 2mm thick tab. In this case, the tab will begin at a Z-height of -8mm and will go down to -10mm. The material above the tab(s) will be removed by a helical toolpath, the material between the tab(s) will be removed by milling horizontal arcs and plunging vertically into the material.
Please note the following:
1. The tabs are only generated if they are visible. If you a looking for a simple and fast way to disable / enable the tabs, simply put all tabs on a seperate layer. By toggling the visibility of the layer, the tabs are generated (if visible) or not (if hidden).
2. The script will only generate tabs if there will be a left-over inside the hole. If you cut for example on the inside a circle with 10mm diameter, a tool with diameter of 5mm or more will result in no left-over (everything is milled away).
Legal information / Disclaimer
This script / software was developed for the author's own use and was made available for free use. The author assumes no liability for the correctness, accuracy or completeness of the software and there are no guarantees of any kind (e.g. for certain functions, etc.). No claims can be made against the author (for example to correct errors or similar). Furthermore, any liability for harm, damages or consequential damages arising in connection with or through the use of this software is excluded. Use at your own risk.
Be sure to check the generated GCode before starting the machine!

