Hi @kukelyk,
Thank you for your help. I put your command in the first line of the macro like that, but it exported NC.csv to my desktop screen. Could you help me to use your command in the right way ? Thank you very much !
//
// Macro to export NC data to Excel
//
// Open File
STRING project_dir =project_pathname(0)
STRING folder_contains_project_folder = dirname(replace (project_pathname(0), "/","\"))
FILE OPEN "NC.csv" FOR WRITE AS "output"
// Cycle through the NC programs
REAL sumtime = 0
FOREACH ncp IN folder('NCProgram') {
REAL ncptime = 0
// Create an empty list
STRING List names = {}
// Output NC Program name
STRING nome = "NC Program:," + ncp.Name
FILE WRITE $nome TO "output"
// Output Header for Toolpath data
STRING header = "Toolpath Name, Tool Name, Toolpath Length"
FILE WRITE $header TO "output"
// loop over the components in the nc program
FOREACH item IN components(ncp) {
// Check that it is a toolpath
IF item.RootType == 'nctoolpath' {
REAL Time = $entity('toolpath',$item.name).statistics.LeadsandLinks.Times.plunge + $entity('toolpath',$item.name).statistics.LeadsandLinks.Times.ramp+ $entity('toolpath',$item.name).statistics.LeadsandLinks.Times.rapid
$Time = $Time + $entity('toolpath',$item.name).statistics.LeadsandLinks.Times.others + $entity('toolpath',$item.name).statistics.cuttingmoves.Times.arcs + $entity('toolpath',$item.name).statistics.cuttingmoves.Times.linear
STRING tpTime = ''
STRING hours = STRING(INT($Time/60))
IF INT($hours) < 10 {
$hours = '0' + $hours
}
STRING mins = STRING(INT($Time%60))
IF INT($mins) < 10 {
$mins = '0' + $mins
}
STRING secs = STRING(INT((($Time-INT($Time%60))*60)))
IF INT($secs) < 10 {
$secs = '0' + $secs
}
$tpTime = $hours + ":" + $mins + ":" + $secs
$ncptime = $ncptime + $Time
$sumtime = $sumtime + $Time
// Use MEMBER to check that we have not seen this name before
IF NOT member(names, item.Name) {
// Add name to list
bool ok = add_last(names, item.Name)
// Output data for current toolpath
STRING line = item.Name + "," + item.Toolname.value + "," + $tpTime
FILE WRITE $line TO "output"
}
}
}
// Write an empty line
STRING empty_line = " "
FILE WRITE $empty_line TO "output"
}
// Close File
FILE CLOSE "output"