diff --git a/.gitignore b/.gitignore index 0d20b64..433acf2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.pyc +/nbproject/private/ \ No newline at end of file diff --git a/gerbmerge/gerbmerge.py b/gerbmerge/gerbmerge.py index 9bee1fa..99db63e 100755 --- a/gerbmerge/gerbmerge.py +++ b/gerbmerge/gerbmerge.py @@ -566,6 +566,7 @@ def merge(opts, args, gui = None): if config.Config['cutlinelayers'] and (layername in config.Config['cutlinelayers']): fid.write('%s*\n' % drawing_code_cut) # Choose drawing aperture + #print "writing drawcode_cut: %s" % drawing_code_cut job.writeCutLines(fid, drawing_code_cut, OriginX, OriginY, MaxXExtent, MaxYExtent) if config.Config['cropmarklayers']: diff --git a/gerbmerge/jobs.py b/gerbmerge/jobs.py index 8ec3030..7033fe8 100644 --- a/gerbmerge/jobs.py +++ b/gerbmerge/jobs.py @@ -1138,68 +1138,90 @@ class JobLayout: def notEdge(x, X): return round(abs(1000*(x-X))) - assert self.x and self.y + #assert self.x and self.y - radius = config.GAT[drawing_code].dimx/2.0 - - # Start at lower-left, proceed clockwise - x = self.x - radius - y = self.y - radius +#if job has a boardoutline layer, write it, else calculate one + outline_layer = 'boardoutline'; + if self.job.hasLayer(outline_layer): + # somewhat of a hack here; making use of code in gerbmerge, around line 516, + # we are going to replace the used of the existing draw code in the boardoutline + # file with the one passed in (which was created from layout.cfg ('CutLineWidth') + # It is a hack in that we are assuming there is only one draw code in the + # boardoutline file. We are just going to ignore that definition and change + # all usages of that code to our new one. As a side effect, it will make + # the merged boardoutline file invalid, but we aren't using it with this method. + temp = [] + for x in self.job.commands[outline_layer]: + if x[0] == 'D': + temp.append(drawing_code) ## replace old aperture with new one + else: + temp.append(x) ## keep old command + self.job.commands[outline_layer] = temp - left = notEdge(self.x, X1) - right = notEdge(self.x+self.width_in(), X2) - bot = notEdge(self.y, Y1) - top = notEdge(self.y+self.height_in(), Y2) + #self.job.writeGerber(fid, outline_layer, X1, Y1) + self.writeGerber(fid, outline_layer) + + else: + radius = config.GAT[drawing_code].dimx/2.0 + + # Start at lower-left, proceed clockwise + x = self.x - radius + y = self.y - radius - BL = ((x), (y)) - TL = ((x), (y+self.height_in()+2*radius)) - TR = ((x+self.width_in()+2*radius), (y+self.height_in()+2*radius)) - BR = ((x+self.width_in()+2*radius), (y)) + left = notEdge(self.x, X1) + right = notEdge(self.x+self.width_in(), X2) + bot = notEdge(self.y, Y1) + top = notEdge(self.y+self.height_in(), Y2) - if not left: - BL = (BL[0]+2*radius, BL[1]) - TL = (TL[0]+2*radius, TL[1]) + BL = ((x), (y)) + TL = ((x), (y+self.height_in()+2*radius)) + TR = ((x+self.width_in()+2*radius), (y+self.height_in()+2*radius)) + BR = ((x+self.width_in()+2*radius), (y)) - if not top: - TL = (TL[0], TL[1]-2*radius) - TR = (TR[0], TR[1]-2*radius) + if not left: + BL = (BL[0]+2*radius, BL[1]) + TL = (TL[0]+2*radius, TL[1]) - if not right: - TR = (TR[0]-2*radius, TR[1]) - BR = (BR[0]-2*radius, BR[1]) + if not top: + TL = (TL[0], TL[1]-2*radius) + TR = (TR[0], TR[1]-2*radius) - if not bot: - BL = (BL[0], BL[1]+2*radius) - BR = (BR[0], BR[1]+2*radius) + if not right: + TR = (TR[0]-2*radius, TR[1]) + BR = (BR[0]-2*radius, BR[1]) - BL = (util.in2gerb(BL[0]), util.in2gerb(BL[1])) - TL = (util.in2gerb(TL[0]), util.in2gerb(TL[1])) - TR = (util.in2gerb(TR[0]), util.in2gerb(TR[1])) - BR = (util.in2gerb(BR[0]), util.in2gerb(BR[1])) + if not bot: + BL = (BL[0], BL[1]+2*radius) + BR = (BR[0], BR[1]+2*radius) - # The "if 1 or ..." construct draws all four sides of the job. By - # removing the 1 from the expression, only the sides that do not - # correspond to panel edges are drawn. The former is probably better - # since panels tend to have a little slop from the cutting operation - # and it's easier to just cut it smaller when there's a cut line. - # The way it is now with "if 1 or....", much of this function is - # unnecessary. Heck, we could even just use the boardoutline layer - # directly. - if 1 or left: - fid.write('X%07dY%07dD02*\n' % BL) - fid.write('X%07dY%07dD01*\n' % TL) + BL = (util.in2gerb(BL[0]), util.in2gerb(BL[1])) + TL = (util.in2gerb(TL[0]), util.in2gerb(TL[1])) + TR = (util.in2gerb(TR[0]), util.in2gerb(TR[1])) + BR = (util.in2gerb(BR[0]), util.in2gerb(BR[1])) - if 1 or top: - if not left: fid.write('X%07dY%07dD02*\n' % TL) - fid.write('X%07dY%07dD01*\n' % TR) + # The "if 1 or ..." construct draws all four sides of the job. By + # removing the 1 from the expression, only the sides that do not + # correspond to panel edges are drawn. The former is probably better + # since panels tend to have a little slop from the cutting operation + # and it's easier to just cut it smaller when there's a cut line. + # The way it is now with "if 1 or....", much of this function is + # unnecessary. Heck, we could even just use the boardoutline layer + # directly. + if 1 or left: + fid.write('X%07dY%07dD02*\n' % BL) + fid.write('X%07dY%07dD01*\n' % TL) - if 1 or right: - if not top: fid.write('X%07dY%07dD02*\n' % TR) - fid.write('X%07dY%07dD01*\n' % BR) + if 1 or top: + if not left: fid.write('X%07dY%07dD02*\n' % TL) + fid.write('X%07dY%07dD01*\n' % TR) - if 1 or bot: - if not right: fid.write('X%07dY%07dD02*\n' % BR) - fid.write('X%07dY%07dD01*\n' % BL) + if 1 or right: + if not top: fid.write('X%07dY%07dD02*\n' % TR) + fid.write('X%07dY%07dD01*\n' % BR) + + if 1 or bot: + if not right: fid.write('X%07dY%07dD02*\n' % BR) + fid.write('X%07dY%07dD01*\n' % BL) def setPosition(self, x, y): self.x=x diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..c712e95 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,5 @@ +gerbmerge.dir=gerbmerge +java.lib.path= +main.file=gerbmerge.py +platform.active=Python_2.7.3 +python.lib.path=/home/scott/development/gerbmerge| diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..891396b --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,13 @@ + + + org.netbeans.modules.python.project + + + NewPythonProject + + + + + + +