@lamtuyphong11
DELETE NCPROGRAM ALL
string list $subFolders = get_folders('Toolpath')
int $index = input choice $subFolders 'Select Folder'
//Create nc program
string $ncName = ''
dialogs message off
foreach $tp in folder($subFolders[$index]) {
int posit = position($tp.name,"-")
if posit != -1 {
string $prefix = substring($tp.name, 0 , $posit)
$ncName = $tp.Name
if not entity_exists('ncprogram', $ncName) {
create ncprogram ${ncName}
}
}
}
// add toolpath into nc program
//--------------------------------------------------------------------------------------------
FOREACH $prog IN folder('ncprogram') {
int k = 0
ACTIVATE NCProgram $prog.name
//add main toolpath
EDIT NCPROGRAM ; APPEND TOOLPATH $prog.name
int posit = position($prog.name,"-")
string $prefix = substring($prog.name, 0 , $posit)
foreach $tp in folder($subFolders[$index]) {
// add sub toolpath if exists
WHILE k < 50 {
String tp_check = $prefix + "+" + $k
IF ENTITY_EXISTS('toolpath', $tp_check) {
EDIT NCPROGRAM ; APPEND TOOLPATH $tp_check
//edit ncprogram $prog insert toolpath $tp_check last
}
$k= $k + 1
}
}
}