Creating a Parametric Custom Tool in FreeCAD and Importing it Into IRBCAM

https://youtu.be/zp2oarJoSz0

In this tutorial it is demonstrated how to use a parametric Python script in FreeCAD to create a spindle tool which is then imported into IRBCAM.

The parametric script used in the Python Console of FreeCAD to create the spindle tool in the video is shown below. This code was pasted into the Python Console in the YouTube video. By editing the parameters at the top of the script, it is easy to modify the design to suit your own needs.

Before exporting the tool to STL format, it is recommend to fuse the parts, see https://wiki.freecad.org/Part_Fuse

import Part

# Edit the values below to match your own spindle, in unit meters [m]
irbcam_tooldata_x = 0.270
irbcam_tooldata_y = 0.000
irbcam_tooldata_z = 0.160

# Spindle parameters in unit meters [m]
flange_radius = 0.08
flange_end = 0.1
plate_dim = 0.16
plate_thickness = 0.01
spindle_dim_x = 0.4
spindle_dim_y = 0.1
spindle_dim_z = 0.1
tool_holder_radius = 0.03
tool_holder_length = 0.03
tool_radius = 0.01
tool_length = irbcam_tooldata_x - spindle_dim_x/2 - tool_holder_length

v0 = FreeCAD.Vector(0,0,0)
R0 = FreeCAD.Rotation(0,0,0)
R1 = FreeCAD.Rotation(0,90,0)

# Flange
myObj = FreeCAD.ActiveDocument.addObject("Part::Feature","flange")
myObj.Shape = Part.makeCylinder(flange_radius,flange_end)

# Attachment Plate
myObj = FreeCAD.ActiveDocument.addObject("Part::Feature","plate")
myObj.Shape = Part.makeBox(plate_dim,plate_dim,plate_thickness)
x = -plate_dim/2
y = -plate_dim/2
z = flange_end
FreeCAD.ActiveDocument.plate.Placement = FreeCAD.Placement(FreeCAD.Vector(x,y,z),R0,v0)

# Spindle Body
myObj = FreeCAD.ActiveDocument.addObject("Part::Feature","spindle")
myObj.Shape = Part.makeBox(spindle_dim_x,spindle_dim_y,spindle_dim_z)
x = -spindle_dim_x/2
y = -spindle_dim_y/2
z = flange_end + plate_thickness
FreeCAD.ActiveDocument.spindle.Placement = FreeCAD.Placement(FreeCAD.Vector(x,y,z),R0,v0)

# Tool Holder
myObj = FreeCAD.ActiveDocument.addObject("Part::Feature","tool_holder")
myObj.Shape = Part.makeCylinder(tool_holder_radius,tool_holder_length)
x = spindle_dim_x/2
y = 0
z = flange_end + plate_thickness + spindle_dim_y/2
FreeCAD.ActiveDocument.tool_holder.Placement = FreeCAD.Placement(FreeCAD.Vector(x,y,z),R1,v0)

# Machining Tool
myObj = FreeCAD.ActiveDocument.addObject("Part::Feature","machining_tool")
myObj.Shape = Part.makeCylinder(tool_radius,tool_length)
x = irbcam_tooldata_x - tool_length
y = irbcam_tooldata_y
z = irbcam_tooldata_z
FreeCAD.ActiveDocument.machining_tool.Placement = FreeCAD.Placement(FreeCAD.Vector(x,y,z),R1,v0)