Added centering code, tidied up some stuff.
parent
0711c27a70
commit
8b494f9a52
20
plater.py
20
plater.py
|
@ -81,7 +81,6 @@ class showstl(wx.Window):
|
|||
stltool.emitstl(name,facets,"plater_export")
|
||||
print "wrote ",name
|
||||
|
||||
<<<<<<< HEAD
|
||||
def testingloadfile(self,name):
|
||||
print name
|
||||
if not(os.path.exists(name)):
|
||||
|
@ -155,37 +154,44 @@ class showstl(wx.Window):
|
|||
self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\big_gear.stl')
|
||||
self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\big_gear.stl')
|
||||
self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\prusabits\\stl\\x-end-idler.stl')
|
||||
#self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\prusabits\\stl\\x-end-idler.stl')
|
||||
self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\prusabits\\stl\\x-end-idler.stl')
|
||||
self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\prusabits\\stl\\x-end-idler.stl')
|
||||
self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\prusabits\\stl\\pla-bushing.stl')
|
||||
#self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\prusabits\\stl\\x-end-idler.stl')
|
||||
#self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\prusabits\\stl\\pla-bushing.stl')
|
||||
self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\prusabits\\stl\\pla-bushing.stl')
|
||||
self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\top.stl')
|
||||
self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\top.stl')
|
||||
self.testingloadfile('C:\\Users\\tjhowse\\reprap\\models\\top.stl')
|
||||
separation = 2
|
||||
bedsize = [200,200,100]
|
||||
cursor = [0,0,0]
|
||||
newrow = 0
|
||||
max = [0,0]
|
||||
for i in self.models:
|
||||
x = abs(self.models[i].dims[0] - self.models[i].dims[1])
|
||||
y = abs(self.models[i].dims[2] - self.models[i].dims[3])
|
||||
centre = [x/2, y/2]
|
||||
centreoffset = [self.models[i].dims[0] + centre[0], self.models[i].dims[2] + centre[1]]
|
||||
if (newrow == 0) or (newrow < y):
|
||||
newrow = y
|
||||
if (cursor[0]+x+separation) >= bedsize[0]:
|
||||
cursor[0] = 0
|
||||
cursor[1] += newrow+separation
|
||||
newrow = 0
|
||||
|
||||
if (newrow == 0) or (newrow < y):
|
||||
newrow = y
|
||||
#To the person who works out why the offsets are applied differently here:
|
||||
# Good job, it confused the hell out of me.
|
||||
self.models[i].offsets[0] = cursor[0] + centre[0] - centreoffset[0]
|
||||
self.models[i].offsets[1] = cursor[1] + centre[1] + centreoffset[1]
|
||||
if (max[0] == 0) or (max[0] < (cursor[0]+x)):
|
||||
max[0] = cursor[0]+x
|
||||
if (max[1] == 0) or (max[1] < (cursor[1]+x)):
|
||||
max[1] = cursor[1]+x
|
||||
cursor[0] += x+separation
|
||||
if (cursor[1]+y) >= bedsize[1]:
|
||||
print "Bed full, sorry sir :("
|
||||
self.Refresh()
|
||||
return
|
||||
centreoffset = [bedsize[0]-cursor[0],bedsize[1]-cursor[1]]
|
||||
centreoffset = [(bedsize[0]-max[0])/2,(bedsize[1]-max[1])/2]
|
||||
for i in self.models:
|
||||
self.models[i].offsets[0] += centreoffset[0]
|
||||
self.models[i].offsets[1] += centreoffset[1]
|
||||
|
|
Loading…
Reference in New Issue