Fusion 360 can work In a variety of different units and even mixed units. To change units in a open document: Go to the browser and scroll to the top. Hover over the 'Units: mm' browser node. An edit icon will appear at the end of the node. Click this icon to edit the units. A command dialog opens and allows you to change units. Example: Fusion 360 exports to STL with 1 unit = 0.001 inch. When imported into Cura, it needs to be scaled by 0.0254 (0.001 inches = 0.0254 mm). It would be nice to see buttons to scale by the common source STL problems (1 unit = 1 inch, 1 unit = 0.001 inch). To install, rename the file extension to.cps and then in the Fusion 360 CAM workspace, select Post Process. At the top it will show the Configuration Folder where post-processors are stored. Just copy the file there, and then it should show up in the drop-down Post Configuration list next time you open the dialog. Feed is generally measured in Inches Per Minute (IPM) and speed is measured in Surface Feet per Minute (SFM). A feed of 10 IPM would drive a tool 10 inches in one minute. If you took an end mill and rolled it along the floor like a tire at 100 SFM it would travel 100 feet in one minute.The only stumbling block was that there was no post-processor for the CNC Shark, so I wrote one. I didn't base it on one of the AutoDesk post files because mostly they're overcomplicated for what the shark can do (we don't need code for coolant, tool changes, radius compensation etc.). I offer this with no guaranty of course, so use at your own risk but so far it has worked well for me. Fair warning, I've only used it on a few simple projects so far and I've only been using millimeters so I haven't tried it using inches. To install, rename the file extension to .cps and then in the Fusion 360 CAM workspace, select Post Process. At the top it will show the Configuration Folder where post-processors are stored. Just copy the file there, and then it should show up in the drop-down Post Configuration list next time you open the dialog. The .tap file it generates can be loaded into the regular control panel and run.
Fusion 360 will run the post-processing with whatever toolpath(s) you have selected, and when using multiple toolpaths they should all use the same tool. I included code to check for this and to display a warning if the tools are of different basic types, diameters, tapers etc. but it doesn't require them to be exactly the same tool because they might differ by non-critical parameters such as cutting length, and even if it flags them as different you have the option to continue. Just pay attention to the comments in the .tap file that show the toolpaths and the tool types in use, to make sure it's what you expected. I also added comments in the .tap showing the overall part size and the total tool travel range in each axis, which I find a useful sanity check to help prevent tool crashes.
Note: The latest version of this post-processor file is now maintained on my web site at http://BrainRight.com/Projects/CNCController, where I have also published details of a new modular CNC controller that I made to run my Shark and other machines. The post-processor is available from a link in the Software section of that page, along with instructions for using it in Fusion 360.
Understanding Units in Fusion 360
Understanding how Fusion 360 uses units is very important in successfully using the API. When using the API the units used by Fusion 360 are always consistent. Getting and setting values always use the internal unit type for that category of units. These unit types are known as database units because these are the same units that Fusion 360 uses internally and how data is saved in the file. These units are:
Lengths - Centimeters
Angles - Radians
Mass - Kilograms
The internal units always use these types without any exceptions. For example, if you call the SketchCurve.length property to get the length of an entity in a sketch, the value returned will always be in centimeters. If you use the Vector3D.angleTo method to measure the angle between two vectors, the resulting angle will always be returned in radians (remember that π radians equals 180 degrees). At first this might not seem ideal because you might want to work in other units. However, this actually makes most things easier because you can always count on the units being consistent and don't have to worry about the current active unit which the user can change. You just write your program to work in the units listed above and it will always work as expected regardless of the active units. The only time you need to worry about unit conversions is when you need to interact with the user by having them enter a value or to display a value.
Units when Communicating with the User
Units become a bit more complicated when interacting with the user. This is because of several reasons. First, the user can choose one of several length units as the default as shown below. This has the side effect of also setting the default mass units. For example, if you choose inches the mass unit is pounds, but if you choose centimeters it is grams. Angles for the user are always in degrees.
A second reason working with the user is more difficult is because when the user enters a value the result is a string that needs to be evaluated to make sure what they entered is valid and then interpreted into a real value. A third reason is that what they enter doesn't necessarily have to be a simple value. Here are three examples of valid entries when specifying the depth of a hole:
- '3' - In this case the result depends on what the user has chosen as the active unit. For example, if they've chosen inches this is interpreted as 3 inches and if they've chosen millimeters this is interpreted as 3 millimeters.
- '3 in' - In this case this is always interpreted as 3 inches, regardless of what the active unit is.
- '3/2' - This results in 3 units of the active unit divided by 2.
- 'hole_depth' - This references an existing parameter. Of course they could also use this as part of an equation, i.e. 'hole_depth / 2'.
Because the user has a lot of flexibility in the way they can specify values and because they can also change the active unit it would be difficult to write code to correctly interpret any string entered by the user. To help with this, the API supports some utilities that convert a user string into internal units. This allows you to take any of the strings in the example above and convert them to a distance value in database units (centimeters).
This is also how Fusion 360 works internally. Any time a user enters any data, it is a string and Fusion 360 has to parse the string and figure out if it's valid and what the real value is. It converts the string into the real value in database units and uses that for all operations within Fusion 360. If a value needs to be displayed to the user, a string is created that is based on the current active unit and other unit settings and displayed to the user.
Using the UnitsManager Object
The UnitsManager object supports functions that make working with units much easier. The code below prompts the user to enter a length using the input box. The input box allows the user to enter any string without any expectation on what the string represents. The code then validates that the entry is a valid length expression and then displays the evaluated results in centimeters.
When you get a value from Fusion 360 or compute it yourself and need to display it to the user you can use the UnitsManager object to format the value so it's in the correct unit and has the correct number of decimals based on the current user preferences.
The length passed in is always expected to be in database units (centimeters) and the formatInternalValue method formats it to be in the specified units. The most common thing to do will be to use the default length, which is what this sample is doing. If you need to specify another unit type besides the default length you can specify it by name.
Most of the functions available on the UnitsManager object have arguments where you need to specify a unit. Units are specified using a string and use the same strings you use when specifying units for a parameter, although the UnitManager is more flexible in how you can combine the units. For example, Fusion 360 won't let you create a parameter for an acceleration by using a combination of existing known unit types such as 'm/s/s' or 'm/s^2'. However, these are valid unit descriptions when used within the UnitsManager. The sample below defines the units using meters and seconds so the result returned is '0.20 m / s^2'.
The last argument indicates if the unit specifier should be appended to the result or if it should just be the value. This ends up displaying the dialog shown below.
Working with Parameters
When discussing units it's important to understand their use with respect to parameters; both editing existing parameters and when creating new objects that rely on parameters. For example, when you create an extrusion that is a defined depth there is a parameter automatically created that controls the depth of the extrusion. In the user interface you enter the depth in the Extrude dialog, which is really a string that is used as the expression of the parameter that will be created. When creating an extrusion using the API there is a little more flexibility in specifying the depth. You can mimic the user interface and provide a string that defines a valid length but the API also supports specifying a real value, which is always in database units (centimeters in this case since it is a length). To be able to specify either a string expression or a real value for the depth, Fusion 360 supports an object called ValueInput that is used any time you're providing a value that will become a parameter. A ValueInput object is a relatively simple object that contains either a real value or a string. When creating a ValueInput object you can use either the ValueInput.createByReal or ValueInput.createByString methods. If you create a ValueInput using a string then the ValueInput will be evaluated the same as other strings entered by the user, as described above. If you create a ValueInput using a real value then the value is assumed to be in database units of whatever unit is needed. For example, in the case of the extrusion the value will be assumed to be in centimeters since the extrusion depth is a length. You can use either option depending on the data you have. If you have a string provided by the user or for some reason want to define an equation you can use createByString. If you've calculated a value then you can use createByReal. The code below demonstrates this. The profile and the part depth have already been obtained.
The ValueInput object serves as a way to pass in either a string or a real value through a single argument. If you pass in a string, that string is used as the equation of the parameter that's created. This means it can include references to other parameters, functions, etc. If you pass in a real value, an equation is computed by Fusion 360 and displayed in the parameters dialog.
When changing the value of a parameter using the API, you have the option of using the expression property, which is a string and is the same as the user using the Parameters dialog to change the value of a parameter. Using the expression property you can enter any valid parameter expression. Internally, Fusion 360 takes this string and evaluates it to make sure it is valid. In addition to setting the expression, the API also supports setting a parameter using a real value through the valueInput property. The real value is assumed to be in database units for whatever unit type is associated with the parameter, and directly assigns it to the parameter. This will override the existing expression and Fusion 360 will create the equivalent expression to display in the dialog. The value shown in the 'Value' column is actually the real internal value converted into a string using something similar to the formatInternalValue method discussed above. It's shown in the current document default unit with the number of decimals specified in preferences. It's only through the API that you have direct access to read and write the internal value.