Blog

Object-oriented computer-assisted machining
Feb
10
Sarunas Simaitis

Creating a bicycle is much harder if you have you create all the parts yourself. However, having at least some parts makes the creation process tremendously simpler. Sadly, currently generating cutting instructions to cut parts in a new arrangement in Fusion 360 resembles creating a bicycle from scratch too much.

In this post, we shall apply the principles of object-oriented programming to make the computer-aided machining ( CAM ) in Fusion 360 ( F360 ) faster to design, more reliable and easier to maintain. The post is based on a real-life business problem we experienced and the solution not only made machining side more efficient but also opened up the possibility of using cheap leftover materials at scale.

Object-oriented framework

Computer-aided design ( CAD ) and programming have benefited immensely from the object-oriented approach to the problem. Under this ideology, a big problem is separated into independent smaller problems which are solved in isolation and then put back together. This has a few benefits:

  1. Smaller problems are easier to solve;
  2. Many of the smaller problems have been solved already in other contexts by other people;

In the case of bicycle creation, high-quality CAD designs of common parts like bearings, chains are readily available and usable in tools like F360. Only the unique parts like frame and handles need to be designed and the digital assembly can commence.

The current state of the CAM process

The situation is different when it comes to machining. Suppose a client comes asking to cut some squares and circles from a plywood sheet. The steps then are:

  1. Get a virtual model of those parts. Such parts are easy to recreate ( available at the Autodesk hub — circle, square ), but in other cases those could be retrieved from 3rd parties;
Figure 1. The parts to manufacture

2. The next step is to lay them out on the sheet to be cut. Although this could be done automatically with nesting tools like Deepnest.io, manual copy/paste and drag is sufficient in this case;

Figure 2. The parts laid out on the sheet

3. Create the cutting instructions for the computer numerical control ( CNC ) machine using F360 CAM workspace;

Figure 3. Generated cutting toolpaths

4. Simulate the cutting in the virtual world, identify and correct the problems;

Figure 4. Machining simulation

5. CNC it!

If one is lucky or has spent enough time reviewing all the steps the parts turned out great. However, once in a while the luck will run out or there won’t be enough time and one can only hope that the material wasted was cheap and readily available.

Another issue is that problems in real life are rarely this simple. Suppose the client returns a month later asking to cut the same parts, but this time he is saving on material costs and the sheets are varying leftovers that he had at his shop. The designs are already available so step 1 can be skipped, but other steps need to be redone. What makes matters worse is that they have to be redone for each type of sheet we’ve got!

This gets very time-consuming and error-prone if done with Fusion 360 the naive way. In what comes next we address how to simplify the steps 3 and 4 to increase productivity and product quality.

An object-oriented view of CAM

Start by splitting the problem of machining the sheet into machining of the separate parts. Once cutting instructions for a part are known they just need to be shifted to correspond with the position of the part in the layout.

Figure 5. Toolpaths generated for each part separately

Unfortunately, F360 does not yet support manipulating machining operations from the Python API and before that is the case, we resort to a less elegant approach:

  1. Create CAM instructions for each of the parts ( eg. Figure 5 );
  2. Copy-paste and arrange the part designs into the sheet design ( identical to Figure 2 );
  3. Copy-paste and translate CAM instructions of each part to get the CAM instructions of the sheet;

Step 1 is a small scale version of what was done before and step 2 is the same as in the original approach. To automate step 3 we use F360 Python API. More on how to begin working with Python in Fusion 360 can be found in the previous blogpost.

Start by initialising the modules and setting the file structure:

Note! The post-processor would need to be changed to a relevant one in your case.

Next, we need to traverse the components, extract the machining toolpaths from their respective designs and combine them into a joint toolpath. This can be achieved by creating the following function run in F360 Python script:

Before the toolpath can be run it needs to be verified with simulation. Unfortunately, F360 does not support simulating plain GCODE and an external simulator is needed. To validate our toolpath G-Wizard Editor was used since it properly implements G52 functionality and many of tested simulators have issues with it.

Figure 6. Simulation of the joint GCODE

In Figure 6 one can observe that the script has generated a valid toolpath which achieves the goal. Success!

Conclusions

In this blogpost, the object-oriented approach has been elaborated on in Fusion 360 CAM environment. We have shown how to structure the workflow for increased flexibility.

The main advantages of it are:

  1. Reusability. Once CAM workflow for a part has been optimised it can be reused many times. Most importantly it avoids repeating the same mistakes;
  2. Flexibility. Automatic generation of nesting layouts enables to be much more flexible on the cutting materials. That entails reduced leftovers and more efficient material use;
  3. Maintainability. In case a part has been changed such that it requires different CAM approach it is sufficient to change the CAM section for that part and then each layout can be updated dynamically.

The main drawback is the loss in machining time efficiency. Copy-pasting cutting instructions which are optimal for a single part does necessarily result in efficient sheet cutting instructions. However, it can be viewed as a tradeoff between designer time and machine time. For every shop the associated cost difference is unique and that tradeoff is an individual business decision.

Another approach would be to optimize the joint GCODE to remove duplicate toolpaths, traverse the parts in a more optimal route. In case you know of software which already does that, please let us know in the comments!

Connect!

At 1D.works we’re excited about the potential of AI to improve businesses and people’s lives. CAD and CAM are two of the largely unexplored territories we’re invested in. If you think you can benefit from a decade-long experience of applying machine learning to business processes.

Appendix

For those who want to reuse the script of this blogpost here it is in full:

WARNING! The script is provided for illustration purposes only and use it at your own risk. There are caveats that can lead to a machine break or material waste, so please take precautions to avoid that and we will take no responsibility for the associated costs.

These are a few implicit assumptions we’ve collected along the way, but the list is not nearly exhaustive:

  1. Model origin is at one of the bottom corners of the part;
  2. Nesting layout origin is also at the bottom corner of the sheet;
  3. The part is cut from a single setup;
  4. The part is cut with a single tool;
  5. All the parts are cut with the same tool;
  6. All the parts have the same height;
  7. The parts have the same orientation wrt. the origin in the sheet layout as in their respective designs;
  8. The gap between all the parts in the layout is wider than the widest cutting tool;
  9. …? Have we missed anything? Let us know in the comments!


Object-oriented computer-assisted machining
Sarunas Simaitis
20
Jan
2020

Creating a bicycle is much harder if you have you create all the parts yourself. However, having at least some parts makes the creation process tremendously simpler. Sadly, currently generating cutting instructions to cut parts in a new arrangement in Fusion 360 resembles creating a bicycle from scratch too much.

In this post, we shall apply the principles of object-oriented programming to make the computer-aided machining ( CAM ) in Fusion 360 ( F360 ) faster to design, more reliable and easier to maintain. The post is based on a real-life business problem we experienced and the solution not only made machining side more efficient but also opened up the possibility of using cheap leftover materials at scale.

Object-oriented framework

Computer-aided design ( CAD ) and programming have benefited immensely from the object-oriented approach to the problem. Under this ideology, a big problem is separated into independent smaller problems which are solved in isolation and then put back together. This has a few benefits:

  1. Smaller problems are easier to solve;
  2. Many of the smaller problems have been solved already in other contexts by other people;

In the case of bicycle creation, high-quality CAD designs of common parts like bearings, chains are readily available and usable in tools like F360. Only the unique parts like frame and handles need to be designed and the digital assembly can commence.

The current state of the CAM process

The situation is different when it comes to machining. Suppose a client comes asking to cut some squares and circles from a plywood sheet. The steps then are:

  1. Get a virtual model of those parts. Such parts are easy to recreate ( available at the Autodesk hub — circle, square ), but in other cases those could be retrieved from 3rd parties;
Figure 1. The parts to manufacture

2. The next step is to lay them out on the sheet to be cut. Although this could be done automatically with nesting tools like Deepnest.io, manual copy/paste and drag is sufficient in this case;

Figure 2. The parts laid out on the sheet

3. Create the cutting instructions for the computer numerical control ( CNC ) machine using F360 CAM workspace;

Figure 3. Generated cutting toolpaths

4. Simulate the cutting in the virtual world, identify and correct the problems;

Figure 4. Machining simulation

5. CNC it!

If one is lucky or has spent enough time reviewing all the steps the parts turned out great. However, once in a while the luck will run out or there won’t be enough time and one can only hope that the material wasted was cheap and readily available.

Another issue is that problems in real life are rarely this simple. Suppose the client returns a month later asking to cut the same parts, but this time he is saving on material costs and the sheets are varying leftovers that he had at his shop. The designs are already available so step 1 can be skipped, but other steps need to be redone. What makes matters worse is that they have to be redone for each type of sheet we’ve got!

This gets very time-consuming and error-prone if done with Fusion 360 the naive way. In what comes next we address how to simplify the steps 3 and 4 to increase productivity and product quality.

An object-oriented view of CAM

Start by splitting the problem of machining the sheet into machining of the separate parts. Once cutting instructions for a part are known they just need to be shifted to correspond with the position of the part in the layout.

Figure 5. Toolpaths generated for each part separately

Unfortunately, F360 does not yet support manipulating machining operations from the Python API and before that is the case, we resort to a less elegant approach:

  1. Create CAM instructions for each of the parts ( eg. Figure 5 );
  2. Copy-paste and arrange the part designs into the sheet design ( identical to Figure 2 );
  3. Copy-paste and translate CAM instructions of each part to get the CAM instructions of the sheet;

Step 1 is a small scale version of what was done before and step 2 is the same as in the original approach. To automate step 3 we use F360 Python API. More on how to begin working with Python in Fusion 360 can be found in the previous blogpost.

Start by initialising the modules and setting the file structure:

Note! The post-processor would need to be changed to a relevant one in your case.

Next, we need to traverse the components, extract the machining toolpaths from their respective designs and combine them into a joint toolpath. This can be achieved by creating the following function run in F360 Python script:

Before the toolpath can be run it needs to be verified with simulation. Unfortunately, F360 does not support simulating plain GCODE and an external simulator is needed. To validate our toolpath G-Wizard Editor was used since it properly implements G52 functionality and many of tested simulators have issues with it.

Figure 6. Simulation of the joint GCODE

In Figure 6 one can observe that the script has generated a valid toolpath which achieves the goal. Success!

Conclusions

In this blogpost, the object-oriented approach has been elaborated on in Fusion 360 CAM environment. We have shown how to structure the workflow for increased flexibility.

The main advantages of it are:

  1. Reusability. Once CAM workflow for a part has been optimised it can be reused many times. Most importantly it avoids repeating the same mistakes;
  2. Flexibility. Automatic generation of nesting layouts enables to be much more flexible on the cutting materials. That entails reduced leftovers and more efficient material use;
  3. Maintainability. In case a part has been changed such that it requires different CAM approach it is sufficient to change the CAM section for that part and then each layout can be updated dynamically.

The main drawback is the loss in machining time efficiency. Copy-pasting cutting instructions which are optimal for a single part does necessarily result in efficient sheet cutting instructions. However, it can be viewed as a tradeoff between designer time and machine time. For every shop the associated cost difference is unique and that tradeoff is an individual business decision.

Another approach would be to optimize the joint GCODE to remove duplicate toolpaths, traverse the parts in a more optimal route. In case you know of software which already does that, please let us know in the comments!

Connect!

At 1D.works we’re excited about the potential of AI to improve businesses and people’s lives. CAD and CAM are two of the largely unexplored territories we’re invested in. If you think you can benefit from a decade-long experience of applying machine learning to business processes.

Appendix

For those who want to reuse the script of this blogpost here it is in full:

WARNING! The script is provided for illustration purposes only and use it at your own risk. There are caveats that can lead to a machine break or material waste, so please take precautions to avoid that and we will take no responsibility for the associated costs.

These are a few implicit assumptions we’ve collected along the way, but the list is not nearly exhaustive:

  1. Model origin is at one of the bottom corners of the part;
  2. Nesting layout origin is also at the bottom corner of the sheet;
  3. The part is cut from a single setup;
  4. The part is cut with a single tool;
  5. All the parts are cut with the same tool;
  6. All the parts have the same height;
  7. The parts have the same orientation wrt. the origin in the sheet layout as in their respective designs;
  8. The gap between all the parts in the layout is wider than the widest cutting tool;
  9. …? Have we missed anything? Let us know in the comments!


Contact us

Send a message

We're always looking to make partnership with great companies.
Whether you'd like to start a project, learn more about what we can do for you, or you have any questions please contact us

Contact us

Send a message

We're always looking to make partnership with great companies.
Whether you'd like to start a project, learn more about what we can do for you, or you have any questions please contact us