Пример #1
0
    def writefiles(self, name):
        sf = open(name.replace(".", "_") + ".scad", "w")
        facets = []
        for i in self.models.values():

            r = i.rot
            o = i.offsets
            #print os.path.split(i.filename)
            #print self.basedir
            #sf.write('translate([%s,%s,%s]) rotate([0,0,%s]) import_stl("%s");\n' % (str(o[0]), str(o[1]), str(o[2]), r, self.basedir + "/" + os.path.split(i.filename)[1]))
            if os.path.split(i.filename)[0] != os.path.split(sf.name)[0]:
                relpath = os.path.relpath(i.filename,sf.name)
            else:
                relpath = os.path.split(i.filename)[1]
            #endif
            #relpath = os.path.relpath(i.filename,sf.name)[3:]
            #print "basedir " + self.basedir
            #print "sf " + sf.name
            #print "relpath " + relpath
            sf.write('translate([%s,%s,%s]) rotate([0,0,%s]) import_stl("%s");\n' % (str(o[0]), str(o[1]), str(o[2]), r, relpath))
            if r != 0:
                i = i.rotate([0, 0, r])
            if o != [0, 0, 0]:
                i = i.translate([o[0], o[1], o[2]])
            facets += i.facets
        sf.close()
        stltool.emitstl(name, facets, "plater_export")
        print _("wrote %s") % name
Пример #2
0
def zimage(name, out):
    i = wx.Image(name)
    s = i.GetSize()
    print len(map(ord, i.GetData()[::3]))
    b = map(ord, i.GetData()[::3])
    data = []
    for i in xrange(s[0]):
        data += [b[i * s[1]:(i + 1) * s[1]]]
    #data = [i[::5] for i in data[::5]]
    emitstl(out, genscape(data, zscale = 0.1).facets, name)
Пример #3
0
def zimage(name, out):
    i = wx.Image(name)
    s = i.GetSize()
    print len(map(ord, i.GetData()[::3]))
    b = map(ord, i.GetData()[::3])
    data = []
    for i in xrange(s[0]):
        data += [b[i * s[1]:(i + 1) * s[1]]]
    # data = [i[::5] for i in data[::5]]
    emitstl(out, genscape(data, zscale = 0.1).facets, name)
Пример #4
0
 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
Пример #5
0
	def doExport(self):
		self.stlFrame.commit()
		objs = self.stlFrame.getStls()
		facets = []
		for o in objs:
			facets.extend(o.facets)
			
		fn = asksaveasfilename(parent=self, title="Export to File", filetypes=[("STL files", "*.stl")], initialdir=self.settings.lastdirectory, defaultextension=".stl")
		if not fn:
			return
		
		stltool.emitstl(fn, facets=facets, objname="PlaterObject", binary=False)
		self.modified = False
Пример #6
0
 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():
             r=i.rot
             o=i.offsets
             if r != 0:
                 i=i.rotate([0,0,-r])
             if o != [0,0,0]:
                 i=i.translate([o[0],-o[1],o[2]])
             facets+=i.facets
         stltool.emitstl(name,facets,"plater_export")
         print "wrote ",name
Пример #7
0
 def writefiles(self,name):
     sf=open(name.replace(".","_")+".scad","w")
     facets=[]
     for i in self.models.values():
         
         r=i.rot
         o=i.offsets
         sf.write('translate([%s,%s,%s]) rotate([0,0,%s]) import_stl("%s");\n'%(str(o[0]),str(o[1]),str(o[2]),r,os.path.split(i.filename)[1]))
         if r != 0:
             i=i.rotate([0,0,r])
         if o != [0,0,0]:
             i=i.translate([o[0],o[1],o[2]])
         facets+=i.facets
     sf.close()
     stltool.emitstl(name,facets,"plater_export")
     print "wrote ",name
Пример #8
0
    def writefiles(self, name):
        sf = open(name.replace(".", "_") + ".scad", "w")
        facets = []
        for i in self.models.values():

            r = i.rot
            o = i.offsets
            sf.write('translate([%s, %s, %s]) rotate([0, 0, %s]) import_stl("%s");\n' % (str(o[0]), str(o[1]), str(o[2]), r, os.path.split(i.filename)[1]))
            if r != 0:
                i = i.rotate([0, 0, r])
            if o != [0, 0, 0]:
                i = i.translate([o[0], o[1], o[2]])
            facets += i.facets
        sf.close()
        stltool.emitstl(name, facets, "plater_export")
        print _("wrote "), name
Пример #9
0
 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():
             r = i.rot
             o = i.offsets
             if r != 0:
                 i = i.rotate([0, 0, -r])
             if o != [0, 0, 0]:
                 i = i.translate([o[0], -o[1], o[2]])
             facets += i.facets
         stltool.emitstl(name, facets, "plater_export")
         print "wrote ", name
Пример #10
0
 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()
         sf=open(name.replace(".","_")+".scad","w")
         
         facets=[]
         for i in self.models.values():
             
             r=i.rot
             o=i.offsets
             sf.write('translate([%s,%s,%s]) rotate([0,0,%s]) import_stl("%s");\n'%(str(o[0]),str(o[1]),str(o[2]),r,os.path.split(i.filename)[1]))
             if r != 0:
                 i=i.rotate([0,0,-r])
             if o != [0,0,0]:
                 i=i.translate([o[0],-o[1],o[2]])
             facets+=i.facets
         sf.close()
         stltool.emitstl(name,facets,"plater_export")
         print "wrote ",name
Пример #11
0
 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()
         sf=open(name.replace(".","_")+".scad","w")
         
         facets=[]
         for i in self.models.values():
             
             r=i.rot
             o=i.offsets
             sf.write('translate([%s,%s,%s]) rotate([0,0,%s]) import_stl("%s");\n'%(str(o[0]),str(o[1]),str(o[2]),r,os.path.split(i.filename)[1]))
             if r != 0:
                 i=i.rotate([0,0,-r])
             if o != [0,0,0]:
                 i=i.translate([o[0],-o[1],o[2]])
             facets+=i.facets
         sf.close()
         stltool.emitstl(name,facets,"plater_export")
         print "wrote ",name
Пример #12
0
	def doSaveAs(self, evt):
		wildcard = "STL (*.stl)|*.stl;*.STL"
		dlg = wx.FileDialog(
			self, message="Save file as ...", defaultDir=self.settings.lastdirectory, 
			defaultFile="", wildcard=wildcard, style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT
			)
		
		rc = dlg.ShowModal()
		if rc == wx.ID_OK:
			path = dlg.GetPath().encode('ascii','ignore')
			if os.path.splitext(path)[1].lower() != ".stl":
				path += ".stl"
			
		dlg.Destroy()
		if rc != wx.ID_OK:
			return
		
		self.stlCanvas.commitDeltas(None)
		objs = self.files.getStlObjects()
		facets = []
		for o in objs:
			facets.extend(o.facets)
			
		self.savedfile = path
		
		emitstl(path, facets=facets, objname="PlaterObject", binary=False)
		self.modified = False
		
		dlg = wx.MessageDialog(self,
			"File '%s' written" % path,
			"Save",
			wx.OK | wx.ICON_INFORMATION)
		
		self.parent.exportStlFile(self.savedfile, self.settings.autoexport, self.settings.autoenqueue)

		dlg.ShowModal()
		dlg.Destroy()
		self.enableButtons()