rename Ncprograms macro

rename Ncprograms macro

hrh46
Advocate Advocate
592 Views
4 Replies
Message 1 of 5

rename Ncprograms macro

hrh46
Advocate
Advocate

I have a macro renaming all toolpaths by an index number and tool name.is it possible to rename ncprograms based on

new toolpaths name?

0 Likes
Accepted solutions (1)
593 Views
4 Replies
Replies (4)
Message 2 of 5

icse
Collaborator
Collaborator

I think so...

But i need more information about how you whant to rename the nc program.

 

Can you give me an example?

0 Likes
Message 3 of 5

hrh46
Advocate
Advocate

Ok. This machine has no tool change, so each nc prog even if has multiple toolpaths, use only one unique tool.

assume toolpaths:

1_EM8

4_EM10

5_EM10   

one Nc has both 4_EM10 and 5_EM10, So renaming Ncs should be something like:

1_EM8

4_And_5_EM10

0 Likes
Message 4 of 5

icse
Collaborator
Collaborator
Accepted solution

can you try this:

entity list $ncs = input entity multiple ncprogram 'select nc programs wich should be renamed:'

if size($ncs) < 1 {
	return
}


foreach $nc in $ncs {

	if size(components($nc)) < 1 {
		continue
	}
	
	string list $tpsuffixes = {}
	
	foreach $tp in components($nc) {
		int $i = add_last($tpsuffixes, tokens($tp.Name,'_')[0])
	}
	string $newNcName = join($tpsuffixes,'_And_') + '_' + components($nc)[0].Tool.Name
	
	if $nc.Name == $newNcName {
		continue
	}
	
	if entity_exists('ncprogram',$newNcName) {
		$newNcName = new_entity_name('ncprogram',$newNcName)
	}
	
	rename ncprogram ${nc.Name} ${newNcName}
}
0 Likes
Message 5 of 5

hrh46
Advocate
Advocate

Many Thanks. that was what I need.

0 Likes