Commit 5fc81cad authored by Guillaume Seguin's avatar Guillaume Seguin

Speedup stl plater by only loading files once when multiple copies are added

parent 999fa8cf
...@@ -30,6 +30,7 @@ import sys ...@@ -30,6 +30,7 @@ import sys
import re import re
import traceback import traceback
import subprocess import subprocess
from copy import copy
from printrun import stltool from printrun import stltool
from printrun.objectplater import Plater from printrun.objectplater import Plater
...@@ -270,8 +271,18 @@ class StlPlater(Plater): ...@@ -270,8 +271,18 @@ class StlPlater(Plater):
path = os.path.split(name)[0] path = os.path.split(name)[0]
self.basedir = path self.basedir = path
if name.lower().endswith(".stl"): if name.lower().endswith(".stl"):
#Filter out the path, just show the STL filename. for model in self.models.values():
self.load_stl_into_model(name, name) if model.filename == name:
newmodel = copy(model)
newmodel.offsets = list(model.offsets)
newmodel.rot = model.rot
newmodel.scale = list(model.scale)
self.add_model(name, newmodel)
self.s.drawmodel(newmodel, 2)
break
else:
#Filter out the path, just show the STL filename.
self.load_stl_into_model(name, name)
self.Refresh() self.Refresh()
def load_stl_into_model(self, path, name, offset = [0, 0, 0], rotation = 0, scale = [1.0, 1.0, 1.0]): def load_stl_into_model(self, path, name, offset = [0, 0, 0], rotation = 0, scale = [1.0, 1.0, 1.0]):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment