Implementing panelization function
Opened this issue · 0 comments
Hi,
I made a extension library for pcb-tools to panelize gerber and drill data. That is published as pcb-tools-extension. This library supports PCB rotation, merging multiple board data, and handling DXF file in order to generate board outline data and snap off halls called "mouse bites". The right image is a sample of that library.
All functionalities are implemented in outer classes inherited from classes in pcb-tools at this moment. However, I feel some of them should be implemented in original pcb-tools.
I want to try to port these functions into pcb-tools and issue a pull request if you don't mind that.
Now I'm planning to do following order of priority. Could you please let me know what do you feel this plan?
-
Writing RS-274x and Excellon data back from object
GerberFile
andExcellonFile
has a functionwrite()
to output RS-274x format data or Excellon format data. However, current implementation does not generate data as same as a file read. I had to several codes to solve this problem.
The major part of them are codes to add expressive power of aperture macro statement as syntax tree object.
AMParamStmt.to_gerber()
generateAM
statement string fromprimitive
which express a set of aperture primitive. These primitive objects inherited fromAMPrimitive
are results of reflecting modifier values specified inAD
statement. That means primitives inAMParamStmt
are correct in case of only latest macro definition which refer the aperture macro.
Therefore, I added primitive object which keep all structure of formula include variables. These are implemented in am_primitive.py and am_expression.py.
I understand RPN instructions referred byAMParamStmt.instructions
keep original aperture macro definition expression completely andAM
statement can be generated from this instructions. However, syntax tree is much easier to modify macro definition. That is helpful to implement unit conversion function etc.I believe that expressive power should be contains in original
AMParamStmt
class. What do you think? -
Rotation
horizontal displacement function is already implemented in your library asoffset()
function. In oder to help panelizing work, I added rotation function in my extension.
Not only coordinate data which represented byCoordStmt
, but also apertures should be rotated. We need some technic to realize this result, because standard aperture templates except polygon such as rectangle cannot be rotate.
I choose the way that allAD
statement which use standard aperture template will be changed to refer equivalent aperture macros, because aperture macro supports rotation angle parameter. In case of rectangle template , following macro is used.%AMMACR* 21,1,$1,$2,0,0,20* 1,0,$3,0,0,20*%
Alternatively, converting aperture definition to filled polygon sequense controlled by
G36
andG37
might be also work.
If you can accept my solution to realize rotation, I will port that function. -
Merging panel data
In my extension, I made a dedicated class to merge multiple RS-274x or Excellon data (composition.py).
Alternatively,GerberFile
andExcellonFile
might have a capability to merge other file.
I considered both way, then I chose the former. Because it is simple in case of supporting different type of files, such as DXF and RS-274x.
I think the above two function, write back and rotation, must be implemented in original pub-tools library. However this merging function might be keep in extension library.
I will do in order to your intention. -
Conversion from DXF to gerber
I created a classDxfFile
inherited fromCamFile
in order to handle DXF file(dxf.py).
After porting the above 1 to 3 functions, I will try to consider that this function should be merge to pcb-tools.
By the way, I found several problems of pcb-tools through developing my extension library. Regarding them, I will register other issues or send pull request.
Thanks