コード例 #1
0
ファイル: build_util_model.py プロジェクト: Gussy/placeFlow
	def parse_load(self):
		if (self.cache and self.file_object):
			return
			
		print "Parsing: %s" % self.filename
		
		if self.__filetype == "Centroid - Custom Eagle":
			self.file_object = EagleCentroidFile(self.filename)
		elif self.__filetype == "BOM - Eagle":
			self.file_object = EagleBOMFile(self.filename)
		elif self.__filetype == "Do Not Populate list":
			self.file_object = DNPFile(self.filename)
		elif self.__filetype == "Placement Order":
			self.file_object = OrderingFile(self.filename)
		elif self.__filetype == "Shapes - Eagle LBR SCR":
			scriptfile = EagleScriptLibraryFileImporter(self.filename)
			self.file_object = {}
			for name,val in scriptfile.subfiles.iteritems():
				if name.endswith("pac"):
					use_layers = [21,22,48,51,52]
					s = ShapeFile()
					s.name = val.name
					s.wires = []
					s.rects = []
					for li,lv in val.layers.iteritems():
						if li in use_layers:
							s.wires.extend(lv.wires)
							s.rects.extend(lv.rects)
					try:
						s.smds = val.layers[1].smds
					except KeyError:
						s.smds = None
					if not s.wires:
						print "Warning, %s contains no wires" % name
					self.file_object[val.name] = s
			
		elif "Silkscreen" in self.__filetype or "Copper" in self.__filetype:
			# Gerber loading is more complicated
			
			f = GD.parseFile(self.__filename)
			if (not f):
				print "Could not parse %s" % self.__filename
				return 
			
			p = GD.runRS274XProgram(f)
			if (not f):
				print "Could not create polygons for %s" % self.__filename
				return 
				
			polys = []
			for i in p.all:
				segs = i.getPolyData().segs
				s = []
				for j in xrange(len(segs)):
					a = segs[j]
					b = segs[(j+1)% len(segs)]
						
					slope = math.atan2(b.y - a.y, b.x-a.x)

					p = a.x, a.y
					
					pc = (a.x+b.x)/2.0, (b.y+a.y)/2
					r = math.sqrt((b.x-a.x)**2 + (b.y-a.y)**2) / 2
					
					s.append(p)
					if a.lt == GD.point_line.line_render_type_t.LR_ARC:
						for j in xrange(1,9):
							t = slope + math.pi/9.0 * j + math.pi
							s.append(point_project(pc, r, t))
					
					
				polys.append(s)
			self.file_object = PolygonFile(polys, "BOTTOM" in self.__filetype, self.visible, self.__filetype)
コード例 #2
0
ファイル: drc_driver.py プロジェクト: hmantz/DRCBotV2
#!/usr/bin/python

import gerberDRC as GD

import gerberDRC.util as GU
import sys
path = sys.argv[1]

GD.setDebugLevel(GD.debug_level_t(0))

f = GD.parseFile(path)
if not f:
	print "Could not parse file %s" % path
	exit(1)
	
p = GD.runRS274XProgram(f)

if not p:
	print "Could not run program"
	exit(1)
for n, i in enumerate(p.layers):
	print "Layer %d: '%s'" % (n,i.name)
	print "\tpolarity: %s" %(i.polarity)
	
	
	
import cairo._cairo as cairo

	
def createCairoLineCenterLinePath(obj, cr):
	cr.move_to (obj.sx, obj.sy);