Assign processed GCode to a mesh instead of the scene

This commit is contained in:
Arjen Hiemstra 2015-03-03 18:00:49 +01:00
parent a7ed3ae2ae
commit 27f475dc79
2 changed files with 31 additions and 14 deletions

View file

@ -1,5 +1,7 @@
from UM.Job import Job
from UM.Application import Application
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Scene.SceneNode import SceneNode
import os
@ -7,11 +9,19 @@ class ProcessGCodeJob(Job):
def __init__(self, message):
super().__init__()
self._scene = Application.getInstance().getController().getScene()
self._message = message
def run(self):
with open(self._message.filename) as f:
data = f.read(None)
Application.getInstance().getController().getScene().gcode = data
objectIdMap = {}
for node in DepthFirstIterator(self._scene.getRoot()):
if type(node) is SceneNode and node.getMeshData():
objectIdMap[id(node)] = node
os.remove(self._message.filename)
node = objectIdMap[self._message.id]
if node:
with open(self._message.filename) as f:
data = f.read(None)
setattr(node.getMeshData(), 'gcode', data)
os.remove(self._message.filename)