Script Editing - Tutorial 3 - Wrench slot

In this tutorial we are going to build a script to create a recurrent machining , the wrench key slot ( i don't know the exact name ) .

It's used to position the wrench tool and screw the component into other assembly.

Wrench tool


Summary steps :

  • Draw the 2 segment as drive curves . It's important consider line direction correctly, since the side milling machining works on right side by default.
  • Draw the outer circle , this is going to be used to trim the toolpath . To do so is enough link it as GeometryMode.StockProfile.
  • Create the machining work, SIDE MILLING type.
  • Link the 2 segments with the newly created machining work.
  • Link the outer circle. In this case link the circle as GeometryMode.StockProfile.
  • Create the roughing operation.
  • Search the tool . If the outer diameter less than 30mm, search for a 10mm endmill, otherwise if the outer diameter is bigger or equal to 30mm, search a 20mm endmill.

Here the final script :

/// <summary>
/// Create Wrench slot with side milling machining
/// </summary>
public void CreateWrenchKeySlot(double key = 17, double diameter = 20)
{
    var halfDiameter = diameter / 2;
    var halfDistance = key / 2;

    //
    // CREATE GEOMETRY - THE DIRECTION IS IMPORTANT , SINCE THE SIDE MILLING WORKS ON RIGHT SIDE BY DEFAULT
    var line1 = new Line(halfDiameter, halfDistance, 0, -halfDiameter, halfDistance, 0);
    var line2 = new Line(-halfDiameter, -halfDistance, 0, halfDiameter, -halfDistance, 0);

    var outerCircle = new Circle(0, 0, 0, diameter / 2);

    //
    // CREATE WORKS AND SUB OPERATION

    var millingWork = AddMachineWork(WorkType.Mill_SideMilling);

    millingWork.MillingParams.MaterialToRemove = halfDiameter - halfDistance;

    //
    // ASSOCIATE GENERATED GEOMETRY WITH MACHINE WORKS

    LinkGeometryToWork(millingWork, line1);
    LinkGeometryToWork(millingWork, line2);

    // I linked the outer circle as STOCK PROFILE to trim toolpath
    LinkGeometryToWork(millingWork, outerCircle, GeometryMode.StockProfile);


    //
    // CREATE SUB-OPERATION
    var roughingSubOp = millingWork.AddSubOperation(SubOperationType.Roughing);


    //FOR BIGGER CIRCLE DIAMETER I CHOOSE A BIGGER TOOL
    var endMillDiameter = 10.0d;

    if (Unit == MeasureUnit.Metric)
    {
        if (diameter >= 30)
            endMillDiameter = 20;
    }
    else
    {
        if (diameter >= 1.2)
            endMillDiameter = 0.8;
    }

    roughingSubOp.Tool = FindRotaryTool(ToolType.MillType_EndMill, endMillDiameter);
}

results matching ""

    No results matching ""