For example in this file there is a structure like this:
Code: Select all
G21 ; set units to millimeters
M104 S200 ; set temperature
G28 ; home all axes
G1 Z5 F5000 ; lift nozzle
M109 S200 ; wait for temperature to be reached
G90 ; use absolute coordinates
G92 E0
M82 ; use absolute distances for extrusion
G1 F1800.000 E-1.00000
G92 E0
G1 Z15.350 F7800.000
G1 X152.500 Y152.500 F7800.000
G1 E1.00000 F1800.000
G1 X347.500 Y152.500 E18.37972 F378.000
G1 X347.500 Y347.500 E35.75944
...
G1 X343.831 Y156.169 E733.08114
G1 F1800.000 E732.08114
G92 E0
G1 Z20.350 F7800.000
G1 X347.500 Y152.500 F7800.000
G1 E1.00000 F1800.000
G1 X347.500 Y347.500 E249.28171 F1260
G1 X152.500 Y347.500 E497.56342
...
I want to delete or avoid the lines with ";" and replace in sequence the values for each X, Y and Z like this:
Code: Select all
CONST robtarget P1:=[[15.350,152.500,15.350],.....
CONST robtarget P2:=[[347.500,152.500,15.350],.....
CONST robtarget P3:=[[347.500,347.500,15.350],.....
...
CONST robtarget Pm:=[[347.500,152.500,20.350],......
...
CONST robtarget Pn:=[[X,Y,Z],.....
...
but I tried a lot of attempts, but no result made... Can someone help me?
I also have to generate 2 files (robtarget.txt and movel.txt) that will be included in Mod_%modnum%.mod to generate ABB rapid instructions...!
Like this:
Code: Select all
MODULE Mod_1234
CONST robtarget P1:=[[x,y,z],.....;
...
PROC Routine()
ConfL\Off;
MoveL P1,v60,z5,mytool\Wobj:=mywobj;
...
ENDPROC
PROC MainMove()
Routine;
ENDPROC
ENDMODULE
The portion of the code I used is:
Code: Select all
@echo off
set nomefile=composition.gcode
set /a x=0
set /a riga=0
set modnum=1234
set wobj=mywobj
set tool=mytool
set vel=v60
IF EXIST Mod_%modnum%.mod DEL /f Mod_%modnum%.mod
IF EXIST movel.txt DEL /f movel.txt
IF EXIST robtarget.txt DEL /f robtarget.txt
IF EXIST xresult.txt DEL /f xresult.txt
IF EXIST yresult.txt DEL /f yresult.txt
IF EXIST zresult.txt DEL /f zresult.txt
findstr /n "Z" "%nomefile%" >> zresult.txt
findstr /n "X" "%nomefile%" >> xresult.txt
findstr /n "Y" "%nomefile%" >> yresult.txt
set xval=%xvalnew%
set yval=%yvalnew%
set zval=%zvalnew%
:while
if %x% lss 20 (
set /a riga+=1
echo CONST robtarget P%x%:=[[%xval%,%yval%,%zval%],[0.00223,-0.994008,-0.109258,-0.002251],[1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]; >> robtarget.txt
echo MoveL P%x%,%vel%,z5,%tool%\Wobj:=%wobj%; >> movel.txt
:: pause>nul
set /a x+=1
set /a riga+=1
goto :while
)
echo MODULE Mod_%modnum% >> Mod_%modnum%.mod
echo. >> Mod_%modnum%.mod
copy robtarget.txt >> Mod_%modnum%.mod
:: del robtarget.txt
echo PROC Routine() >> Mod_%modnum%.mod
echo ConfL\Off; >> Mod_%modnum%.mod
echo ENDPROC>> Mod_%modnum%.mod
echo.>> Mod_%modnum%.mod
echo PROC MainMove()>> Mod_%modnum%.mod
echo Routine;>> Mod_%modnum%.mod
echo ENDPROC>> Mod_%modnum%.mod
echo.>> Mod_%modnum%.mod
echo ENDMODULE>> Mod_%modnum%.mod
Thanks and have a good time!
