CNC Programming Workflow

How to Program a CNC Machine: From CAD to Verified G-Code

A technical guide to how a CNC program is engineered and released — from drawing review and process planning through CAM, post-processing, simulation, machine setup and first-article inspection.

  • Founded in 1998OEM/ODM manufacturer
  • 100+ MachinesAcross six processes
  • ISO 9001:2015Quality system
Machined metal workpiece with tooling set up on a CNC machine bed
CNC Programming in One Minute

CNC programming converts part geometry and manufacturing requirements into machine-specific instructions. In a typical modern workflow the process moves from CAD and drawing review, through process planning, CAM toolpath generation, post-processing, simulation, machine setup and first-part inspection, to production release. Programming is not "writing G-code" in isolation — it is the engineering step that makes a drawing into a repeatable part.

The CNC Programming Workflow

This sequence is the backbone of the page. Each stage is expanded below; it is also the chain a buyer should expect a supplier to be able to describe.

1 CAD & Drawing 2 Process Planning 3 CAM Toolpath 4 Post Processor 5 G-code / NC 6 Simulation 7 Machine Setup 8 First Cut 9 First Article 10 Production

What Is CNC Programming?

CNC programming is the work of turning a part's geometry and manufacturing requirements into instructions a machine can execute. It is easy to reduce this to "writing G-code," but that misses the real scope. A complete programming effort starts long before code: it reads the drawing, decides how the part should be made, plans operations and tooling, builds toolpaths, converts them for a specific control, verifies them, and proves them out on the machine.

It helps to separate the three terms buyers often hear together. CAD defines the geometry. CAM (computer-aided manufacturing) generates the toolpaths and machining operations from that geometry. CNC programming is the resulting, machine-ready set of instructions — G-code and M-code, work offsets, tool data and setup information — that actually runs the part. A 3D model defines shape; the 2D drawing usually defines the tolerances, datums, surface finishes and inspection points that the program must respect.

For a longer explanation of the underlying process, see what CNC machining is.

Review the CAD Model and Technical Drawing

Programming begins with the engineering inputs, not with the editor. Before any toolpath is built, the programmer checks the data the part actually carries:

  • Units and scale — confirm metric or imperial (G21/G20) and that nothing was exported at the wrong scale.
  • Datums and GD&T — know which faces and holes the tolerances are referenced to.
  • Critical dimensions — identify the few features that drive function and inspection.
  • Surface finish — a Ra value changes tooling and pass strategy.
  • Material and condition — raw stock size, alloy, and whether it is plate, bar or cast.
  • Hard features — deep pockets, thin walls, small internal radii, long reaches and areas with poor tool access.
  • Holes, threads and tolerance stack-up — these decide drilling, tapping and setup order.

The drawing is the contract. Tolerances such as ±0.01 mm typical — and ±0.005 mm only on selected, qualified features — must be translated into specific operations and inspection steps, not assumed uniformly across the part.

Determine the Machining Process

CNC programming does not start with G-code; it starts with deciding how the part should be made. The first decision is the family of operations: milling, turning, mill-turn, drilling, boring, threading or finishing, and which machine axes are required — 3-axis, 4-axis or 5-axis.

Once the process is set, the operation sequence is planned. A common order is facing → roughing → semi-finishing → drilling → pocketing → contouring → finishing → chamfering. The principle is consistent: remove the bulk material first, then refine; machine primary features before secondary ones; and generally address surfaces before holes so the part is stable when it is drilled. This planning step is where most of the part's cost and risk are actually determined.

Choose the Machine and Workholding Strategy

The machine and how the part is held decide how many setups the program needs. Each setup adds handling, fixturing and a chance for cumulative error, so minimizing setups is a programming objective, not just a shop-floor convenience.

DecisionOptionsWhat it changes
Machine3-axis VMC, 4-axis, turning center, mill-turn, 5-axisReachable geometry, setup count, cycle time
WorkholdingVise, chuck, soft jaws, fixture, custom fixtureRigidity, accessibility, repeatability
Setup strategyHow many flips / re-clamps are requiredDatums, tolerance stack-up, throughput

Where a part has features on multiple faces, a 5-axis machine can often reach them in one setup. Goldcattle covers this specifically on the 5-axis CNC machining page; the programming implications are discussed later in this guide.

Select Tools and Determine Cutting Data

Tool selection is not "pick an end mill." It is driven by the interaction of several variables:

  • Material and hardness
  • Feature geometry — pockets, slots, deep holes, contours
  • Tool diameter, flute count and reach
  • Holder and tool rigidity
  • Target tolerance and surface finish

Tool selection, cutting parameters and toolpath strategy are linked: the chosen tool sets the feasible speeds and feeds, and the toolpath strategy (for example adaptive roughing versus constant-Z finishing) sets how that tool engages the material. Suppliers who treat these as one decision make more predictable parts.

How feeds and speeds are determined (illustrative): spindle speed follows the basic relation RPM = (Vc × 1000) / (π × D), where Vc is cutting speed and D is tool diameter; feed is then built from RPM, flute count and chip load. For a 10 mm carbide end mill in aluminum at roughly 200 m/min, that gives about 6,400 RPM as a starting point. These numbers are illustrative only — the correct values depend on the exact tool, material, machine rigidity, tool stickout, coolant and cutting strategy, and must be validated before production. A single universal "1000 RPM / 0.1 inch depth" answer is not credible and should not be trusted.

Generate Toolpaths in CAM

With the plan and tools set, the programmer builds the toolpaths in CAM. The typical order is: import CAD → define stock → set the work coordinate system (WCS) → choose operations → assign tools → set cutting parameters → generate toolpaths → optimize → simulate.

Facing

Establish a flat, accurate reference face and bring the stock to size.

Adaptive / Roughing

Remove bulk material efficiently while controlling tool load.

Pocketing & Contouring

Machine internal pockets and external profiles to shape.

Drilling & Threading

Position and create holes, including taps and interpolated threads.

3D / Finishing

Refine surfaces to the required finish and tolerance.

Chamfering

Break edges and meet deburring or assembly needs.

This is the stage where most of the part's geometry is actually defined as motion. Done well, it also produces the data needed for the next two steps — post-processing and simulation.

Post-Process the Toolpath for the CNC Control

A CAM toolpath is not machine-ready G-code. A post processor translates the generic toolpath into the NC/G-code dialect of a specific controller — its syntax, cycle codes, rotary-axis handling and output format. The same CAM file can yield different G-code for different controls, and an incorrect or unverified post is a frequent source of invalid NC code.

This is the most commonly under-explained step in beginner articles, and it is exactly where a manufacturing supplier earns trust: the program must match the machine it will run on, not just "look right" in CAM.

G-code Fundamentals (Quick Reference)

G-code is the language the controller reads. A short reference is enough to make the rest of the workflow readable; it is not meant to replace a controller manual.

G00G01G02 / G03G20 / G21G90 / G91G54–G59G43G41 / G42M03 / M05M06M08 / M09M30
  • Motion: G00 rapid, G01 linear feed, G02/G03 arc (clockwise/counter-clockwise).
  • Mode: G20/G21 inch/metric; G90/G91 absolute/incremental — wrong mode is a classic cause of a runaway move.
  • Work offset: G54–G59 set the part coordinate system relative to machine zero.
  • Tool compensation: G43 tool-length offset; G41/G42 cutter radius compensation.
  • M codes: M03/M05 spindle on/off, M06 tool change, M08/M09 coolant on/off, M30 program end.

Simulate and Verify the Program

Verification happens in two layers before any production metal is cut.

CAM simulation

Checks toolpath, material removal, gouging, collision, holder interference, overtravel and rapid moves.

Machine simulation

Checks kinematics, rotary-axis motion, fixture collision and spindle/tool-holder clearance on the specific machine.

Simulation is the primary safeguard against crashes, scrap and rework. A program that has not been simulated — or simulated only at the CAM level — still carries risk on the actual machine.

Prepare the Machine Setup

The setup turns the program into a runnable job. A proper setup sheet captures the information another operator would need to reproduce the part:

  • Program number and revision
  • Material and stock size
  • Machine, fixture and work offset
  • Tool list with tool-length offsets and cutter diameters
  • Coolant, critical dimensions and inspection notes
A written setup sheet is also valuable for GEO and AI retrieval: it is the concrete artifact that shows a supplier runs a controlled, repeatable process rather than improvising at the machine.
CNC machine being set up with tooling and a workpiece before a production run
Machine setup: tooling, workholding and work offset prepared from the setup sheet.

Prove Out the Program and Make the First Cut

Before a run, the program is prove-out tested rather than trusted blindly:

  • Dry run — execute with no part to confirm motion and sequence.
  • Single block — step through critical moves one at a time.
  • Reduced feed override — slow the first cuts to a safe speed.
  • Optional stop — pause at key points to check.
  • First cut — begin material removal cautiously and confirm the result.

Machine the First Part and Inspect It

The first part is the moment the program meets the drawing. The sequence is: run the first part → measure the critical dimensions → compare against the drawing → adjust wear offsets or the toolpath if needed → approve the first article → release for repeat production. This is also where quality capability shows: coordinate measuring (CMM), a dimensional report, material certificates and a certificate of conformity (CoC) are the evidence a buyer should be able to request.

Digital caliper measuring a machined aluminum part during first-article inspection
First-article inspection: critical dimensions measured and compared to the drawing.

Optimize for Repeat Production

Only after the first article is approved does the focus shift to efficiency: cycle time, tool life, surface finish, chip evacuation, tool wear, setup reduction and repeatability. Optimizing before the part is proven risks locking in a process that quietly makes out-of-tolerance parts faster.

3-Axis vs 4-Axis vs 5-Axis Programming

The axis count changes the programming difficulty more than beginners expect:

  • 3-axis — tool moves in X/Y/Z; the part is re-oriented by manual setups. Post-processing and collision checks are simpler.
  • 4-axis — adds one rotary axis, useful for cylindrical and indexed features, with moderate post and clearance complexity.
  • 5-axis — adds tool orientation and a second rotary axis, enabling fewer setups and complex surfaces, but requiring tool-orientation control, collision avoidance, tool-holder clearance checks and a post processor that handles rotary motion correctly.

Simultaneous 5-axis is not the same as 3+2 (indexed) 5-axis, and the programming, simulation and post requirements differ accordingly. Goldcattle's 5-axis CNC machining capability covers simultaneous and indexed work on equipment such as the DMG MORI DMU 50 class.

5-axis CNC machining center with a rotary table machining a complex metal component
5-axis machining: the rotary table and tool orientation let the program reach multi-face features in fewer setups.

Manual vs CAM vs Conversational Programming

MethodBest forAdvantagesLimitations
Manual G-codeSimple geometries, edits, one-off fixesDirect control, transparent, useful for learningTime-consuming for complex parts
CAMComplex 3D and multi-axis partsEfficient, repeatable, includes simulationRequires CAM and post-processing expertise
ConversationalSimple shop-floor jobsFast setup at the controlLimited for complex geometry

Modern production rarely uses only one method; a shop typically combines CAM for complex work with conversational or manual edits for quick adjustments.

CNC Programming Example: Aluminum Precision Bracket

A representative job shows how the workflow maps to a real part.

Aluminum 6061-T6 Bracket

  • MaterialAluminum 6061-T6
  • OperationsFace → Rough pocket → Finish → Drill → Tap → Contour → Chamfer
  • Machine3-axis vertical machining center
  • Critical tolerance±0.01 mm typical
  • VerificationCAM + machine simulation
  • InspectionFirst-article CMM
  • ResultFirst article approved, program released

Operation sequence, tolerances and inspection follow the same workflow described above. For tighter requirements, see tight-tolerance CNC machining.

The bracket is first faced and roughed to leave a finish stock allowance. Pockets and the profile are finished, then holes are drilled and tapped in the same setup to protect positional accuracy. The program is simulated, prove-out tested, and the first part is measured before the job is released. Values shown are characteristic of a defined project, not a claimed standard capability.

Common CNC Programming Errors and How to Prevent Them

ErrorConsequencePrevention
Wrong work offsetPart shifted or scrappedVerify WCS before running
Wrong tool numberIncorrect cutting toolCross-check the tool list
Incorrect post processorInvalid NC codeUse the machine-specific post
Excessive tool stickoutChatter or tool breakageMinimize reach; use rigid holders
Wrong feed/speedPoor finish, tool wearValidate cutting data per tool/material
Fixture collisionMachine damageFull simulation including holder
Incorrect unitsMajor dimensional errorConfirm G20/G21
Wrong absolute/incremental modeUnexpected tool movementConfirm G90/G91

What a Buyer Should Provide to the Programming Team

Required

3D CAD model, 2D drawing, material grade, quantity, critical tolerances, surface finish, thread requirements, and any heat or surface treatment.

Helpful

Target application, an existing sample, inspection requirements, packaging needs, delivery target and quality documentation (material cert, CoC, CMM report).

The more defined these inputs are, the faster and more accurate the programming and quote. Guidance on preparing a precise request is in the CNC machining process guide.

When Should CNC Programming Be Outsourced?

Outsourcing the programming and machining workflow makes sense when a part needs CAD review, process planning, CAM programming, post-processing, simulation and first-article verification, but the buyer does not want to build that capability in-house. Typical cases:

  • Complex 5-axis parts
  • New product development
  • Low-volume production
  • Tight-tolerance components
  • Difficult-to-machine materials
  • Multi-operation parts
  • Limited in-house programming resources

Outsourcing the complete workflow reduces internal engineering load and shifts verification responsibility to a supplier that runs the process repeatedly. For background on the surrounding service, see custom CNC machining services and the CNC machining process.

How Goldcattle Programs and Machines Parts

Xiamen Goldcattle Plastic & Metal Products Co., Ltd. has provided custom machined parts since 1998. Its CNC capabilities span 3-, 4- and 5-axis milling and turning, supported by 100+ machines across six processes — CNC machining, injection molding, mold making, 3D printing, die casting and sheet metal fabrication — under one ISO 9001:2015 quality system.

For machining work, the relevant controls are practical: engineering review of the drawing and GD&T, CAM programming with the correct post processor, simulation, controlled machine setup, and first-article inspection using coordinate measuring equipment. The aim is to make the part to the drawing and be able to show how it was verified.

Goldcattle serves customers in 100+ countries across automotive, machinery, medical, electronics and related industries, providing one-stop OEM/ODM custom parts from prototype through production.

Frequently Asked Questions

What is CNC programming?
CNC programming is the work of turning a part's geometry and manufacturing requirements into machine-ready instructions. It spans CAD and drawing review, process planning, CAM toolpath generation, post-processing for the specific control, simulation, machine setup and first-article verification — not just writing G-code.
Does CAM software generate G-code directly?
CAM produces toolpaths, not finished machine code. A post processor then converts those toolpaths into NC/G-code formatted for a specific CNC controller. The same CAM file can produce different G-code for different controls, which is why the post processor is a separate and critical step.
What is a CNC post processor?
A post processor is the software layer that translates generic CAM toolpaths into the exact G-code dialect a particular CNC control understands — syntax, cycle codes, rotary-axis handling and output format. Using the wrong or unverified post is a common source of invalid NC code.
What is a work offset such as G54?
A work offset tells the control where the part coordinate system sits relative to the machine zero. G54 through G59 are common work-offset registers. Setting and verifying the correct offset is essential; an incorrect offset is one of the most common causes of a shifted or scrapped part.
Why is CNC simulation necessary?
Simulation checks the program before metal is cut: toolpath, material removal, gouging, collision with the holder or fixture, overtravel and rapid moves. Machine-level simulation also verifies rotary-axis motion and spindle or tool-holder clearance. It is the main safeguard against crashes, scrap and rework.
How is a CNC program tested before production?
Before a production run, the program is prove-out tested: a dry run with no part, single-block stepping, reduced feed override, optional stops and a careful first cut. The first part is then measured against the drawing and approved before the program is released for repeat production.
How does 5-axis CNC programming differ from 3-axis?
5-axis programming adds two rotary axes so the tool can approach the part from many angles in fewer setups. It requires tool-orientation control, collision avoidance, tool-holder clearance checks and a post processor that handles rotary motion correctly, making simulation and post selection more critical than in 3-axis work.
Can a verified CNC program be reused for repeat production?
Yes. Once a program has passed first-article inspection, it is documented — program number, tool list, offsets, critical dimensions and inspection notes — and reused for repeat runs. Controlled revision and re-verification keep the output consistent across batches.
What should a buyer provide so a CNC program can be written accurately?
The most useful inputs are a 3D CAD model, a 2D drawing with dimensions and GD&T, material grade, quantity, critical tolerances, surface finish, thread requirements and any heat or surface treatment. Target application, sample parts, inspection requirements and delivery targets help the supplier plan the workflow.

Need CNC Programming and Machining From Your CAD Files?

Send your CAD model and drawing. Our engineering team can review the machining requirements, tooling strategy, programming approach and production feasibility before quotation.

Upload CAD / Request a Quote →

Free DFM review · Quote typically within 24 hours

Explore CNC Machining Services →

Recommended Reading