Create NC program from toolpaths inside of folders

inbirta
Participant
Participant

Create NC program from toolpaths inside of folders

inbirta
Participant
Participant

Hey guys! I have a problem creating NC programs with macro. I found this macro, which creates NC programs from folders. 

// Loop through all toolpaths
FOREACH $tp IN FOLDER('toolpath') {
 STRING Fold=pathname( $Tp )
 STRING NCProgDir=DIRNAME($Fold)
 STRING NCProgName=SUBSTRING($NCProgDir,9)
 
 IF NOT ENTITY_EXISTS('Ncprogram',$NCProgName) AND $NCProgDir != "Toolpath" {
  EDIT FOLDER $NCProgDir NCPROGRAM
 }
}

 Id like to modify to able to use it when the folder inside an other folder. 

For example there is a main folder ( A ) and inside there is X and Y folder wich contains toolpaths. I hope you can help me. Thanks! 

0 Likes
Reply
Accepted solutions (1)
264 Views
3 Replies
Replies (3)

icse
Collaborator
Collaborator

this one lets you select the folders you whant:

 

string list $folders = get_folders('toolpath')
int list $indexer = input choice multiple $folders 'select'

foreach $i in $indexer {
	STRING Fold = $folders[$i]
	STRING NCProgDir = DIRNAME($Fold)
	STRING NCProgName = SUBSTRING($NCProgDir,9)
	
	IF NOT ENTITY_EXISTS('Ncprogram',$NCProgName) AND $NCProgDir != "Toolpath" {
		EDIT FOLDER $NCProgDir NCPROGRAM
	}
}
0 Likes

inbirta
Participant
Participant

Thank you for you answer!

 

The problem that i have with your solution is its create a combination of X and Y folder. Id like to make a two separate NC program from X and Y folder.

0 Likes

icse
Collaborator
Collaborator
Accepted solution

this should exclude toolpaths in subfolders:

 

string list $folders = get_folders('toolpath')
int list $indexer = input choice multiple $folders 'select'

foreach $i in $indexer {

	STRING $f = $folders[$i]
	STRING $NCProgName = basename($f)
	
	IF NOT ENTITY_EXISTS('Ncprogram',$NCProgName) {
	
		CREATE NCPROGRAM ${NCProgName}
		foreach $tp in filter(folder($f),'dirname(pathname(this)) == "' + $f + '"') {
			EDIT NCPROGRAM $NCProgName APPEND TOOLPATH ${tp.Name}
		}
		
	}
}

 

0 Likes