Skip to content

Commit

Permalink
Simple object marking script for Marlin (to support MarlinFirmware/Ma…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Shashlov authored and Kirill Shashlov committed Oct 18, 2019
1 parent 46c371e commit 3772a88
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions plugins/PostProcessingPlugin/scripts/MarlinObjectsMarking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Cura PostProcessingPlugin
# Author: Kirill Shashlov
# Date: October, 2019

# Licence: AGPLv3 or higher

from ..Script import Script
from UM.Application import Application
from UM.Logger import Logger

class MarlinObjectsMarking(Script):
def __init__(self):
super().__init__()

def getSettingDataString(self):
return """{
"name": "Mark different objects (meshes) with Marlin firmware rules",
"key": "MarlinObjectsMarking",
"metadata": {},
"version": 2,
"settings": {}
}"""

def execute(self, data):
obj_dict = {}
for layer in data:
lay_idx = data.index(layer)
layerCommandLines = layer.split("\n")
for commandLine in layerCommandLines:
if not commandLine.startswith(";"):
continue

command_idx = layerCommandLines.index(commandLine)

if commandLine.startswith(";TYPE:SKIRT") or \
commandLine.startswith(";MESH:NONMESH"):
layerCommandLines.insert(command_idx + 1, self.putValue("", M=86, S=-1))
continue

if commandLine.startswith(";MESH:"):
obj_name = commandLine.split(":")[1]
obj_index = obj_dict.setdefault(obj_name, len(obj_dict.keys()))
layerCommandLines.insert(command_idx + 1, self.putValue("", M=86, S=obj_index))

data[lay_idx] = "\n".join(layerCommandLines)
return data

0 comments on commit 3772a88

Please sign in to comment.