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.


```import Part

# 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 = 0.04

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 = tool_holder_length + spindle_dim_x/2
y = 0
z = flange_end + plate_thickness + spindle_dim_y/2
FreeCAD.ActiveDocument.machining_tool.Placement = FreeCAD.Placement(FreeCAD.Vector(x,y,z),R1,v0)