Example Toolpath Code
These are Code Examples for toolpaths.
Selection by Layer Name
SelectVectorsOnLayer
Create a selection set by layer name and object type, retunes the selection set.
function SelectVectorsOnLayer(layer, selection, select_closed, select_open, select_groups) --[[ Please Note: SelectVectorsOnLayer is provided by Vectric and can be found in the SDK and Sample Gadget files. -- | ---------------- SelectVectorsOnLayer ---------------- -- | SelectVectorsOnLayer("Stringer Profile", selection, true, false, false) -- | Add all the vectors on the layer to the selection -- | layer, -- layer we are selecting vectors on -- | selection -- selection object -- | select_closed -- if true select closed objects -- | select_open -- if true select open objects -- | select_groups -- if true select grouped vectors (irrespective of open / closed state of member objects) -- | Return Values: true if selected one or more vectors -- | -- ====================================================]] local objects_selected = false local warning_displayed = false local pos = layer:GetHeadPosition() while pos ~= nil do local object object, pos = layer:GetNext(pos) local contour = object:GetContour() if contour == nil then if (object.ClassName == "vcCadObjectGroup") and select_groups then selection:Add(object, true, true) objects_selected = true else if not warning_displayed then local message = "Object(s) without contour information found on layer - ignoring" if not select_groups then message = message .. "\r\n\r\n" .. "If layer contains grouped vectors these must be un-grouped for this script" end -- if end StatusMessage("Error", "Select Vectors", message, "(7200)") warning_displayed = true end -- if end end -- if end else -- contour was NOT nil, test if Open or Closed if contour.IsOpen and select_open then selection:Add(object, true, true) objects_selected = true elseif select_closed then selection:Add(object, true, true) objects_selected = true end -- if end end -- if end end -- while end -- to avoid excessive redrawing etc. we added vectors to the selection in 'batch' mode -- tell selection we have now finished updating if objects_selected then selection:GroupSelectionFinished() end -- if end return objects_selected end -- function end -- =====================================================]]
Pocketing Toolpaths
CreatePocketingToolpath by Selection
Create a Pocketing toolpath within the program for the currently selected vectors.
function CreatePocketingToolpath(name, start_depth, cut_depth, tool_dia, tool_stepdown, tool_stepover_percent, tool_in_mm) --[[ ------------ CreatePocketingToolpath ------------ || ===================================================== | Create a Pocketing toolpath within the program for the currently selected vectors | Parameters: | name, -- Name for toolpath | start_depth -- Start depth for toolpath below surface of material | cut_depth -- cut depth for pocket toolpath | tool_dia -- diameter of end mill to use | tool_stepdown -- stepdown for tool | tool_stepover_percent -- percentage stepover for tool | tool_in_mm -- true if tool size and stepdown are in mm || =====================================================]] -- Return Values: -- true if toolpath created OK else false -- Create tool we will use to machine vectors local tool = Tool("Lua End Mill",Tool.END_MILL -- BALL_NOSE, END_MILL, VBIT) tool.InMM = tool_in_mm tool.ToolDia = tool_dia tool.Stepdown = tool_stepdown tool.Stepover = tool_dia * (tool_stepover_percent / 100) tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC,... tool.FeedRate = 30 tool.PlungeRate = 10 tool.SpindleSpeed = 20000 tool.ToolNumber = 1 tool.VBitAngle = 90.0 -- used for vbit only tool.ClearStepover = tool_dia * (tool_stepover_percent / 100) -- used for vbit only -- Create object used to set home position and safez gap above material surface local pos_data = ToolpathPosData() pos_data:SetHomePosition(0, 0, 5.0) pos_data.SafeZGap = 5.0 -- Create object used to pass pocketing options local pocket_data = PocketParameterData() -- start depth for toolpath pocket_data.StartDepth = start_depth -- cut depth for toolpath this is depth below start depth pocket_data.CutDepth = cut_depth -- direction of cut for offet clearance - ProfileParameterData.CLIMB_DIRECTION or -- ProfileParameterData.CONVENTIONAL_DIRECTION - NOTE: enum from ProfileParameterData pocket_data.CutDirection = ProfileParameterData.CLIMB_DIRECTION -- Allowance to leave on when machining pocket_data.Allowance = 0.0 -- if true use raster clearance strategy , else use offset area clearance pocket_data.DoRasterClearance = true -- angle for raster if using raster clearance pocket_data.RasterAngle = 0 -- type of profile pass to perform PocketParameterData.PROFILE_NONE , -- PocketParameterData.PROFILE_FIRST orPocketParameterData.PROFILE_LAST pocket_data.ProfilePassType = PocketParameterData.PROFILE_LAST -- if true we ramp into pockets (always zig-zag) pocket_data.DoRamping = false -- if ramping, distance to ramp over pocket_data.RampDistance = 10.0 -- if true in Aspire, project toolpath onto composite model pocket_data.ProjectToolpath = false -- Create object which can be used to automatically select geometry local geometry_selector = GeometrySelector() -- if this is true we create 2d toolpaths previews in 2d view, if false we dont local create_2d_previews = true -- if this is true we will display errors and warning to the user local display_warnings = true -- if we are doing two tool pocketing define tool to use for area clearance local area_clear_tool = nill -- we just create a tool twice as large for testing here area_clear_tool = Tool("Lua Clearance End Mill",Tool.END_MILL) -- BALL_NOSE, END_MILL, VBIT area_clear_tool.InMM = tool_in_mm area_clear_tool.ToolDia = tool_dia * 2 area_clear_tool.Stepdown = tool_stepdown * 2 area_clear_tool.Stepover = tool_dia * 2 *(tool_stepover_percent / 100) area_clear_tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC.. area_clear_tool.FeedRate = 30 area_clear_tool.PlungeRate = 10 area_clear_tool.SpindleSpeed = 20000 area_clear_tool.ToolNumber = 1 area_clear_tool.VBitAngle = 90.0 -- used for vbit only area_clear_tool.ClearStepover = tool_dia*2*(tool_stepover_percent/100) -- used for vbit -- Create our toolpath local toolpath_manager = ToolpathManager() local toolpath_id = toolpath_manager:CreatePocketingToolpath(name, tool, area_clear_tool, pocket_data, pos_data, geometry_selector, create_2d_previews, display_warnings) if toolpath_id == nill then DisplayMessageBox("Error creating toolpath") return false end -- if end return true end -- function end -- =====================================================]]
CreatePocketingToolpath by Named Layer
Create a Pocketing toolpath within the program for the named layer.
function CreateLayerPocketingToolpath(layer_name, name, start_depth, cut_depth) local caller = " - " .. name if Milling.Pocket then local selection = Milling.job.Selection -- clear current selection selection:Clear() -- get layer local layer = Milling.job.LayerManager:FindLayerWithName(layer_name) if layer == nil then StatusMessage("Error", "Pocketing Toolpath", "No layer found with name = " .. layer_name, " (4601)" .. caller, 165) return false end -- if end -- select all closed vectors on the layer if not SelectVectorsOnLayer(layer, selection, true, false, true) then StatusMessage("Error", "Pocketing Toolpath", "No closed vectors found on layer " .. layer_name , "(4602)" .. caller, 165) return false end -- if end -- Create tool we will use to machine vectors local tool = Tool(MillTool2.Name, Tool.END_MILL) -- BALL_NOSE, END_MILL, VBIT tool.InMM = MillTool2.InMM -- tool_in_mm tool.ToolDia = MillTool2.ToolDia -- tool_dia tool.Stepdown = MillTool2.Stepdown -- tool_stepdown tool.Stepover = MillTool2.Stepover -- tool_dia * (tool_stepover_percent / 100) tool.RateUnits = MillTool2.RateUnits -- Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC, INCHES_MIN, FEET_MIN tool.FeedRate = MillTool2.FeedRate -- 30 tool.PlungeRate = MillTool2.PlungeRate -- 10 tool.SpindleSpeed = MillTool2.SpindleSpeed -- 20000 tool.ToolNumber = MillTool2.ToolNumber -- 1 -- tool.VBit_Angle = MillTool.VBit_Angle -- 90.0 -- used for vbit only -- tool.ClearStepover = MillTool.ClearStepover -- tool_dia * (tool_stepover_percent / 100) -- used for vbit only -- we will set home position and safe z relative to material block size local mtl_block = MaterialBlock() local mtl_box = mtl_block.MaterialBox local mtl_box_blc = mtl_box.BLC -- Create object used to set home position and safez gap above material surface local pos_data = ToolpathPosData() pos_data:SetHomePosition(mtl_box_blc.x, mtl_box_blc.y, mtl_box.TRC.z + (mtl_block.Thickness * 0.2) ) pos_data.SafeZGap = mtl_block.Thickness * 0.1 -- Create object used to pass pocketing options local pocket_data = PocketParameterData() -- start depth for toolpath pocket_data.StartDepth = start_depth -- cut depth for toolpath this is depth below start depth pocket_data.CutDepth = cut_depth -- direction of cut for offset clearance - ProfileParameterData.CLIMB_DIRECTION or ProfileParameterData.CONVENTIONAL_DIRECTION -- NOTE: enum from ProfileParameterData pocket_data.CutDirection = ProfileParameterData.CLIMB_DIRECTION -- Allowance to leave on when machining pocket_data.Allowance = 0.0 -- if true use raster clearance strategy , else use offset area clearance pocket_data.DoRasterClearance = false --true -- angle for raster if using raster clearance pocket_data.RasterAngle = 0 -- type of profile pass to perform PocketParameterData.PROFILE_NONE , PocketParameterData.PROFILE_FIRST orPocketParameterData.PROFILE_LAST pocket_data.ProfilePassType = PocketParameterData.PROFILE_LAST -- if true we ramp into pockets (always zig-zag) pocket_data.DoRamping = false -- if ramping, distance to ramp over pocket_data.RampDistance = 1.0 -- if true in Aspire, project toolpath onto composite model pocket_data.ProjectToolpath = false -- Create object which can used to automatically select geometry on layers etc. local geometry_selector = GeometrySelector() -- if this is true we create 2d toolpaths previews in 2d view, if false we don't local create_2d_previews = true -- if this is true we will display errors and warning to the user local display_warnings = true -- false -- -- if we are doing two tool pocketing define tool to use for area clearance local area_clear_tool = nil if Milling.Clearning then -- we just create a tool twice as large for testing here area_clear_tool = Tool(MillTool3.Name, Tool.END_MILL) -- BALL_NOSE, END_MILL, VBIT area_clear_tool.InMM = MillTool3.InMM -- tool_in_mm area_clear_tool.ToolDia = MillTool3.ToolDia -- tool_dia * 2 area_clear_tool.Stepdown = MillTool3.Stepdown -- tool_stepdown * 2 area_clear_tool.Stepover = MillTool3.Stepover -- tool_dia * 2 *(tool_stepover_percent / 100) area_clear_tool.RateUnits = MillTool3.RateUnits -- Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC, INCHES_MIN, FEET_MIN area_clear_tool.FeedRate = MillTool3.FeedRate -- 30 area_clear_tool.PlungeRate = MillTool3.PlungeRate -- 10 area_clear_tool.SpindleSpeed = MillTool3.SpindleSpeed -- 20000 area_clear_tool.ToolNumber = MillTool3.ToolNumber -- 1 end -- if end -- area_clear_tool.VBit_Angle = Carrier.MillTool3.VBit_Angle -- 90.0 -- used for vbit only -- area_clear_tool.ClearStepover = Carrier.MillTool3.ClearStepover -- tool_dia * 2 * (tool_stepover_percent / 100) -- used for vbit only -- Create our toolpath local toolpath_manager = ToolpathManager() local toolpath_id = toolpath_manager:CreatePocketingToolpath( name, tool, area_clear_tool, pocket_data, pos_data, geometry_selector, create_2d_previews, display_warnings ) if toolpath_id == nil then StatusMessage("Error", "Milling Settings", "Unable to create toolpath.", "(4603)" .. caller, 165) return false end -- if end end -- if end return true end -- function end -- =====================================================]]
Drilling Toolpath
Drilling Toolpath by Selection
Create a drilling toolpath within the program for the currently selected vectors.
function CreateDrillingToolpath(name, start_depth, cut_depth, retract_gap, tool_dia, tool_stepdown, tool_in_mm) --[[ ------- CreateDrillingToolpath -------------------------------------------------- || Create a drilling toolpath within the program for the currently selected vectors | Parameters: | name, -- Name for toolpath | start_depth -- Start depth for toolpath below surface of material | cut_depth -- cut depth for drilling toolpath | retract_gap -- distance to retract above surface for pecks | tool_dia -- diameter of drill to use | tool_stepdown -- stepdown for tool | tool_in_mm -- true if tool size and stepdown are in mm || Return Values: | true if toolpath created OK else false | ]] -- Create tool we will use to machine vectors local tool = Tool("Lua Drill", Tool.THROUGH_DRILL) -- BALL_NOSE, END_MILL, VBIT, THROUGH_DRILL tool.InMM = tool_in_mm tool.ToolDia = tool_dia tool.Stepdown = tool_stepdown tool.Stepover = tool_dia * 0.25 tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC, INCHES_MIN, FEET_MIN tool.FeedRate = 30 tool.PlungeRate = 10 tool.SpindleSpeed = 20000 tool.ToolNumber = 1 tool.VBitAngle = 90.0 -- used for vbit only tool.ClearStepover = tool_dia * 0.5 -- used for vbit only -- Create object used to set home position and safez gap above material surface local pos_data = ToolpathPosData() pos_data:SetHomePosition(0, 0, 5.0) pos_data.SafeZGap = 5.0 -- Create object used to pass profile options local drill_data = DrillParameterData() -- start depth for toolpath drill_data.StartDepth = start_depth -- cut depth for toolpath this is depth below start depth drill_data.CutDepth = cut_depth -- if true perform peck drilling drill_data.DoPeckDrill = retract_gap > 0.0 -- distance to retract above surface when peck drilling drill_data.PeckRetractGap = retract_gap -- if true in Aspire, project toolpath onto composite model drill_data.ProjectToolpath = false -- Create object which can be used to automatically select geometry local geometry_selector = GeometrySelector() -- if this is true we create 2d toolpaths previews in 2d view, -- if false we dont local create_2d_previews = true -- if this is true we will display errors and warning to the user local display_warnings = true -- Create our toolpath local toolpath_manager = ToolpathManager() local toolpath_id = toolpath_manager:CreateDrillingToolpath(name, tool, drill_data, pos_data, geometry_selector, create_2d_previews, display_warnings) if toolpath_id == nil then DisplayMessageBox("Error creating toolpath") return false end -- if end return true end -- function end -- =====================================================]]
Drilling Toolpath by Named Layer
Create a drilling toolpath within the program for the currently selected vectors.
function CreateDrillingToolpath(layer_name, name, start_depth, cut_depth, retract_gap, tool_dia, tool_stepdown, tool_in_mm) --[[ ------- CreateDrillingToolpath -------------------------------------------------- || Create a drilling toolpath within the program for the currently selected vectors | Parameters: | name, -- Name for toolpath | start_depth -- Start depth for toolpath below surface of material | cut_depth -- cut depth for drilling toolpath | retract_gap -- distance to retract above surface for pecks | tool_dia -- diameter of drill to use | tool_stepdown -- stepdown for tool | tool_in_mm -- true if tool size and stepdown are in mm || Return Values: | true if toolpath created OK else false | ]] -- get layer local layer = Milling.job.LayerManager:FindLayerWithName(layer_name) if layer == nil then StatusMessage("Error", "Pocketing Toolpath", "No layer found with name = " .. layer_name, " (4601)" .. caller, 165) return false end -- select all closed vectors on the layer if not SelectVectorsOnLayer(layer, selection, true, false, true) then StatusMessage("Error", "Pocketing Toolpath", "No closed vectors found on layer " .. layer_name , "(4602)" .. caller, 165) return false end -- Create tool we will use to machine vectors local tool = Tool("Lua Drill", Tool.THROUGH_DRILL) -- BALL_NOSE, END_MILL, VBIT, THROUGH_DRILL tool.InMM = tool_in_mm tool.ToolDia = tool_dia tool.Stepdown = tool_stepdown tool.Stepover = tool_dia * 0.25 tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC, INCHES_MIN, FEET_MIN tool.FeedRate = 30 tool.PlungeRate = 10 tool.SpindleSpeed = 20000 tool.ToolNumber = 1 tool.VBitAngle = 90.0 -- used for vbit only tool.ClearStepover = tool_dia * 0.5 -- used for vbit only -- Create object used to set home position and safez gap above material surface local pos_data = ToolpathPosData() pos_data:SetHomePosition(0, 0, 5.0) pos_data.SafeZGap = 5.0 -- Create object used to pass profile options local drill_data = DrillParameterData() -- start depth for toolpath drill_data.StartDepth = start_depth -- cut depth for toolpath this is depth below start depth drill_data.CutDepth = cut_depth -- if true perform peck drilling drill_data.DoPeckDrill = retract_gap > 0.0 -- distance to retract above surface when peck drilling drill_data.PeckRetractGap = retract_gap -- if true in Aspire, project toolpath onto composite model drill_data.ProjectToolpath = false -- Create object which can be used to automatically select geometry local geometry_selector = GeometrySelector() -- if this is true we create 2d toolpaths previews in 2d view, -- if false we dont local create_2d_previews = true -- if this is true we will display errors and warning to the user local display_warnings = true -- Create our toolpath local toolpath_manager = ToolpathManager() local toolpath_id = toolpath_manager:CreateDrillingToolpath(name, tool, drill_data, pos_data, geometry_selector, create_2d_previews, display_warnings) if toolpath_id == nil then DisplayMessageBox("Error creating toolpath") return false end -- if end return true end -- function end -- =====================================================]]
V-Carve Toolpaths
CreateVCarveToolpath by Selection
Create a V-Carve toolpath within the program for the currently selected vectors.
CreateVCarveToolpath by Layer Name
Create a V-Carve toolpath within the program by Layer Name.
Fluting Toolpaths
CreateFlutingToolpath by Selection
Create a Fluting toolpath within the program for the currently selected vectors.
function CreateFlutingToolpath(name, start_depth, cut_depth, tool_dia, tool_stepdown, tool_in_mm) --[[ ----------------- CreateFlutingToolpath ----------------- | Create a flutting toolpath within the program for the currently selected vectors | Parameters: | name, -- Name for toolpath | start_depth -- Start depth for toolpath below surface of material | cut_depth -- cut depth for toolpath | tool_dia -- diameter of tool to use | tool_stepdown -- stepdown for tool | tool_in_mm -- true if tool size and stepdown are in mm | | Return Values: | true if toolpath created OK else false | ]] -- Create tool we will use to machine vectors local tool = Tool("Lua Ball Nose", Tool.BALL_NOSE) -- BALL_NOSE, END_MILL, VBIT, THROUGH_DRILL tool.InMM = tool_in_mm tool.ToolDia = tool_dia tool.Stepdown = tool_stepdown tool.Stepover = tool_dia * 0.25 tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC, INCHES_MIN, FEET_MIN tool.FeedRate = 30 tool.PlungeRate = 10 tool.SpindleSpeed = 20000 tool.ToolNumber = 1 tool.VBit_Angle = 90.0 -- used for vbit only tool.ClearStepover = tool_dia * 0.5 -- used for vbit only -- Create object used to set home position and safez gap above material surface local pos_data = ToolpathPosData() pos_data:SetHomePosition(0, 0, 1.0) pos_data.SafeZGap = 5.0 -- Create object used to pass fluting options local fluting_data = FlutingParameterData() -- start depth for toolpath fluting_data.StartDepth = start_depth -- cut depth for toolpath this is depth below start depth fluting_data.CutDepth = cut_depth -- type of fluting FULL_LENGTH, RAMP_START or RAMP_START_END fluting_data.FluteType = FlutingParameterData.RAMP_START_END -- type of ramping RAMP_LINEAR, RAMP_SMOOTH fluting_data.RampType = FlutingParameterData.RAMP_LINEAR -- if true use ratio field for controling ramp length else absolute length value fluting_data.UseRampRatio = false -- length of ramp as ratio of flute length(range 0 - 1.0) -- (for start and end - ratio is of half length) fluting_data.RampRatio = 0.2 -- length to ramp over - if UseRampRatio == false fluting_data.RampLength = 15 -- if true in Aspire, project toolpath onto composite model fluting_data.ProjectToolpath = false -- Create object which can be used to automatically select geometry local geometry_selector = GeometrySelector() -- if this is true we create 2d toolpaths previews in 2d view, if false we dont local create_2d_previews = true -- if this is true we will display errors and warning to the user local display_warnings = true -- Create our toolpath local toolpath_manager = ToolpathManager() local toolpath_id = toolpath_manager:CreateFlutingToolpath(name, tool, fluting_data, pos_data, geometry_selector, create_2d_previews, display_warnings) if toolpath_id == nil then DisplayMessageBox("Error creating toolpath") return false else return true end -- if end end -- end function -- =====================================================]]
CreateFlutingToolpath by Layer Name
Create a Fluting toolpath within the program by Layer Name.
Profile Toolpaths
CreateProfileToolpath by Selection
Create a Profile toolpath within the program for the currently selected vectors.
CreateProfileToolpath by Layer Name
Create a Profile toolpath within the program by Layer Name.
function CreateProfileToolpath(layer_name, name, start_depth, cut_depth, tool_dia, tool_stepdown, tool_in_mm) -- get layer local layer = Milling.job.LayerManager:FindLayerWithName(layer_name) if layer == nil then StatusMessage("Error", "Pocketing Toolpath", "No layer found with name = " .. layer_name, " (4601)" .. caller, 165) return false end -- if end -- select all closed vectors on the layer if not SelectVectorsOnLayer(layer, selection, true, false, true) then StatusMessage("Error", "Pocketing Toolpath", "No closed vectors found on layer " .. layer_name , "(4602)" .. caller, 165) return false end -- if end -- Create tool we will use to machine vectors local tool = Tool("Lua End Mill", Tool.END_MILL) -- BALL_NOSE, END_MILL, VBIT tool.InMM = tool_in_mm tool.ToolDia = tool_dia tool.Stepdown = tool_stepdown tool.Stepover = tool_dia * 0.25 tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC ... tool.FeedRate = 30 tool.PlungeRate = 10 tool.SpindleSpeed = 20000 tool.ToolNumber = 1 tool.VBit_Angle = 90.0 -- used for vbit only tool.ClearStepover = tool_dia * 0.5 -- used for vbit only -- Create object used to set home position and safez gap above material surface local pos_data = ToolpathPosData() pos_data:SetHomePosition(0, 0, 1.0) pos_data.SafeZGap = 5.0 -- Create object used to pass profile options local profile_data = ProfileParameterData() -- start depth for toolpath profile_data.StartDepth = start_depth -- cut depth for toolpath this is depth below start depth profile_data.CutDepth = cut_depth -- direction of cut - ProfileParameterData. -- CLIMB_DIRECTION or ProfileParameterData.CONVENTIONAL_DIRECTION profile_data.CutDirection = ProfileParameterData.CLIMB_DIRECTION -- side we machine on - ProfileParameterData. -- PROFILE_OUTSIDE, ProfileParameterData.PROFILE_INSIDE or -- ProfileParameterData.PROFILE_ON profile_data.ProfileSide = ProfileParameterData.PROFILE_OUTSIDE -- Allowance to leave on when machining profile_data.Allowance = 0.0 -- true to preserve start point positions, false to reorder start -- points to minimise toolpath length profile_data.KeepStartPoints = false -- true if want to create 'square' external corners on toolpath profile_data.CreateSquareCorners = false -- true to perform corner sharpening on internal corners (only with v-bits) profile_data.CornerSharpen = false -- true to use tabs (position of tabs must already have been defined on vectors) profile_data.UseTabs = false -- length for tabs if being used profile_data.TabLength = 5.0 -- Thickness for tabs if being used profile_data.TabThickness = 1.0 -- if true then create 3d tabs else 2d tabs profile_data.Use3dTabs = true -- if true in Aspire, project toolpath onto composite model profile_data.ProjectToolpath = false -- Create object used to control ramping local ramping_data = RampingData() -- if true we do ramping into toolpath ramping_data.DoRamping = false -- type of ramping to perform RampingData.RAMP_LINEAR , RampingData.RAMP_ZIG_ZAG -- or RampingData.RAMP_SPIRAL ramping_data.RampType = RampingData.RAMP_ZIG_ZAG -- how ramp is contrained - either by angle or distance RampingData.CONSTRAIN_DISTANCE -- or RampingData.CONSTRAIN_ANGLE ramping_data.RampConstraint = RampingData.CONSTRAIN_ANGLE -- if we are constraining ramp by distance, distance to ramp over ramping_data.RampDistance = 100.0 -- if we are contraining ramp by angle , angle to ramp in at (in degrees) ramping_data.RampAngle = 25.0 -- if we are contraining ramp by angle, max distance to travel before 'zig zaging' -- if zig zaging ramping_data.RampMaxAngleDist = 15 -- if true we restrict our ramping to lead in section of toolpath ramping_data.RampOnLeadIn = false -- Create object used to control lead in/out local lead_in_out_data = LeadInOutData() -- if true we create lead ins on profiles (not for profile on) lead_in_out_data.DoLeadIn = false -- if true we create lead outs on profiles (not for profile on) lead_in_out_data.DoLeadOut = false -- type of leads to create LeadInOutData.LINEAR_LEAD or LeadInOutData.CIRCULAR_LEAD lead_in_out_data.LeadType = LeadInOutData.CIRCULAR_LEAD -- length of lead to create lead_in_out_data.LeadLength = 10.0 -- Angle for linear leads lead_in_out_data.LinearLeadAngle = 45 -- Radius for circular arc leads lead_in_out_data.CirularLeadRadius = 5.0 -- distance to 'overcut' (travel past start point) when profiling lead_in_out_data.OvercutDistance = 0.0 -- Create object which can be used to automatically select geometry local geometry_selector = GeometrySelector() -- if this is true we create 2d toolpaths previews in 2d view, if false we dont local create_2d_previews = true -- if this is true we will display errors and warning to the user local display_warnings = true -- Create our toolpath local toolpath_manager = ToolpathManager() local toolpath_id = toolpath_manager:CreateProfilingToolpath(name, tool, profile_data, ramping_data, lead_in_out_data, pos_data, geometry_selector, create_2d_previews, display_warnings ) if toolpath_id == nil then DisplayMessageBox("Error creating toolpath") return false end -- if end return true end -- end function -- =====================================================]]
Prism Toolpaths
CreatePrismToolpath by Selection
Create a Prism toolpath within the program for the currently selected vectors.
function CreatePrismToolpath(name, start_depth, cut_depth, vbit_angle, vbit_dia, vbit_stepdown, tool_stepover_percent, tool_in_mm) --[[ ------------------- CreatePrismToolpath ------------------- | | Create a prism toolpath within the program for the currently selected vectors | Parameters: | name, -- Name for toolpath | start_depth -- Start depth for toolpath below surface of material | cut_depth -- cut depth for drilling toolpath | vbit_angle -- angle of vbit to use | vbit_dia -- diameter of VBit to use | vbit_stepdown -- stepdown for tool | tool_stepover_percent - percentage stepover for tool | tool_in_mm -- true if tool size and stepdown are in mm | | Return Values: | true if toolpath created OK else false | ]] -- Create tool we will use to machine vectors local tool = Tool("Lua VBit", Tool.VBIT ) -- BALL_NOSE, END_MILL, VBIT tool.InMM = tool_in_mm tool.ToolDia = vbit_dia tool.Stepdown = vbit_stepdown tool.Stepover = vbit_dia * (tool_stepover_percent / 100) tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC, INCHES_MIN, FEET_MIN tool.FeedRate = 30 tool.PlungeRate = 10 tool.SpindleSpeed = 20000 tool.ToolNumber = 1 tool.VBit_Angle = 90.0 -- used for vbit only tool.ClearStepover = vbit_dia * (tool_stepover_percent / 100) * 2 -- used for vbit only -- Create object used to set home position and safez gap above material surface local pos_data = ToolpathPosData() pos_data:SetHomePosition(0, 0, 1.0) pos_data.SafeZGap = 5.0 -- Create object used to pass profile options local prism_data = PrismCarveParameterData() -- start depth for toolpath prism_data.StartDepth = start_depth -- cut depth for toolpath this is depth below start depth prism_data.CutDepth = cut_depth -- direction of cut for offet clearance - ProfileParameterData.CLIMB_DIRECTION -- or ProfileParameterData.CONVENTIONAL_DIRECTION - NOTE: enum from ProfileParameterData prism_data.CutDirection = ProfileParameterData.CLIMB_DIRECTION -- calculate the minimum cut depth to fully form the bevel on the current -- selection with the current tool local min_bevel_depth = prism_data:CalculateMinimumBevelDepth(tool, true) if min_bevel_depth > cut_depth then DisplayMessageBox("A prism will not be fully formed with a depth of " .. cut_depth .. "\r\n" .. "A depth of " .. min_bevel_depth .. " is required to fully form the prism" ) end -- if end -- Create object which can be used to automatically select geometry local geometry_selector = GeometrySelector() -- if this is true we create 2d toolpaths previews in 2d view, if false we dont local create_2d_previews = true -- if this is true we will display errors and warning to the user local display_warnings = true -- Create our toolpath local toolpath_manager = ToolpathManager() local toolpath_id = toolpath_manager:CreatePrismCarvingToolpath(name, tool, prism_data, pos_data, geometry_selector, create_2d_previews, display_warnings) if toolpath_id == nil then DisplayMessageBox("Error creating toolpath") return false end -- if end return true end -- end function -- =====================================================]]
CreatePrismToolpath by Layer Name
Create a Prism toolpath within the program by Layer Name.
function CreatePrismToolpath(layer_name, name, start_depth, cut_depth, vbit_angle, vbit_dia, vbit_stepdown, tool_stepover_percent, tool_in_mm) --[[ ------------------- CreatePrismToolpath ------------------- | | Create a prism toolpath within the program for the currently selected vectors | Parameters: | name, -- Name for toolpath | start_depth -- Start depth for toolpath below surface of material | cut_depth -- cut depth for drilling toolpath | vbit_angle -- angle of vbit to use | vbit_dia -- diameter of VBit to use | vbit_stepdown -- stepdown for tool | tool_stepover_percent - percentage stepover for tool | tool_in_mm -- true if tool size and stepdown are in mm | | Return Values: | true if toolpath created OK else false | ]] -- get layer local layer = Milling.job.LayerManager:FindLayerWithName(layer_name) if layer == nil then StatusMessage("Error", "Pocketing Toolpath", "No layer found with name = " .. layer_name, " (4601)" .. caller, 165) return false end -- select all closed vectors on the layer if not SelectVectorsOnLayer(layer, selection, true, false, true) then StatusMessage("Error", "Pocketing Toolpath", "No closed vectors found on layer " .. layer_name , "(4602)" .. caller, 165) return false end -- Create tool we will use to machine vectors local tool = Tool("Lua VBit", Tool.VBIT ) -- BALL_NOSE, END_MILL, VBIT tool.InMM = tool_in_mm tool.ToolDia = vbit_dia tool.Stepdown = vbit_stepdown tool.Stepover = vbit_dia * (tool_stepover_percent / 100) tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC, INCHES_MIN, FEET_MIN tool.FeedRate = 30 tool.PlungeRate = 10 tool.SpindleSpeed = 20000 tool.ToolNumber = 1 tool.VBit_Angle = 90.0 -- used for vbit only tool.ClearStepover = vbit_dia * (tool_stepover_percent / 100) * 2 -- used for vbit only -- Create object used to set home position and safez gap above material surface local pos_data = ToolpathPosData() pos_data:SetHomePosition(0, 0, 1.0) pos_data.SafeZGap = 5.0 -- Create object used to pass profile options local prism_data = PrismCarveParameterData() -- start depth for toolpath prism_data.StartDepth = start_depth -- cut depth for toolpath this is depth below start depth prism_data.CutDepth = cut_depth -- direction of cut for offet clearance - ProfileParameterData.CLIMB_DIRECTION or ProfileParameterData.CONVENTIONAL_DIRECTION - NOTE: enum from ProfileParameterData prism_data.CutDirection = ProfileParameterData.CLIMB_DIRECTION -- calculate the minimum cut depth to fully form the bevel on the current -- selection with the current tool local min_bevel_depth = prism_data:CalculateMinimumBevelDepth(tool, true) if min_bevel_depth > cut_depth then DisplayMessageBox("A prism will not be fully formed with a depth of " .. cut_depth .. "\r\n" .. "A depth of " .. min_bevel_depth .. " is required to fully form the prism") end -- if end -- Create object which can be used to automatically select geometry local geometry_selector = GeometrySelector() -- if this is true we create 2d toolpaths previews in 2d view, if false we dont local create_2d_previews = true -- if this is true we will display errors and warning to the user local display_warnings = true -- Create our toolpath local toolpath_manager = ToolpathManager() local toolpath_id = toolpath_manager:CreatePrismCarvingToolpath(name, tool, prism_data, pos_data, geometry_selector, create_2d_previews, display_warnings) if toolpath_id == nil then DisplayMessageBox("Error creating toolpath") return false end -- if end return true end -- end function -- =====================================================]]
References
Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information