macro to open the paths folder

macro to open the paths folder

Felipe_Callegario
Advocate Advocate
1,620 Views
6 Replies
Message 1 of 7

macro to open the paths folder

Felipe_Callegario
Advocate
Advocate

I need some help for this macro, currently it is used to activate a toolpath, I would like that when activating the toolpath it expands the folder where the toolpath is located.

 

STRING LIST $names = extract(folder("Toolpath"),"name")
INT LIST $Choices = INPUT CHOICE MULTIPLE $names "Choose_Toolpats"
FOREACH tpn IN $Choices {
ENTITY tp = entity("Toolpath",$names[$tpn])
ACTIVATE TOOLPATH $tp.Name


}

STRING LIST tpathFolders = extract(folder("Toolpath"),"name")
STRING LIST tPaths = {}


$tPaths = extract(folder("Toolpath"),"name")


STRING first = $tpathFolders[$i] + "\" + remove_first(tPaths)
STRING last = $tpathFolders[$i] + "\" + remove_last(tPaths)

// Select all the toolpaths in the folder
EXPLORER SELECT TOOLPATH $first NEW
EXPLORER SELECT TOOLPATH $last SERIES

0 Likes
Accepted solutions (1)
1,621 Views
6 Replies
Replies (6)
Message 2 of 7

kevin.hammond3WX4X
Advocate
Advocate
0 Likes
Message 3 of 7

Felipe_Callegario
Advocate
Advocate

Thanks for your solution, but it's still not what I need, as I use a lot of folders in my project, I want to open only the folder of the tool that is active

 

0 Likes
Message 4 of 7

kamalrajcv
Explorer
Explorer

To achieve the desired functionality, you can add the following lines of code inside the loop after the "ACTIVATE TOOLPATH" command:

 

// Get the folder entity of the current toolpath
ENTITY folderEntity = parent(tp)

// Expand the folder
EXPLORER EXPAND folderEntity

 

This code will retrieve the folder entity of the current toolpath and expand the folder in the PowerMill explorer. Here is the modified code with the above changes:

 

STRING LIST $names = extract(folder("Toolpath"),"name")
INT LIST $Choices = INPUT CHOICE MULTIPLE $names "Choose_Toolpats"
FOREACH tpn IN $Choices {
ENTITY tp = entity("Toolpath",$names[$tpn])
ACTIVATE TOOLPATH $tp.Name

// Get the folder entity of the current toolpath
ENTITY folderEntity = parent(tp)

// Expand the folder
EXPLORER EXPAND folderEntity
}

STRING LIST tpathFolders = extract(folder("Toolpath"),"name")
STRING LIST tPaths = {}


$tPaths = extract(folder("Toolpath"),"name")


STRING first = $tpathFolders[$i] + "\" + remove_first(tPaths)
STRING last = $tpathFolders[$i] + "\" + remove_last(tPaths)

// Select all the toolpaths in the folder
EXPLORER SELECT TOOLPATH $first NEW
EXPLORER SELECT TOOLPATH $last SERIES

 

Note that the above code assumes that each toolpath is located in a folder. If you have toolpaths that are not in folders, you may need to add additional checks to handle those cases.

0 Likes
Message 5 of 7

Felipe_Callegario
Advocate
Advocate

Thank you very much for your answer, but this solution is showing a failure on line 8

forum.png

0 Likes
Message 6 of 7

kevin.hammond3WX4X
Advocate
Advocate
Accepted solution

Try this...

 

STRING path = ""

STRING LIST $names = extract(folder("Toolpath"),"name")
INT LIST $Choices = INPUT CHOICE MULTIPLE $names "Choose_Toolpaths"

FOREACH tpn IN $Choices {
ENTITY tp = entity("Toolpath",$names[$tpn])
ACTIVATE TOOLPATH $tp.Name
//get folder name of active toolpath
$path = dirname(pathname('Toolpath',Name))
WAIT 1.0
//Message info $path
// Expand the Root folder
EXPLORER SELECT toolpath ROOT
DEBUG EXPLORER KEY RIGHT
//Expand active toolpath folder
EXPLORER SELECT FOLDER $path New
DEBUG EXPLORER KEY RIGHT

}

 

Regards Kevin

0 Likes
Message 7 of 7

Felipe_Callegario
Advocate
Advocate

Excellent thank you very much for your solution.

0 Likes