Example Toolpath Code: Difference between revisions
Jump to navigation
Jump to search
(Created page with "right|50px|link=Toolpaths Category:SDK These are Code Examples for toolpaths. ==Creat_Pocketing_Toolpath== <nowiki>function CreatePocketingToolpath( -- ------------ 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 |...") |
|||
Line 6: | Line 6: | ||
==Creat_Pocketing_Toolpath== | ==Creat_Pocketing_Toolpath== | ||
<nowiki>function CreatePocketingToolpath( | <nowiki>function CreatePocketingToolpath(name, start_depth, cut_depth, tool_dia, tool_stepdown, tool_stepover_percent, tool_in_mm) | ||
--[[ ------------ CreatePocketingToolpath ------------ | --[[ ------------ CreatePocketingToolpath ------------ | ||
| | || ===================================================== | ||
| Create a Pocketing toolpath within the program for the currently selected vectors | | Create a Pocketing toolpath within the program for the currently selected vectors | ||
| Parameters: | | Parameters: | ||
Line 18: | Line 18: | ||
| tool_stepover_percent -- percentage stepover for tool | | tool_stepover_percent -- percentage stepover for tool | ||
| tool_in_mm -- true if tool size and stepdown are in mm | | tool_in_mm -- true if tool size and stepdown are in mm | ||
|| | || =====================================================]] | ||
Return Values: | -- Return Values: | ||
-- true if toolpath created OK else false | |||
-- Create tool we will use to machine vectors | -- Create tool we will use to machine vectors | ||
local tool = Tool("Lua End Mill",Tool.END_MILL -- BALL_NOSE, END_MILL, VBIT) | local tool = Tool("Lua End Mill",Tool.END_MILL -- BALL_NOSE, END_MILL, VBIT) | ||
tool.InMM = tool_in_mm | tool.InMM = tool_in_mm | ||
tool.ToolDia = tool_dia | tool.ToolDia = tool_dia | ||
tool.Stepdown = tool_stepdown | tool.Stepdown = tool_stepdown | ||
tool.Stepover = tool_dia * (tool_stepover_percent / 100) | tool.Stepover = tool_dia * (tool_stepover_percent / 100) | ||
tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC,... | tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC,... | ||
tool.FeedRate = 30 | tool.FeedRate = 30 | ||
tool.PlungeRate = 10 | tool.PlungeRate = 10 | ||
tool.SpindleSpeed = 20000 | tool.SpindleSpeed = 20000 | ||
tool.ToolNumber = 1 | tool.ToolNumber = 1 | ||
tool.VBitAngle = 90.0 -- used for vbit only | tool.VBitAngle = 90.0 -- used for vbit only | ||
tool.ClearStepover = tool_dia * (tool_stepover_percent / 100) -- 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 | -- Create object used to set home position and safez gap above material surface | ||
local pos_data = ToolpathPosData() | local pos_data = ToolpathPosData() | ||
pos_data:SetHomePosition(0, 0, 5.0) | pos_data:SetHomePosition(0, 0, 5.0) | ||
pos_data.SafeZGap = 5.0 | pos_data.SafeZGap = 5.0 | ||
-- Create object used to pass pocketing options | -- Create object used to pass pocketing options | ||
local pocket_data = PocketParameterData() | local pocket_data = PocketParameterData() | ||
-- start depth for toolpath | -- start depth for toolpath | ||
pocket_data.StartDepth = start_depth | pocket_data.StartDepth = start_depth | ||
-- cut depth for toolpath this is depth below start depth | -- cut depth for toolpath this is depth below start depth | ||
pocket_data.CutDepth = cut_depth | pocket_data.CutDepth = cut_depth | ||
-- direction of cut for offet clearance - ProfileParameterData.CLIMB_DIRECTION or | -- direction of cut for offet clearance - ProfileParameterData.CLIMB_DIRECTION or | ||
-- ProfileParameterData.CONVENTIONAL_DIRECTION - NOTE: enum from ProfileParameterData | -- ProfileParameterData.CONVENTIONAL_DIRECTION - NOTE: enum from ProfileParameterData | ||
pocket_data.CutDirection = ProfileParameterData.CLIMB_DIRECTION | pocket_data.CutDirection = ProfileParameterData.CLIMB_DIRECTION | ||
-- Allowance to leave on when machining | -- Allowance to leave on when machining | ||
pocket_data.Allowance = 0.0 | pocket_data.Allowance = 0.0 | ||
-- if true use raster clearance strategy , else use offset area clearance | -- if true use raster clearance strategy , else use offset area clearance | ||
pocket_data.DoRasterClearance = true | pocket_data.DoRasterClearance = true | ||
-- angle for raster if using raster clearance | -- angle for raster if using raster clearance | ||
pocket_data.RasterAngle = 0 | pocket_data.RasterAngle = 0 | ||
-- type of profile pass to perform PocketParameterData.PROFILE_NONE , | -- type of profile pass to perform PocketParameterData.PROFILE_NONE , | ||
-- PocketParameterData.PROFILE_FIRST orPocketParameterData.PROFILE_LAST | -- PocketParameterData.PROFILE_FIRST orPocketParameterData.PROFILE_LAST | ||
pocket_data.ProfilePassType = PocketParameterData.PROFILE_LAST | pocket_data.ProfilePassType = PocketParameterData.PROFILE_LAST | ||
-- if true we ramp into pockets (always zig-zag) | -- if true we ramp into pockets (always zig-zag) | ||
pocket_data.DoRamping = false | pocket_data.DoRamping = false | ||
-- if ramping, distance to ramp over | -- if ramping, distance to ramp over | ||
pocket_data.RampDistance = 10.0 | pocket_data.RampDistance = 10.0 | ||
-- if true in Aspire, project toolpath onto composite model | -- if true in Aspire, project toolpath onto composite model | ||
pocket_data.ProjectToolpath = false | pocket_data.ProjectToolpath = false | ||
-- Create object which can be used to automatically select geometry | -- Create object which can be used to automatically select geometry | ||
local geometry_selector = GeometrySelector() | local geometry_selector = GeometrySelector() | ||
-- if this is true we create 2d toolpaths previews in 2d view, if false we dont | -- if this is true we create 2d toolpaths previews in 2d view, if false we dont | ||
local create_2d_previews = true | local create_2d_previews = true | ||
-- if this is true we will display errors and warning to the user | -- if this is true we will display errors and warning to the user | ||
local display_warnings = true | local display_warnings = true | ||
-- if we are doing two tool pocketing define tool to use for area clearance | -- if we are doing two tool pocketing define tool to use for area clearance | ||
local area_clear_tool = nill | local area_clear_tool = nill | ||
-- we just create a tool twice as large for testing here | -- we just create a tool twice as large for testing here | ||
area_clear_tool = Tool( | area_clear_tool = Tool("Lua Clearance End Mill",Tool.END_MILL) -- BALL_NOSE, END_MILL, VBIT | ||
"Lua Clearance End Mill", | area_clear_tool.InMM = tool_in_mm | ||
Tool.END_MILL -- BALL_NOSE, END_MILL, VBIT | area_clear_tool.ToolDia = tool_dia * 2 | ||
area_clear_tool.Stepdown = tool_stepdown * 2 | |||
area_clear_tool.InMM = tool_in_mm | area_clear_tool.Stepover = tool_dia * 2 *(tool_stepover_percent / 100) | ||
area_clear_tool.ToolDia = tool_dia * 2 | area_clear_tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC.. | ||
area_clear_tool.Stepdown = tool_stepdown * 2 | area_clear_tool.FeedRate = 30 | ||
area_clear_tool.Stepover = tool_dia * 2 *(tool_stepover_percent / 100) | area_clear_tool.PlungeRate = 10 | ||
area_clear_tool.RateUnits = Tool.MM_SEC -- MM_SEC, MM_MIN, METRES_MIN, INCHES_SEC.. | area_clear_tool.SpindleSpeed = 20000 | ||
area_clear_tool.FeedRate = 30 | area_clear_tool.ToolNumber = 1 | ||
area_clear_tool.PlungeRate = 10 | area_clear_tool.VBitAngle = 90.0 -- used for vbit only | ||
area_clear_tool.SpindleSpeed = 20000 | area_clear_tool.ClearStepover = tool_dia*2*(tool_stepover_percent/100) -- used for vbit | ||
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 | -- Create our toolpath | ||
local toolpath_manager = ToolpathManager() | local toolpath_manager = ToolpathManager() | ||
local toolpath_id = toolpath_manager:CreatePocketingToolpath( | local toolpath_id = toolpath_manager:CreatePocketingToolpath(name, tool, area_clear_tool, pocket_data, pos_data, | ||
name, | geometry_selector, create_2d_previews, display_warnings) | ||
tool, | if toolpath_id == nill then | ||
area_clear_tool, | DisplayMessageBox("Error creating toolpath") | ||
pocket_data, | return false | ||
pos_data, | end -- if end | ||
geometry_selector, | return true | ||
create_2d_previews, | end -- function end</nowiki> | ||
display_warnings | |||
) | |||
if toolpath_id == nill then | |||
DisplayMessageBox("Error creating toolpath") | |||
return false | |||
end | |||
return true | |||
end</nowiki> | |||
[[File:Back.jpg|right|50px|link=Toolpaths]] | [[File:Back.jpg|right|50px|link=Toolpaths]] | ||
==References== | ==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 [https://gadgets.vectric.com/developerinfo.html Vertric Developer Information] | '''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 [https://gadgets.vectric.com/developerinfo.html Vertric Developer Information] |
Revision as of 11:26, 1 September 2023
These are Code Examples for toolpaths.
Creat_Pocketing_Toolpath
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
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