### Initialize SprutCAM X Machining Tools Import API Source: https://context7.com/sprutcamtech/sprutcam-api-examples/llms.txt Loads the Machining Tools Import API from the SprutCAM X installation directory and initializes the importer. It also demonstrates how to create and open tool storage databases. ```csharp using SprutCAMTech.MachinigToolsImportTypes; using SprutCAMTech.STMachiningToolsImportHelper; // Load the importer from SprutCAM installation string assemblyPath = @"C:\Program Files\SprutCAM Tech\SprutCAM X 17\Bin64\" + MTIMachiningToolsImportHelper.DllName; IMTI_MachiningToolsImportLibrary importer = MTIMachiningToolsImportHelper.CreateImporter(assemblyPath); // Create a new tool storage database IMTI_MachiningToolsStorage storage = importer.CreateNewToolsStorage(@"MyTools.db"); // Or open an existing tool storage IMTI_MachiningToolsStorage existingStorage = importer.OpenExistingToolsStorage(@"ExistingTools.db"); // Clean up when done MTIMachiningToolsImportHelper.FinalizeImporter(); ``` -------------------------------- ### Command Line Interface for DIN4000 Import Plugin Source: https://context7.com/sprutcamtech/sprutcam-api-examples/llms.txt This section details the command-line arguments for the DIN4000ImportPlugin executable, enabling batch processing of tool imports. It supports direct CSV files, ZIP archives containing CSVs, and specifying custom SprutCAM installation paths. ```bash # Import from CSV files directly DIN4000ImportPlugin.exe tools1.csv tools2.csv output.db # Import from ZIP archives containing DIN4000 CSV files DIN4000ImportPlugin.exe DIN4000_Tools1.zip DIN4000_Tools2.zip output.db # Specify custom SprutCAM installation folder DIN4000ImportPlugin.exe tools.csv output.db SCInstallFolder:"C:\Program Files\SprutCAM Tech\SprutCAM X 17" # Mix CSV and ZIP sources DIN4000ImportPlugin.exe direct_tools.csv archived_tools.zip combined_output.db ``` -------------------------------- ### Configure Multi-Step Tool Adapter - C# Source: https://context7.com/sprutcamtech/sprutcam-api-examples/llms.txt Configures multi-step adapters (tool holders) that connect cutting tools to machine spindles. This involves defining the number of steps and their respective diameters and heights for precise dimensional specifications. ```csharp var adapter = tool.GetStepsAdapter(); adapter.HolderName = "Custom HSK-A63 Adapter"; adapter.HolderStepCount = 3; // Define stepped adapter profile adapter.HolderStepDiameter[0] = 20; // First step diameter adapter.HolderStepHeight[0] = 20; // First step height adapter.HolderStepDiameter[1] = 30; // Second step diameter adapter.HolderStepHeight[1] = 10; // Second step height adapter.HolderStepDiameter[2] = 30; // Third step diameter adapter.HolderStepHeight[2] = 60; // Third step height storage.AddToolItem(tool); ``` -------------------------------- ### Create Turning Tool with External Holder - C# Source: https://context7.com/sprutcamtech/sprutcam-api-examples/llms.txt Creates a turning tool with an external holder and insert configuration. This includes setting identification, dimensions, hand orientation, cutting directions, overhang, tooling points, and cutting conditions for lathe operations. ```csharp using THDT = SprutCAMTech.MachinigToolsImportTypes.TMTI_TurnToolHolderDimensionTypes; using TIDT = SprutCAMTech.MachinigToolsImportTypes.TMTI_TurnToolInsertDimensionTypes; var tool = importer.CreateTurnToolWithExternalHolder(); // Set tool identification tool.SetName("External Turning Tool"); tool.SetIdentifier("t001"); tool.SetMagazineNumber(1); tool.SetToolNumber(1); tool.SetUnits(TMTI_LinearUnits.luMillimeter); tool.SetDurability(70); // Configure hand orientation tool.GetHandType().Hand = TMTI_Hand.hRight; // Set holder and insert types bool isCompatible = tool.SetHolderAndInsertType( TMTI_ExternalToolHolderTypes.htA_90deg, TMTI_ExternalToolHolderInsertTypes.itC_80degRhombic); if (isCompatible) { var tdim = tool.GetDimensions(); // Holder dimensions tdim.Holder[THDT.hdL1] = 130; // Overall holder length tdim.Holder[THDT.hdB] = 20; // Holder width tdim.Holder[THDT.hdL3] = 30; // Insert pocket depth tdim.Holder[THDT.hdF1] = 30; // Height to insert // Insert dimensions tdim.Insert[TIDT.idL] = 17; // Insert length tdim.Insert[TIDT.idTi] = 2; // Insert thickness tdim.Insert[TIDT.idRe] = 0.1; // Corner radius } // Configure cutting directions var tdir = tool.GetDirections(); tdir.FixingDirection = TMTI_FixingDirection.fdDirect; tdir.CuttingDirection[TMTI_CuttingDirections.cdS] = true; // South tdir.CuttingDirection[TMTI_CuttingDirections.cdE] = true; // East tdir.CuttingDirection[TMTI_CuttingDirections.cdSE] = true; // Southeast // Configure overhang var overh = tool.GetOverhang(); overh.isAutoCalc = false; overh.Axial = -10; overh.Radial = 121; overh.Matching = 1.5; // Configure tooling points var tpoints = tool.GetToolingPoints(); tpoints.Corrector[0] = 1; tpoints.Corrector[1] = 99; tpoints.TPointX[0] = -2.22; tpoints.TPointX[1] = 1.11; tpoints.TPointY[0] = -1.55; tpoints.TPointY[1] = -0.29; // Configure cutting conditions var cond = tool.GetCuttingConditions(); cond.RotationDirection = TMTI_RotationDirection.rdCCW; cond.CuttingSpeedMode = TMTI_CuttingSpeedMode.csmCSS; cond.Coolant.TubeIsOn[0] = false; cond.Coolant.TubeIsOn[1] = true; cond.Coolant.TubeIsOn[2] = true; cond.FeedValue = 2; storage.AddToolItem(tool); ``` -------------------------------- ### Create Drill Tool in SprutCAM X API Source: https://context7.com/sprutcamtech/sprutcam-api-examples/llms.txt Programmatically creates a drill tool, specifying its dimensions, point angle, and other parameters for hole-making operations. The configured drill is then added to the tool storage. ```csharp var tool = importer.CreateDrill(); tool.OverallLength = 120; tool.CuttingDiameter = 10; // Drill diameter tool.WorkingLength = 80; // Usable flute length tool.ShankDiameter = 10; tool.ShoulderLength = 100; tool.ShankTaperAngle = 45; tool.Angle = 118; // Point angle in degrees tool.SetName("HSS Twist Drill"); tool.SetIdentifier("d001"); tool.SetOverhang(120); storage.AddToolItem(tool); ``` -------------------------------- ### Create Torus Mill Tool in SprutCAM X API Source: https://context7.com/sprutcamtech/sprutcam-api-examples/llms.txt Programmatically creates a torus (bull nose) mill tool, defining its dimensions and corner radius for improved surface finishes. The created tool is then added to the tool storage. ```csharp var tool = importer.CreateTorusMill(); tool.OverallLength = 100; tool.CuttingDiameter = 12; tool.WorkingLength = 25; tool.ShankDiameter = 12; tool.ShoulderLength = 65; tool.ShankTaperAngle = 45; tool.Radius = 2.0; // Corner radius for torus profile tool.SetName("Bull Nose End Mill"); tool.SetIdentifier("bn001"); tool.SetOverhang(100); storage.AddToolItem(tool); ``` -------------------------------- ### Create Custom Axial Shape Tool - C# Source: https://context7.com/sprutcamtech/sprutcam-api-examples/llms.txt Creates a custom axial tool with a user-defined generatrix profile. This allows for special cutting geometries not covered by standard tool types and includes configuration of tooling points. ```csharp var tool = importer.CreateCustomAxialShapeTool(); tool.ToolGroup = TMTI_AxialToolGroup.tgSpherical; tool.OverallLength = 100; tool.SetName("Custom Spherical Mill Tool"); tool.SetIdentifier("s001"); tool.SetTeethsCount(2); tool.SetMagazineNumber(1); tool.SetToolNumber(1); tool.SetUnits(TMTI_LinearUnits.luMillimeter); tool.SetDurability(70); tool.SetMaxPlungeAngle(90); // Define custom generatrix profile var rcv = tool.BeginGeneratrix(); TST2DPoint p = new TST2DPoint() { X = 1, Y = 1 }; TST2DPoint pc = new TST2DPoint() { X = 0.0359, Y = 7.3301 }; // Start with working portion of the curve rcv.SetSpanType(TMTI_CurveSpanType.csfWorking); rcv.StartCurve(p); // Add arc segment p.X = 6; p.Y = 5; rcv.ArcTo(pc, p, 6.4031); // Add straight cutting segment p.X = 6; p.Y = 25; rcv.CutTo(p); // Switch to non-working portion (shank) rcv.SetSpanType(TMTI_CurveSpanType.csfNonWorking); p.X = 6; p.Y = 30; rcv.CutTo(p); p.X = 7.5; p.Y = 40; rcv.CutTo(p); // Configure tooling points var toolings = tool.GetToolingPoints(); toolings.ToolContactPointType = TMTI_AxialToolContactPointType.cpCustomPoint; toolings.ToolContactPointsCount = 1; toolings.ToolingPointCount = 1; toolings.ToolingPointType[0] = TMTI_AxialToolToolingPointType.tpCustomPoint; toolings.ToolingPointShift[0] = 1.5; toolings.ToolingPointLengthCorrectorNumber[0] = 1; toolings.ToolingPointRadiusCorrectorNumber[0] = 1; storage.AddToolItem(tool); ``` -------------------------------- ### C# Tool Conversion from DIN4000 CSV to SprutCAM Source: https://context7.com/sprutcamtech/sprutcam-api-examples/llms.txt The ToolFromCsvMaker class converts DIN4000 tool records parsed from CSV files into SprutCAM's internal tool definitions. It handles different DIN tool types (end mills, ball nose mills, drills) and maps their parameters to the corresponding SprutCAM tool properties. The process involves creating a new tool storage, iterating through records, and adding the converted tools to the storage. Dependencies include the SprutCAM API libraries for tool creation and manipulation. ```csharp public class ToolFromCsvMaker : IDisposable { public int ImportedToolsCount { get; set; } public void ImportRecsToDB(IEnumerable recs, string resultDBFileName) { var importer = LoadImporter(); if (importer == null) return; // Create new storage (delete if exists) if (File.Exists(resultDBFileName)) File.Delete(resultDBFileName); var storage = importer.CreateNewToolsStorage(resultDBFileName); foreach (ToolRecord rec in recs) { var tool = CreateNewTool(importer, rec); if (tool != null) { ImportedToolsCount++; storage.AddToolItem(tool); } } } private IMTI_MachiningToolsItem CreateNewTool(IMTI_MachiningToolsImportLibrary importer, ToolRecord rec) { IMTI_AxialToolItems tool = null; string DINToolType = rec.NSM + "-" + rec.BLD; // Map DIN4000 types to SprutCAM tool types if (DINToolType == "DIN4000-82-1" || DINToolType == "DIN4000-82-2") // End mills { if (rec.G1 != 0) // Has corner radius - create torus mill { tool = importer.CreateTorusMill(); var ctl = tool as IMTI_TorusMill; ctl.OverallLength = rec.B5; ctl.CuttingDiameter = rec.A1; ctl.WorkingLength = rec.B2; ctl.ShankDiameter = rec.C3; ctl.ShoulderLength = rec.B5 - rec.C4; ctl.Radius = rec.G1; } else // No corner radius - create cylindrical mill { tool = importer.CreateCylindricalMill(); var ctl = tool as IMTI_CylindricalMill; ctl.OverallLength = rec.B5; ctl.CuttingDiameter = rec.A1; ctl.WorkingLength = rec.B2; ctl.ShankDiameter = rec.C3; ctl.ShoulderLength = rec.B5 - rec.C4; } } else if (DINToolType == "DIN4000-82-6") // Ball nose mills { tool = importer.CreateSpphericalMill(); var ctl = tool as IMTI_SphericalMill; ctl.OverallLength = rec.B5; ctl.CuttingDiameter = rec.A1; ctl.WorkingLength = rec.B2; ctl.ShankDiameter = rec.C3; ctl.ShoulderLength = rec.B5 - rec.C4; } else if (DINToolType == "DIN4000-81-1") // Drills { tool = importer.CreateDrill(); var ctl = tool as IMTI_Drill; ctl.OverallLength = rec.B5; ctl.CuttingDiameter = rec.A11; ctl.WorkingLength = rec.B4; ctl.ShankDiameter = rec.C3; ctl.ShoulderLength = rec.B5 - rec.C4; ctl.Angle = rec.E1; } if (tool != null) { tool.SetName(rec.J21); tool.SetOverhang(rec.B5); } return tool; } } // Usage: Import DIN4000 tools from ZIP archives containing CSV files var startArgs = new StartArgs(); startArgs.Parse(args); // Parse command line for .zip, .csv, .db files startArgs.UnZipCsvFiles(); // Extract CSV from ZIP archives var recs = new List(); foreach (string csvFileName in startArgs.CsvFiles) DIN4000CsvReader.ReadCsvFile(csvFileName, recs); using var toolMaker = new ToolFromCsvMaker(startArgs.SCInstallFolder); toolMaker.ImportRecsToDB(recs, startArgs.ResultDBFile); Console.WriteLine($"Imported tools count: {toolMaker.ImportedToolsCount}"); startArgs.ClearUnzippedCsvFiles(); // Clean up temporary files ``` -------------------------------- ### Create Spherical Mill Tool in SprutCAM X API Source: https://context7.com/sprutcamtech/sprutcam-api-examples/llms.txt Programmatically creates a spherical (ball nose) mill tool, suitable for 3D contouring and finishing operations. The tool's dimensions and identification are set before adding it to storage. ```csharp var tool = importer.CreateSpphericalMill(); tool.OverallLength = 80; tool.CuttingDiameter = 8; // Ball diameter tool.WorkingLength = 20; tool.ShankDiameter = 8; tool.ShoulderLength = 50; tool.ShankTaperAngle = 45; tool.SetName("Ball Nose Finishing Mill"); tool.SetIdentifier("ball001"); tool.SetOverhang(80); storage.AddToolItem(tool); ``` -------------------------------- ### Create Cylindrical Mill Tool in SprutCAM X API Source: https://context7.com/sprutcamtech/sprutcam-api-examples/llms.txt Programmatically creates a cylindrical end mill tool, setting its physical dimensions, identification, cutting conditions, and coolant tube configurations. The tool is then added to a tool storage database. ```csharp var tool = importer.CreateCylindricalMill(); // Set physical dimensions tool.OverallLength = 100; // Total tool length in mm tool.CuttingDiameter = 10; // Cutting diameter tool.WorkingLength = 30; // Flute length tool.ShankDiameter = 12; // Shank diameter tool.ShoulderLength = 60; // Distance from tip to shank tool.ShankTaperAngle = 40; // Taper angle // Set tool identification tool.SetName("My Cylindrical Mill"); tool.SetIdentifier("m001"); tool.SetTeethsCount(3); tool.SetMagazineNumber(1); tool.SetToolNumber(1); tool.SetUnits(TMTI_LinearUnits.luMillimeter); tool.SetOverhang(155); tool.SetDurability(70); tool.SetMaxPlungeAngle(90); // Configure cutting conditions var cond = tool.GetCuttingConditions(); cond.CuttingSpeedMode = TMTI_CuttingSpeedMode.csmRPM; cond.RotationsPerMinute = 100; cond.SpindleGearRange = 1; cond.RotationDirection = TMTI_RotationDirection.rdCW; cond.FeedUnits = TMTI_FeedUnits.perMinute; cond.FeedValue = 100; // Configure coolant tubes cond.Coolant.TubeIsOn[0] = true; cond.Coolant.TubeIsOn[1] = false; cond.Coolant.TubeIsOn[2] = true; // Add to storage storage.AddToolItem(tool); ``` -------------------------------- ### Read DIN4000 CSV Tools in C# Source: https://context7.com/sprutcamtech/sprutcam-api-examples/llms.txt This C# code defines a `ToolRecord` class to map DIN4000 CSV columns and provides a function `ReadCsvFile` to parse the CSV data. It utilizes the CsvHelper library for efficient CSV processing. The code reads tool geometry parameters like length, diameter, and radius from a specified CSV file. ```csharp using CsvHelper; using CsvHelper.Configuration; using System.Globalization; // Define tool record structure matching DIN4000 CSV columns public class ToolRecord { [Name("J21")] public string J21 { get; set; } // Tool name [Name("NSM")] public string NSM { get; set; } // Standard number [Name("BLD")] public string BLD { get; set; } // Properties layout [Name("B5")][Optional][Default(0)] public double B5 { get; set; } // Overall length [Name("B3")][Optional][Default(0)] public double B3 { get; set; } // Protruding length [Name("B2")][Optional][Default(0)] public double B2 { get; set; } // Depth of cut max [Name("B4")][Optional][Default(0)] public double B4 { get; set; } // Usable length [Name("A1")][Optional][Default(0)] public double A1 { get; set; } // Cutting diameter [Name("A11")][Optional][Default(0)] public double A11 { get; set; } // Cutting diameter step 1 [Name("C3")][Optional][Default(0)] public double C3 { get; set; } // Connection diameter [Name("C4")][Optional][Default(0)] public double C4 { get; set; } // Shank length [Name("G1")][Optional][Default(0)] public double G1 { get; set; } // Corner radius [Name("E1")][Optional][Default(0)] public double E1 { get; set; } // Point angle } // Read CSV file into tool records public static class DIN4000CsvReader { public static void ReadCsvFile(string fileName, List toolRecs) { var config = new CsvConfiguration(CultureInfo.InvariantCulture) { Delimiter = ";", HasHeaderRecord = true, MissingFieldFound = null }; using var reader = new StreamReader(fileName); using var csv = new CsvReader(reader, config); var recs = csv.GetRecords(); foreach (ToolRecord rec in recs) toolRecs.Add(rec); } } // Usage: Import DIN4000 tools from CSV files // var recs = new List(); // DIN4000CsvReader.ReadCsvFile("tools_export.csv", recs); // Console.WriteLine($"Loaded {recs.Count} tool records"); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.