// Russell Loveridge - 09/10/04 // This Script is intended to assist with cutting out blocks of material using a 3-axis mill and a single cutting line. //This script sets up a spiralling rectangular d1 line that begins at the 0 level and decends in //stepsized steps to create a cutting line for a block of material. //The parameters are the ssize of the block in millimeters, followed by the toolsize used for offsets, //and a depth factor for changes in z-step sizes depending on density of material. // The block begins with its lower left corner at 0,0 for origin-ing the mill. global proc block_cut (float $x, float $y, float $z, int $toolsize, float $depth_factor) { //declaring the variable needed for the script.... string $points; string $finalpoint; float $current_z; // clear the scene of any extra items.... select -all; delete; // Set the 4 XY corner variables for the material according to the offset of the milling tool.... float $x1 = (-1 * ($toolsize/2)); float $x2 = ($x + ($toolsize/2)); float $y1 = (-1 * ($toolsize/2)); float $y2 = ($y + ($toolsize/2)); //Set the Z step size - including the depth/material factor float $zstep = (($toolsize/2)*$depth_factor); // Set the number of steps required to mill most of the material away, NOTE: the value is rounded to an integer!!! int $steps = ($z/$zstep); // For loop to calculate all of the points required... for($counter=0; $counter<=$steps; $counter++) { // Set the Z value for this itteration of the loop... $current_z =((0-$zstep) * $counter); // Set the values for the 4 corners for this itteration of the loop.... vector $np1 = <<$x1,$y1,$current_z>>; vector $np2 = <<$x2,$y1,$current_z>>; vector $np3 = <<$x2,$y2,$current_z>>; vector $np4 = <<$x1,$y2,$current_z>>; // dynamic assignment of the points into a string variable - this is incremented with the new //points each time the loop is evaluated... // this results in a list of -p X Y Z values printed as a string variable. $points = $points+" -p "+$np1+" -p "+$np2+" -p "+$np3+" -p "+$np4; }; // Create a final point to "almost" close the spiral loop - not closed to facilitate the selection in SurfCAM $finalpoint = " -p "+$x1+" "+($y1 + ($y*0.2))+" "+$current_z; print ($finalpoint+"\n"); $points = ($points + $finalpoint); print ($points+"\n"); // Create the final "command string" that contains all the required data to make the line... $makeline = "curve -d 1" + $points; print "\n"; print ($makeline+"\n"); // Evaluate the "command string" to create the line.... eval $makeline; // END }; // Example: block_cut "size_in_X" "Size_in_Y" "Size_in_-Z" "tool_diameter" "material_density_factor" // block_cut 500 300 80 6 1.0;