Based on the examples here
https://github.com/nallath/PostProcessingPlugin
Note that I'm not able to test. I reserve the right to submit pull request to the above repo.
https://github.com/nallath/PostProcessingPlugin
# Copyright (c) 2017 Boyan Kolev # The PostProcessingPlugin is released under the terms of the AGPLv3 or higher. from ..Script import Script class InsertTextEveryLayer(Script): def getSettingDataString(self): return """{ "name": "Insert Text in Every Layer", "key": "InsertText", "metadata": {}, "version": 1, "settings": { "insert text": { "label": "Insert Text", "description": "This text will be inserted in each layer.", "type": "str", "default_value": "" }, "insert at": { "label": "Insert at line", "description": "Number of the line (0-based) at which to insert the text.", "type": "int", "default_value": "3" }, } }""" def _process_layer(self, layer): insert_text = self.getSettingValueByKey("insert text") insert_at = self.getSettingValueByKey("insert at") layer = layer.split("\n") layer.insert(insert_at, insert_text) return "\n".join(layer) def execute(self, data): return [self._process_layer(layer) for layer in data]data is list of layers as str. I assume layers look like this
Output:;LAYER:0
M106 S255
G0 F3600 X99.873 Y99.731 Z0.3
G0 X100 Y50
G1 F100 X100 Y10
G1 F20 X110 Y10
G1 F100 X110 Y170
G1 F100 X110 Y10
G1 F20 X100 Y10
G0 X100 Y50
;TYPE:WALL-INNER
G1 F1800 X100.034 Y99.574 E0.02699
G1 X100.225 Y99.441 E0.05491
G1 X100.445 Y99.339 E0.08401
;TIME_ELAPSED:18.234693
i.e. first line is the line of layer index. If this is not the case default value for 'insert at' should be decreased by 1Note that I'm not able to test. I reserve the right to submit pull request to the above repo.