forked from Ultimaker/Cura
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple object marking script for Marlin (to support MarlinFirmware/Ma…
- 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.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
plugins/PostProcessingPlugin/scripts/MarlinObjectsMarking.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |