HSMXpress to LinuxCNC tool table conversion script
09 Jun 2015 12:18 - 09 Jun 2015 13:26 #59643
by adam3999
HSMXpress to LinuxCNC tool table conversion script was created by adam3999
Hey guys, here is a quick Powershell script I wrote that converts an XML-based HSMXpress tool library to LinuxCNC tool table. The XML input files are usually stored in "C:\Users\user\Documents\My Libraries". You can paste the output of this script into your LinuxCNC "tool.tbl" file. This code assumes "inch" linear units.
It should take an HSMXpress entry such as:
and convert it to a LinuxCNC compatible entry:
My setup is rather simple so I only translate the tool #, diameter and comments but there is room for extension. Let me know what you think, thanks.
param ( [parameter(mandatory=$true)] [string] $hsmlib_input )
function main()
{
[xml] $tool_xml = get-content $hsmlib_input
foreach( $tool in $tool_xml."tool-library".tool )
{
$tool_num = $tool.nc.number
switch( $tool.unit )
{
"inches" { $tool_dia = $tool.body.diameter }
"millimeters" { $tool_dia = [float] $tool.body.diameter * 0.03937 | %{ "{0:N4}" -f $_ } }
}
$tool_remark = ""
if( $tool.manufacturer ) { $tool_remark = $tool.manufacturer + " " }
if( $tool.description ) { $tool_remark += $tool.description + " " }
if( $tool.comment ) { $tool_remark += $tool.comment + " " }
if( $tool.motion."spindle-rpm" -and $tool.motion."cutting-feedrate" ) { $tool_remark += "speed: " + $tool.motion."spindle-rpm" + " feed: " + $tool.motion."cutting-feedrate" }
#Tool Table Format:
#Tool # Pocket # X offset Y offset Z offset A offset B offset C offset U offset V offset W offset Diameter Front Angle Back Angle Orientation Remark
write-host "T${tool_num} P0 X0 Y0 Z0 A0 B0 C0 U0 V0 W0 D${tool_dia} I0 J0 Q0 ; $tool_remark"
}
}
. main
It should take an HSMXpress entry such as:
type unit description comment manufacturer product-id number diameter-offset length-offset break-control manual-tool-change diameter tip-diameter tip-length corner-radius taper-angle taper-angle2 flute-length shoulder-length shaft-diameter body-length overall-length number-of-flutes thread-pitch coolant-mode material-name spindle-rpm ramp-spindle-rpm clockwise cutting-feedrate entry-feedrate exit-feedrate plunge-feedrate ramp-feedrate retract-feedrate holder shaft guid holder-description holder-comment holder-vendor holder-product-id holder-guid holder-library-name
drill inches #36 tap drill for UNC #6-32 100 100 100 0 0 0.1065 0 0 0 118 0 0.213 0.3195 0.1065 0.7455 50.3195 1 0 disabled unspecified 1793 1793 yes 16 5 5 2 2 2 {e4884275-727b-49cb-aa67-91cc6dac4ec0}
and convert it to a LinuxCNC compatible entry:
T100 P0 X0 Y0 Z0 A0 B0 C0 U0 V0 W0 D0.1065 I0 J0 Q0 ; #36 tap drill for UNC #6-32 speed: 1793 feed: 16
My setup is rather simple so I only translate the tool #, diameter and comments but there is room for extension. Let me know what you think, thanks.
Last edit: 09 Jun 2015 13:26 by adam3999.
Please Log in or Create an account to join the conversation.
12 Jun 2015 03:37 #59727
by andypugh
Replied by andypugh on topic HSMXpress to LinuxCNC tool table conversion script
I would be more interested in going the other way....
(But don't bother writing the script, I have already manually-entered the tools I use most)
(But don't bother writing the script, I have already manually-entered the tools I use most)
Please Log in or Create an account to join the conversation.
Time to create page: 0.057 seconds