I use Cura 3.3.1 and I try to create a plugIn by modifying the SearchAndReplace.py file
Everything works fine except that there is a problem in the layer "parsing" by the script
In the execute function I add a new line (the last line but one)
def execute(self, data):
search_string = self.getSettingValueByKey("search")
if not self.getSettingValueByKey("is_regex"):
search_string = re.escape(search_string) #Need to search for the actual string, not as a regex.
search_regex = re.compile(search_string)
replace_string = self.getSettingValueByKey("replace")
for layer_number, layer in enumerate(data):
data[layer_number] = re.sub(search_regex, replace_string, layer) #Replace all.
data[layer_number] = ("JCD >>> %d \n" % layer_number) + data[layer_number] # !!!! new line added
return data
the result on the GCode file is not consistent
At the begining of the file there are 2 "layers"
beginning of the post processed GCode OK
JCD >>> 0
;FLAVOR:Marlin
;TIME:249
;Filament used: 0.194653m
;Layer height: 0.2
;POSTPROCESSED
JCD >>> 1
;Generated with Cura_SteamEngine 3.3.1
...
;LAYER_COUNT:28
JCD >>> 2
;JCDLAYER:0
...
then OK (difference of 2 between layer number-postPocess parsing- and LAYER number -slicing-up to LAYER 21
layer 21 OK
;TIME_ELAPSED:215.547436
JCD >>> 23
;LAYER:21
layer 22 not detected ! no new line inserted before the ;LAYER:22 line
;TIME_ELAPSED:222.765224
;LAYER:22
layer 23 OK but the difference now is only one
;TIME_ELAPSED:228.186561
JCD >>> 24
;JCDLAYER:23
What is the problem ?
jeton27.stl