Estou executando algumas instruções de máquina Gcode e preciso adicionar uma instrução no início da linha onde cada primeira instância, F 180.0
mas pule a segunda
por exemplo
G00 X 0.0000 Y 0.0000 Z 10.0000
G00 X 24.5230 Y 44.6619 Z 5.0000
G01 X 24.5230 Y 44.6619 Z 0.0000 F 180.0
G01 X 24.5585 Y 45.2432 Z 0.0000 F 180.0
G01 X 24.6723 Y 45.8451 Z 0.0000
Se tornaria
G00 X 0.0000 Y 0.0000 Z 10.0000
G00 X 24.5230 Y 44.6619 Z 5.0000
M03 G01 X 24.5230 Y 44.6619 Z 0.0000 F 180.0
G01 X 24.5585 Y 45.2432 Z 0.0000 F 180.0
G01 X 24.6723 Y 45.8451 Z 0.0000
Suponho que o mesmo princípio possa ser usado, mas preciso adicionar a cada linha que tenhaZ5.0000
G00 X 0.0000 Y 0.0000 Z 10.0000
M05 G00 X 24.5230 Y 44.6619 Z 5.0000
M03 G01 X 24.5230 Y 44.6619 Z 0.0000 F 180.0
G01 X 24.5585 Y 45.2432 Z 0.0000 F 180.0
G01 X 24.6723 Y 45.8451 Z 0.0000
Responder1
- Ctrl+H
- Encontre o que:
\A(?:(?:(?!\bF 180\.0\b).)+\R)+\K^(?=.+?\bF 180\.0\b)
- Substituir com:
M03
<-- há um espaço após M03 - VERIFICAR Caso de compatibilidade
- VERIFICAR Envolver em torno
- VERIFICAR Expressão regular
- DESMARCAR
. matches newline
* - Replace all
Explicação:
\A # beginning of file
(?: # non capture group ()
(?: # non capture group (1 line that doesn't contain F 180.0)
(?! # negative lookahead, make sure we haven't after:
\b # word boundary
F 180\.0 # literally
\b # word boundary
) # end lookahead
. # any character but newline
)+ # end group, may appear 1 or more times
\R # any kind of line break
)+ # end group, may appear 1 or more times
\K # forget all we have seen until this position(i.e. skip all lines before the first occurrence of F 180.0)
^ # beginning of line
(?= # positive lookahead, make sure we have after:
.+? # 1 or more any character but newline, not greedy
\b # word boundary
F 180\.0 # literally
\b # word boundary
) # end lookahead
Captura de tela (antes):
Captura de tela (depois):
A segunda substituição é semelhante, mas mais simples:
- Encontre o que:
^(?=.+?\bZ 5.0000\b)
- Substituir com:
M03
Captura de tela (depois):