Commit b8d04d18 authored by kliment's avatar kliment

First semi-working version of plater. Only works with ascii stl files for now

parent ffb151b3
......@@ -12,10 +12,12 @@ class stlwrap:
return self.name
class showstl(wx.Frame):
class showstl(wx.Window):
def __init__(self,parent,size,pos):
wx.Window.__init__(self,parent,size=size,pos=pos)
self.l=wx.ListCtrl(self,size=(300,100),pos=(0,size[1]-100))
self.b=wx.Button(self,label="Export",pos=(300,size[1]-100))
self.b.Bind(wx.EVT_BUTTON,self.export)
#self.SetBackgroundColour((0,0,0))
wx.FutureCall(200,self.paint)
self.i=0
......@@ -30,6 +32,18 @@ class showstl(wx.Frame):
self.initpos=None
self.prevsel=-1
def export(self,event):
dlg=wx.FileDialog(self,"Pick file to save to",self.basedir,style=wx.FD_SAVE)
dlg.SetWildcard("STL files (;*.stl;)")
if(dlg.ShowModal() == wx.ID_OK):
name=dlg.GetPath()
facets=[]
for i in self.models.values():
facets+=i.facets
stltool.emitstl(name,facets,"plater_export")
print "wrote ",name
def right(self,event):
dlg=wx.FileDialog(self,"Open file to print",self.basedir,style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard("STL files (;*.stl;)")
......@@ -120,7 +134,7 @@ class showstl(wx.Frame):
class stlwin(wx.Frame):
def __init__(self,size=(500,600)):
wx.Frame.__init__(self,None,size=size)
wx.Frame.__init__(self,None,title="Right-click to add a file",size=size)
self.s=showstl(self,(500,600),(100,100))
if __name__ == '__main__':
......
......@@ -24,6 +24,22 @@ m=[
[0,0,0,1]
]
def emitstl(filename,facets=[],objname="stltool_export"):
if filename is None:
return
f=open(filename,"w")
f.write("solid "+objname+"\n")
for i in facets:
f.write(" facet normal "+" ".join(map(str,i[0]))+"\n outer loop\n")
for j in i[1]:
f.write(" vertex "+" ".join(map(str,j))+"\n")
f.write(" endloop"+"\n")
f.write(" endfacet"+"\n")
f.write("endsolid "+objname+"\n")
f.close()
class stl:
def __init__(self, filename=None):
self.facet=[[0,0,0],[[0,0,0],[0,0,0],[0,0,0]]]
......@@ -112,7 +128,7 @@ class stl:
f.write(" vertex "+" ".join(map(str,j))+"\n")
f.write(" endloop"+"\n")
f.write(" endfacet"+"\n")
f.write("endsolid exported"+"\n")
f.write("endsolid "+self.name+"\n")
f.flush()
def parseline(self,l):
......@@ -156,5 +172,5 @@ if __name__=="__main__" and 0:
break
print i,len(working)
emitstl("sphereout.stl",s.facets,"emitted_object")
#stl("../prusamendel/stl/mendelplate.stl")
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