get toolpath selected folder names

get toolpath selected folder names

hx
Advocate Advocate
1,772 Views
3 Replies
Message 1 of 4

get toolpath selected folder names

hx
Advocate
Advocate
Get use command to return the names to a list which was selected in toolpath tree nodes?
0 Likes
Accepted solutions (1)
1,773 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Accepted solution

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
}

 

Message 3 of 4

Genericxg
Advocate
Advocate

Is the folder displayed like this

2020-09-08_17-25-32.png

0 Likes
Message 4 of 4

phocvet
Enthusiast
Enthusiast

I WISH TO GET THE NUMBER OF TOOLPATH IN 1 LIBRARY

0 Likes