replace a character in file with a macro

replace a character in file with a macro

Anonymous
Not applicable
2,790 Views
21 Replies
Message 1 of 22

replace a character in file with a macro

Anonymous
Not applicable

hello,

how can i replace a character in file with a macro on powermill.

for example :

 

O6992
T30 M6
G8 P1
G0 G90 X74.057 Y-430.296 S12000 M3
G0 G43 Z12.021 H30 M8
Z5.0 F3000
G1 Z-1.791 F30000
Y-430.466
X74.173 Y-431.051
X74.505 Y-431.548
X75.003 Y-431.88

 

I want to replace M3 by M3 T17 

 

O6992
T30 M6
G8 P1
G0 G90 X74.057 Y-430.296 S12000 M3 T17 
G0 G43 Z12.021 H30 M8
Z5.0 F3000
G1 Z-1.791 F30000
Y-430.466
X74.173 Y-431.051
X74.505 Y-431.548
X75.003 Y-431.88

 

if someone can help me Smiley Happy

0 Likes
Accepted solutions (1)
2,791 Views
21 Replies
Replies (21)
Message 21 of 22

rafael.sansao
Advisor
Advisor
Accepted solution

Hello @Anonymous,

 

Run the "param.mac" macro on the Powermill.

BOOL err = 0
$err = ERROR $folder('NCProgram')[0].name
INT Pos = 0
INT Next_Pos = 0

WHILE NOT $err {
	STRING NC_Name = $folder('NCProgram')[$Pos].name
	STRING NC_Name_Next = ''
	IF NOT MEMBER($entity('ncprogram',$NC_Name).userparameters._keys, "NC_tool_next") {
		EDIT USERPAR ncprogram $NC_Name NAME "NC_tool_next"
		EDIT USERPAR ncprogram $NC_Name TYPE 'String'
		CREATE USERPAR ncprogram $NC_Name
	}
	${entity('ncprogram';$NC_Name).UserParameters.NC_tool_next} = '0'
	$Next_Pos = $Pos + 1
	$err = ERROR $folder('NCProgram')[$Next_Pos].name
	IF NOT $err {
		INT tool_num = 0
		$NC_Name_Next = $folder('NCProgram')[$Next_Pos].name
		FOREACH item IN components(entity('ncprogram',$NC_Name_Next)) {
			IF lcase(item.RootType) == 'nctoolpath' {
				$tool_num = $item.ToolNumber.FromTool
				BREAK
			}
		}
		${entity('ncprogram';$NC_Name).UserParameters.NC_tool_next} = $tool_num
	}
$Pos = $Pos + 1
}

 

In Pmpost:

1.png

 

 

2.png

 

 

3.png

 

 

4.png

 

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

Message 22 of 22

Anonymous
Not applicable

hello rafael

 

great Smiley Very Happy

 

At the beginning, it did not work. There was an error in standart parameter :

 

 

large (1).png  

 

but nothing serious Smiley Happy

 

param 3.jpg

 

after, I wrote the parameters as on the following screen and it works very well

 

param 2.jpgparam 1.jpg

 

 

Thank you very much for your help and solution, thanks to all those who helped me. 

 

 

 

 

 

0 Likes