I only know a workaround for this problem: https://forums.autodesk.com/t5/powermill-forum/getting-then-selected-folder-name/m-p/8497952
The attached macro attempts to find the name of the selected folder in four ways:
1.use active_folder() function
2.use explorer_selected_entities() function
3.use active toolpath
4.select by list
ENTITY LIST SelectedToolpaths={}
STRING SelectedFolder=''
IF active_folder() != "" AND substring(active_folder(),0,8) == 'Toolpath' {
$SelectedToolpaths=folder(active_folder())
$SelectedFolder=active_folder()
} ELSE {
ENTITY LIST SelItems=explorer_selected_entities()
IF size($SelItems)>0 AND $SelItems[0].RootType=='toolpath' {
$SelectedToolpaths=folder(dirname(pathname($SelItems[0])))
$SelectedFolder=dirname(pathname($SelItems[0]))
} ELSEIF entity_exists('toolpath','') {
$SelectedToolpaths=folder(dirname(pathname(entity('toolpath',''))))
$SelectedFolder=dirname(pathname(entity('toolpath','')))
} ELSE {
STRING LIST FolderList=get_folders('toolpath')
INT I=INPUT CHOICE $FolderList 'Please select folder'
IF error($I) {
RETURN
}
$SelectedToolpaths=folder($FolderList[$I])
$SelectedFolder=$FolderList[$I]
}
}
STRING LIST FolderList=get_folders($SelectedFolder)
IF size($FolderList) > 0 {
ENTITY LIST UnselectToolpaths={}
FOREACH F IN $FolderList {
$UnselectToolpaths=$UnselectToolpaths+folder($f)
}
// subtract not working with entities: $Diff list is equal with $SelectedToolpath
ENTITY LIST Diff={}
$Diff=subtract($SelectedToolpaths,$UnselectToolpaths)
// subtract working with strings
STRING LIST L1=extract($SelectedToolpaths,'Name')
STRING LIST L2=extract($UnselectToolpaths,'Name')
STRING LIST L3=subtract($L1,$L2)
$SelectedToolpaths={}
FOREACH item IN $L3 {
INT I=add_last($SelectedToolpaths,entity('toolpath',$item))
}
}
FOREACH tp IN $SelectedToolpaths {
print=$tp.Name
}