Exporting G-code from CAM software is a crucial step in bringing designs to life using CNC machines. G-code, the language of CNC machines, provides a detailed set of instructions that govern the machine’s every action.
This Tech Tip points out basic CAM Studio settings so you can start generating G-code from Onshape.
Defining the Coordinate System Orientation in Onshape CAM Studio
In an Onshape document, click the Insert new tab icon (+) at the bottom left corner and select Create CAM Studio. This opens a new CAM Studio tab where you can define your machining operations. From the Component section, click the Add component icon (+), then select the Part, Stock, and Workholding CAD parts.
Select the Jobs section and click the Create job icon. When creating a Job, users have the option to specify how the stock is defined. Choosing User defined stock allows users to specify a CAD part as the Stock body. Stock direction type defines the coordinate system used to output the tool coordinates contained in G-code, so it is important to select the correct option that works with your CNC machine.
Defining the Post Settings in Onshape CAM Studio
Postprocessors are essential for ensuring that the G-code generated by your CAM software is compatible with your specific CNC machine. They act as translators, converting the generic toolpath data into the specific G-code dialect understood by your machine's controller.
In the Jobs section, click the Create machine icon and select your machine from the dropdown list. This ensures the generated G-code is compatible with your specific CNC machine. The Post settings can also be customized in this section to ensure you have the G-code output required for the postprocessor. For example, you might choose to “write Block number at tools only” in the G-code.
Defining the Datum for Coordinate Measurement in Onshape CAM Studio
Machinists use a datum point as the origin for coordinate measurement. Typically, this is a point on the stock part that machinists can touch with the tool. In CAM Studio, this is defined in the Setup section. In the Jobs section, click the Create Setup icon. Select Stock box point as the Position type. From the Position dropdown, select the bottom-most box point, as shown in the Setup below. This is the point with coordinates 0,0,0 in the exported G-code.
Defining the Tool and Toolpath Setting in Onshape CAM Studio
Once the coordinate system and datums are established, machinists need to create tools and specify the toolpaths. This information is transferred to the G-code, which in turn is interpreted by the postprocessor and the machine controller. In CAM Studio, speeds and feeds are specified as part of the settings in the Toolpath section. In particular, from the Posting dropdown, it is possible to specify details such as whether coolant is utilized or not during machining. It is also possible to leave a comment for reference in the generated G-code.
Toggle on Coolant and enter “Using coolant” in the Comments field.
Exporting G-code from Onshape CAM Studio
Export G-code from the Setup. Click the Post child operations icon as shown in the image below.
Open the exported text file. You should see the “Using coolant” comment and the code M8 generated in the file. M8 instructs the controller to turn on coolant flow in the CNC machine.
This file can be imported into Onshape CAM Studio and versioned along with the CAD and CAM models.
This Tech Tip showed you how to export G-code from CAM Studio. To see this workflow in action, watch the following video:
Want more Tech Tips related to CAM Studio? Here’s the latest:
Onshape on YouTube
Subscribe to our channel to stay up-to-date on new product releases, Onshape Tech Tips, and more!