//----------------------------------------------------------------// // This macro will help automate reducing corners. Generally, // // we go from 3/4 to 1/4 cutters. The user should select the 3/4 // // toolpaths that they want to use the workplanes and boundaries // // from and then run the macro. Select toolpaths & run again for // // each desired diameter. // // written by David 6/20/2019 // // Jesus is Lord! // //----------------------------------------------------------------// // UPDATES // //----------------------------------------------------------------// // 09/27/2019 - DRA - added more logic & functionality // // // // 06/16/2020 - DRA - completely revamped using pull down menus // // for tool selection, naming & referencing // // the function below the main function. // // // // 07/16/2020 - DRA - added code for 3/32 & 1/32 tools, cleaned // // up the logic some // // 10/07/2021 - DRA - added 'while' loop to go through all tools // // before exiting the macro. // // 10/13/2021 - DRA - add option to batch or not // // 01/12/2022 - DRA - pass in User\AppData folder path // // 05/17/2022 - DRA - make sure orientation vectors are off // //----------------------------------------------------------------// // Some functions used in this macro may be located another file. // // If there is an error or the macro does not function properly, // // please report it to the developer: info@anchorcadcam.com // //----------------------------------------------------------------// // This macro (all code and included functions) is the // // intellectual property of David R.W. Adam (unless credited to // // other users). Any unauthorized copy or use of these without // // expressed permission is strictly prohibited. // //----------------------------------------------------------------// reset localvars FUNCTION Main(STRING userAppDataPath) { // Create the question on whether or not // to repeat the macro & batch the toolpaths; // make the yes answers true STRING promptAnother = "Run another tool?" BOOL carryon = 0 STRING promptForBatch = "Batch Process?" BOOL batch = 0 // Run the macro to create corner toolpaths CALL CornerMarco(userAppDataPath) // Pop up the diaglog to inqure about // running it again $carryon = QUERY $promptAnother // Execute the commands WHILE $carryon { CALL CornerMarco(userAppDataPath) $carryon = QUERY $promptAnother } PROJECT SAVE // Pop up the diaglog to inqure about // batch processing $batch = QUERY $promptForBatch IF $batch == true { BATCH PROCESS PROJECT SAVE } } //---------------------// // FUNCTIONS // //---------------------// // Run the Macro FUNCTION CornerMarco(STRING userAppDataPath) { // check for selected entities, and make sure those // selected are toolpaths INT $i = size(explorer_selected_entities()) IF $i > 0 { ENTITY ent = explorer_selected_entities()[0] IF $ent.RootType != "toolpath" { MACRO PAUSE "No toolpaths have been selected." + CRLF + "Select toolpaths." } } // select cutting & reference tool, make a place holder for // boundary & start a counter STRING cutTool = INPUT ENTITY TOOL "Select Tool To Use" STRING refTool = INPUT ENTITY TOOL "Select Reference Tool" STRING tlDia = substring(tokens(entity('tool', cutTool).Name)[0], 1, 5) STRING templateName = $tlDia + "-" STRING bnName = "" REAL rspm = "" REAL ispm = "" // loop through all the selected toolpaths and make the corner // finishers according to the selected cutting tool FOREACH tp IN explorer_selected_entities() { ACTIVATE WORKPLANE $tp.workplane IF entity_exists($tp.boundary) { $bnName = $tp.boundary.name } SWITCH $tlDia { CASE "3/4" $rspm = 8500.0 $ispm = 500.0 BREAK CASE "1/2" $rspm = 6000.0 $ispm = 350.0 BREAK CASE "3/8" $rspm = 5000.0 $ispm = 300.0 BREAK CASE "1/4" $rspm = 7500.0 $ispm = 300.0 BREAK CASE "3/16" $rspm = 7000.0 $ispm = 250.0 BREAK CASE "1/8" $rspm = 6500.0 $ispm = 150.0 BREAK CASE "3/32" $rspm = 6500.0 $ispm = 50.0 BREAK CASE "1/16" $rspm = 6500.0 $ispm = 50.0 BREAK CASE "1/32" $rspm = 6500.0 $ispm = 25.0 BREAK } // create the toolpath(s) with the appropriate names and // paramters CALL CornerFinisher(bnName, cutTool, refTool, rspm, ispm, templateName, userAppDataPath) // clear the value for the boundary variable $bnName = "" } // reset the naming template to the // default behavior EDIT ENTATTRIBUTE TEMPLATE TOOLPATH ; } // Import & create toolpath(s) FUNCTION CornerFinisher(STRING bnName, STRING cutTool, STRING refTool, REAL rspm, REAL ispm, STRING templateName, STRING userAppDataPath) { $userAppDataPath = "'"+$userAppDataPath+"\Button Window\Toolpath Templates\Corners.ptf'" STRING myCmd = "IMPORT TEMPLATE ENTITY TOOLPATH TMPLTSELECTORGUI $userAppDataPath" EDIT ENTATTRIBUTE TEMPLATE TOOLPATH $templateName DOCOMMAND $myCmd ACTIVATE TOOL $cutTool EDIT PAR 'Strategy' 'along_corner' ACTIVATE BOUNDARY $bnName EDIT PAR 'BoundaryLimit.Keep' 'inside' EDIT PAR 'StockEngagement.MachineStockOnly' 0 EDIT PAR 'Cusp.Height' ".001" EDIT PAR 'CutDirection' 'any' EDIT PAR 'Tolerance' ".001" EDIT FINCORNER REFTOOL NAME $refTool EDIT PAR 'RemoveDeepCuts' '0' EDIT PAR 'Overlap' ".025" EDIT PAR 'CollisionCheck' '1' EDIT PAR 'Clearance.Holder' ".06" EDIT PAR 'ActionOnCollision' 'keep' EDIT TOOLAXIS TYPE VERTICAL EDIT TOOLAXIS ORIENTATION OFF EDIT PAR 'PolarMilling.Active' '0' EDIT RPM $rspm EDIT FRATE $ispm EDIT PRATE "150" EDIT TOOLPATH ; REAPPLYFROMGUI }