From 9febca7da6a730b3b3ca3a54129a9f88e5c44d14 Mon Sep 17 00:00:00 2001 From: opiopan Date: Thu, 21 Mar 2019 22:00:32 +0900 Subject: initial commit --- README.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 README.md (limited to 'README.md') diff --git a/README.md b/README.md new file mode 100644 index 0000000..e3fb731 --- /dev/null +++ b/README.md @@ -0,0 +1,74 @@ +PCB tools extension +=== +PCB tools extension is a Python library to panelize gerber files. +This library is designed based on [PCB tools](https://github.com/curtacircuitos/pcb-tools) which provides cool functionality to handle PCB such as generationg PCB image from gerber files. + +PCB tools extension adds following function to PCB tools. + +- Rotate PCB data (imprementation is not completed) +- Save loding PCB data +- Merge multiple PCB data +- Translate DXF file to gerber data + +Only RS-274x format and Excellon drill format data can be handled by current version of this library. + +## How to panelize +Following code is a example to panelize two top metal layer files. + +``` python +import gerberex + +ctx = gerberex.GerberComposition() + +metal1 = gerberex.read('board1.gtl') +ctx.merge(metal1) + +metal2 = gerberex.read('board2.gtl') +metal2.to_metric() +metal2.offset(30, 0) +ctx.merge(metal2) + +ctx.dump('panelized-board.gtl') +``` + +In case of Excellon drill data, you have to use ```DrillCompositon``` instead of ```GerberComposition```. + +```python +import gerberex + +ctx = gerberex.DrillComposition() + +drill1 = gerberex.read('board1.txt') +ctx.merge(drill1) + +drill2 = gerberex.read('board2.txt') +drill2.to_metric() +drill2.offset(30, 0) +ctx.merge(drill2) + +ctx.dump('panelized-board.txt') +``` + +## DXF file translation +You can also load a dxf file and handle that as same as RX-274x gerber file.
+This function is useful to generate outline data of pnanelized PCB boad. + +```python +import gerberex + +ctx = gerberex.GerberComposition() +dxf = gerberex.read('outline.dxf') +ctx.merge(dxf) +``` +## Panelized board image Example +This image is generated by original [PCB tools](https://github.com/curtacircuitos/pcb-tools) fucntion. + +

+description +

+ + +## Installation +```shell +$ git clone https://github.com/opiopan/pcb-tools-extension.git +$ pip install pcb-tools-extension \ No newline at end of file -- cgit From 690df56bb71020901167605a87ec451081fa18d7 Mon Sep 17 00:00:00 2001 From: opiopan Date: Sat, 23 Mar 2019 21:59:13 +0900 Subject: add rotation fuction --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index e3fb731..6baa2ee 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ This library is designed based on [PCB tools](https://github.com/curtacircuitos/ PCB tools extension adds following function to PCB tools. -- Rotate PCB data (imprementation is not completed) -- Save loding PCB data +- Rotate PCB data +- Write back loded PCB data (original PCB tools does not work completely) - Merge multiple PCB data - Translate DXF file to gerber data @@ -25,12 +25,16 @@ ctx.merge(metal1) metal2 = gerberex.read('board2.gtl') metal2.to_metric() +metal2.rotate(-20) metal2.offset(30, 0) ctx.merge(metal2) ctx.dump('panelized-board.gtl') ``` +```rotate()``` method can be used to rotate PCB data counterclockwise. you have to specify angle in degree
+```offset()``` method can be used to move PCB data. Specified offset values are interpreted according to unit setting of PCB data. In case of the above code, ```board2.gtl``` move to 30mm left since ```to_metric()``` is called. + In case of Excellon drill data, you have to use ```DrillCompositon``` instead of ```GerberComposition```. ```python @@ -43,6 +47,7 @@ ctx.merge(drill1) drill2 = gerberex.read('board2.txt') drill2.to_metric() +drill2.rotate(-20) drill2.offset(30, 0) ctx.merge(drill2) -- cgit From 0d5e6744d10146dba3310cdf2f1921c086ee74b6 Mon Sep 17 00:00:00 2001 From: opiopan Date: Sun, 24 Mar 2019 11:07:13 +0900 Subject: change README --- README.md | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 6baa2ee..d44593e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,13 @@ PCB tools extension adds following function to PCB tools. Only RS-274x format and Excellon drill format data can be handled by current version of this library. +## Install +PCB tools extension is not registerd to PyPI repository.
+Please install from GitHub repository as below. +```shell +$ pip install git+https://github.com/opiopan/pcb-tools-extension +``` + ## How to panelize Following code is a example to panelize two top metal layer files. @@ -65,15 +72,33 @@ ctx = gerberex.GerberComposition() dxf = gerberex.read('outline.dxf') ctx.merge(dxf) ``` +Circle object, Arc object, Line object and Polyline object are supported. Other kind of objects in DXF file are ignored when translating to gerber data. + +You can specify line width (default 0). PCB tools extension will translate DXF primitive shape to RX-274x line or arc sequense using circle aperture with diamater as same as specified line width.
+ +```python +import gerberex + +dxf = gerberex.read('outline.dxf') +dxf.to_inch() +dxf.width = 0.004 +dxf.write('outline.gml') +``` + +You can also translate DXF closed shape such as circle to RX-274x polygon fill sequence.
+In order to fill closed shape, ```DM_FILL``` has to be set to ```drawing_mode``` property. In this mode, All object except circle and closed polyline will be ignored.
+ +```python +import gerberex + +dxf = gerberex.read('outline.dxf') +dxf.draw_mode = gerberex.DxfFile.DM_FILL +dxf.write('outline.gml') +``` + ## Panelized board image Example This image is generated by original [PCB tools](https://github.com/curtacircuitos/pcb-tools) fucntion.

description

- - -## Installation -```shell -$ git clone https://github.com/opiopan/pcb-tools-extension.git -$ pip install pcb-tools-extension \ No newline at end of file -- cgit From fcd704e1eef9034e2000f55b2918d7df41379408 Mon Sep 17 00:00:00 2001 From: opiopan Date: Sat, 30 Mar 2019 11:16:13 +0900 Subject: add mouse bites generator function --- README.md | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index d44593e..8f90efa 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -PCB tools extension +pcb-tools-extension === -PCB tools extension is a Python library to panelize gerber files. -This library is designed based on [PCB tools](https://github.com/curtacircuitos/pcb-tools) which provides cool functionality to handle PCB such as generationg PCB image from gerber files. +pcb-tools-extension is a Python library to panelize gerber files. +This library is designed based on [pcb-tools](https://github.com/curtacircuitos/pcb-tools) which provides cool functionality to handle PCB such as generationg PCB image from gerber files. -PCB tools extension adds following function to PCB tools. +pcb-tools-extension adds following function to pcb-tools. - Rotate PCB data - Write back loded PCB data (original PCB tools does not work completely) @@ -13,7 +13,7 @@ PCB tools extension adds following function to PCB tools. Only RS-274x format and Excellon drill format data can be handled by current version of this library. ## Install -PCB tools extension is not registerd to PyPI repository.
+pcb-tools-extension is not registerd to PyPI repository.
Please install from GitHub repository as below. ```shell $ pip install git+https://github.com/opiopan/pcb-tools-extension @@ -62,6 +62,8 @@ ctx.dump('panelized-board.txt') ``` ## DXF file translation + +### PCB Outline You can also load a dxf file and handle that as same as RX-274x gerber file.
This function is useful to generate outline data of pnanelized PCB boad. @@ -96,8 +98,33 @@ dxf.draw_mode = gerberex.DxfFile.DM_FILL dxf.write('outline.gml') ``` +### Mouse bites + +mouse bites + + +If ```DM_MOUSE_BITES``` is specified for ```drawing_mode```, filled circles will arranged along a DXF line object at equal intervals.
+DXF file object in this state can be merged to excellon file also. That means you can arrange mouse bites easily. + +```python +import gerberex + +ctx = gerberex.DrillComposition() +drill = gerberex.read('drill.txt') +ctx.merge(drill) + +dxf = gerberex.read('mousebites.dxf') +dxf.draw_mode = gerberex.DxfFile.DM_MOUSE_BITES +dxf.to_metric() +dxf.width = 0.5 +dxf.pitch = 1 +ctx.merge(dxf) + +ctx.dump('merged_drill.txt') +``` + ## Panelized board image Example -This image is generated by original [PCB tools](https://github.com/curtacircuitos/pcb-tools) fucntion. +This image is generated by original [pcb-tools](https://github.com/curtacircuitos/pcb-tools) fucntion.

description -- cgit From 900d992fa3af05f93ac7a4cf717f28598e1a868d Mon Sep 17 00:00:00 2001 From: opiopan Date: Sun, 31 Mar 2019 13:30:15 +0900 Subject: auto detection closed paths in the collection of DXF arc object and line object, then fill these closed path --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index 8f90efa..d6e31a8 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ dxf.write('outline.gml') mouse bites -If ```DM_MOUSE_BITES``` is specified for ```drawing_mode```, filled circles will arranged along a DXF line object at equal intervals.
+If ```DM_MOUSE_BITES``` is specified for ```drawing_mode```, filled circles are arranged along a DXF line object at equal intervals.
DXF file object in this state can be merged to excellon file also. That means you can arrange mouse bites easily. ```python -- cgit From 53816574a986722d7af26c5597248d9c96f31bd3 Mon Sep 17 00:00:00 2001 From: opiopan Date: Sun, 31 Mar 2019 18:16:34 +0900 Subject: fix a minor issue --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index d6e31a8..a3ddf50 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This library is designed based on [pcb-tools](https://github.com/curtacircuitos/ pcb-tools-extension adds following function to pcb-tools. - Rotate PCB data -- Write back loded PCB data (original PCB tools does not work completely) +- Write back loaded PCB data (original pcb-tools does not work in some condition) - Merge multiple PCB data - Translate DXF file to gerber data @@ -39,7 +39,7 @@ ctx.merge(metal2) ctx.dump('panelized-board.gtl') ``` -```rotate()``` method can be used to rotate PCB data counterclockwise. you have to specify angle in degree
+```rotate()``` method can be used to rotate PCB data counterclockwise. you have to specify angle in degree.
```offset()``` method can be used to move PCB data. Specified offset values are interpreted according to unit setting of PCB data. In case of the above code, ```board2.gtl``` move to 30mm left since ```to_metric()``` is called. In case of Excellon drill data, you have to use ```DrillCompositon``` instead of ```GerberComposition```. @@ -88,7 +88,11 @@ dxf.write('outline.gml') ``` You can also translate DXF closed shape such as circle to RX-274x polygon fill sequence.
-In order to fill closed shape, ```DM_FILL``` has to be set to ```drawing_mode``` property. In this mode, All object except circle and closed polyline will be ignored.
+In order to fill closed shape, ```DM_FILL``` has to be set to ```drawing_mode``` property. In this mode, All object except closed shapes listed below are ignored. + +- circle +- closed polyline +- closed path which consist of lines and arcs ```python import gerberex -- cgit From 06ba3e68434e7755f1b19c0c7844d1e0f21da4ad Mon Sep 17 00:00:00 2001 From: opiopan Date: Sun, 31 Mar 2019 23:38:07 +0900 Subject: change document --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index a3ddf50..4c7f7d3 100644 --- a/README.md +++ b/README.md @@ -88,11 +88,11 @@ dxf.write('outline.gml') ``` You can also translate DXF closed shape such as circle to RX-274x polygon fill sequence.
-In order to fill closed shape, ```DM_FILL``` has to be set to ```drawing_mode``` property. In this mode, All object except closed shapes listed below are ignored. +In order to fill closed shape, ```DM_FILL``` has to be set to ```draw_mode``` property. In this mode, All object except closed shapes listed below are ignored. - circle - closed polyline -- closed path which consist of lines and arcs +- closed path which consists of lines and arcs ```python import gerberex @@ -107,7 +107,7 @@ dxf.write('outline.gml') mouse bites -If ```DM_MOUSE_BITES``` is specified for ```drawing_mode```, filled circles are arranged along a DXF line object at equal intervals.
+If ```DM_MOUSE_BITES``` is specified for ```draw_mode```, filled circles are arranged along a DXF line object at equal intervals.
DXF file object in this state can be merged to excellon file also. That means you can arrange mouse bites easily. ```python -- cgit From b7320a6b586e8cf12ea126e7ed4320e6d9f53e99 Mon Sep 17 00:00:00 2001 From: opiopan Date: Mon, 1 Apr 2019 21:26:26 +0900 Subject: add examples --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 4c7f7d3..2099b21 100644 --- a/README.md +++ b/README.md @@ -127,8 +127,11 @@ ctx.merge(dxf) ctx.dump('merged_drill.txt') ``` -## Panelized board image Example -This image is generated by original [pcb-tools](https://github.com/curtacircuitos/pcb-tools) fucntion. +## Panelizing Example +This example board image is generated by following scripts + +- [panelizing script](examples/panelize.py) +- [imaging script](examples/genimage.py)

description -- cgit From eda75275505e14439e2dcd1990d2b95217546db1 Mon Sep 17 00:00:00 2001 From: opiopan Date: Mon, 1 Apr 2019 22:07:56 +0900 Subject: compliant with Python 2.7 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index 2099b21..fd589d9 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ ctx.dump('merged_drill.txt') ``` ## Panelizing Example -This example board image is generated by following scripts +This example board image is generated by following scripts from [these source data](examples). - [panelizing script](examples/panelize.py) - [imaging script](examples/genimage.py) -- cgit From 166e3dfe2be1b4f357ba9bd05f216fcf288fa962 Mon Sep 17 00:00:00 2001 From: opiopan Date: Mon, 1 Apr 2019 22:21:43 +0900 Subject: fix a document issue --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index fd589d9..29a6ec7 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ ctx.dump('merged_drill.txt') ``` ## Panelizing Example -This example board image is generated by following scripts from [these source data](examples). +This example board image is generated by following scripts from [these source data](examples/imputs). - [panelizing script](examples/panelize.py) - [imaging script](examples/genimage.py) -- cgit From b72d891998cc87273b9dd8bfe4d864cbe6a8cc62 Mon Sep 17 00:00:00 2001 From: opiopan Date: Mon, 1 Apr 2019 22:22:47 +0900 Subject: fix a document issue --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index 29a6ec7..9a9100b 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ ctx.dump('merged_drill.txt') ``` ## Panelizing Example -This example board image is generated by following scripts from [these source data](examples/imputs). +This example board image is generated by following scripts from [these source data](examples/inputs). - [panelizing script](examples/panelize.py) - [imaging script](examples/genimage.py) -- cgit From d53293a609a83aa945af6864285b90d36bcbdd69 Mon Sep 17 00:00:00 2001 From: opiopan Date: Wed, 3 Apr 2019 19:05:20 +0900 Subject: add move and rotation capability to DxfFile object --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 9a9100b..a2c309d 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,15 @@ dxf.draw_mode = gerberex.DxfFile.DM_FILL dxf.write('outline.gml') ``` +If you want to arrange simple rectangle for PCB outline, ```gerberex.rectangle()``` is better solution. This generate a object representing a rectangle compatible with DXF file object.
+ +```python +import gerberex + +outline = gerberex.rectangle(width=100, height=100, units='metric') +outline.write('outline.gml') +``` + ### Mouse bites mouse bites -- cgit From e3c59e39cf9bc64ce9d76c324b82956a65515f16 Mon Sep 17 00:00:00 2001 From: opiopan Date: Sun, 7 Apr 2019 22:22:33 +0900 Subject: expand test and fix many issues --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index a2c309d..f992edf 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ In order to fill closed shape, ```DM_FILL``` has to be set to ```draw_mode``` pr import gerberex dxf = gerberex.read('outline.dxf') -dxf.draw_mode = gerberex.DxfFile.DM_FILL +dxf.draw_mode = dxf.DM_FILL dxf.write('outline.gml') ``` @@ -127,7 +127,7 @@ drill = gerberex.read('drill.txt') ctx.merge(drill) dxf = gerberex.read('mousebites.dxf') -dxf.draw_mode = gerberex.DxfFile.DM_MOUSE_BITES +dxf.draw_mode = dxf.DM_MOUSE_BITES dxf.to_metric() dxf.width = 0.5 dxf.pitch = 1 -- cgit From 0d91ed834d7a28b249b86081294a9c1b95e8f39c Mon Sep 17 00:00:00 2001 From: opiopan Date: Sun, 7 Apr 2019 23:32:03 +0900 Subject: compliant with PyPi repository --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index f992edf..20dc7c0 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,8 @@ pcb-tools-extension adds following function to pcb-tools. Only RS-274x format and Excellon drill format data can be handled by current version of this library. ## Install -pcb-tools-extension is not registerd to PyPI repository.
-Please install from GitHub repository as below. ```shell -$ pip install git+https://github.com/opiopan/pcb-tools-extension +$ pip install pcb-tools-extension ``` ## How to panelize @@ -137,10 +135,10 @@ ctx.dump('merged_drill.txt') ``` ## Panelizing Example -This example board image is generated by following scripts from [these source data](examples/inputs). +This example board image is generated by following scripts from [these source data](https://github.com/opiopan/pcb-tools-extension/tree/master/examples/inputs). -- [panelizing script](examples/panelize.py) -- [imaging script](examples/genimage.py) +- [panelizing script](https://github.com/opiopan/pcb-tools-extension/blob/master/examples/panelize.py) +- [imaging script](https://github.com/opiopan/pcb-tools-extension/blob/master/examples/genimage.py)

description -- cgit From a33e9a16863a3a7f1a3e26717d6bcd5e7408a76a Mon Sep 17 00:00:00 2001 From: opiopan Date: Sun, 12 May 2019 08:21:41 +0900 Subject: change supported python version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index 20dc7c0..0429e54 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ pcb-tools-extension adds following function to pcb-tools. Only RS-274x format and Excellon drill format data can be handled by current version of this library. -## Install +## Installation ```shell $ pip install pcb-tools-extension ``` -- cgit From 22f4c8a3f5bdce243908f3787216344b200902df Mon Sep 17 00:00:00 2001 From: Hiroshi Murayama Date: Sat, 17 Aug 2019 23:38:30 +0900 Subject: router mode and G85 slot in excellon file is supported --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 0429e54..d688edf 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,18 @@ pcb-tools-extension adds following function to pcb-tools. Only RS-274x format and Excellon drill format data can be handled by current version of this library. ## Installation +You can install a stable version by following step. + ```shell $ pip install pcb-tools-extension ``` +If you have a intention to try latest developing version, please install as follows. + +```shell +$ pip install git+https://github.com/opiopan/pcb-tools-extension.git +``` + ## How to panelize Following code is a example to panelize two top metal layer files. -- cgit From 2b1c751ff76ebd6901633235ee694cc93dabce81 Mon Sep 17 00:00:00 2001 From: Hiroshi Murayama Date: Mon, 9 Sep 2019 09:07:38 +0900 Subject: improve compatibility with RS-274x specification: - can merge multiple files having different file scope modifier, such as AS, MI, OF, SF, and IR - support modal coordinate notation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index d688edf..271573d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ pcb-tools-extension adds following function to pcb-tools. - Rotate PCB data - Write back loaded PCB data (original pcb-tools does not work in some condition) - Merge multiple PCB data -- Translate DXF file to gerber data +- Translate DXF file to PCB data Only RS-274x format and Excellon drill format data can be handled by current version of this library. -- cgit From 00351ebe277aeb90e7463d1b0bd55402249c4687 Mon Sep 17 00:00:00 2001 From: Hiroshi Murayama Date: Thu, 12 Sep 2019 23:44:50 +0900 Subject: add IP command handling function --- README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 271573d..6c879f2 100644 --- a/README.md +++ b/README.md @@ -151,3 +151,62 @@ This example board image is generated by following scripts from [these source da

description

+ +## Notes + +### Equivalence of output +pcb-tools-extension generate data block stream to focus equivalence of final image, but not focus equivalence of data block sequence. +There are some difference between input data and output data as below. + +- **File Scope Modifier [RS-274x]**
+ Sometimes, commands that affect entire image and should be specified only once in a file, such as ```MI``` (Mirror Image) command, cause contradiction when multiple gerber file are merged.
+ For example, when mergeing a file containing ```%MIA1B0*%``` command and a file containing ```%MIA0B1*``` command, which command should remain as output? + Of cause, it is impossible that generate correct merged image by specifiing any ```MI``` command.
+ pcb-tools-extension translate coordinate data reflecting these file socpe modifier to address this probrem, then ommit these modifier command.
+ ```MI```, ```OF```, ```SF```, ```AS```, ```IP```, and ```IR``` are in a this category. + +- **Coodinate Normalizing [RS-274x, Excellon]**
+ RS-274x specification and Excellon specification allow various notation to express a coordinate. However pcb-tools-extension normalize coordinate notation in order to correct deprecated notation and ease internal process as below. + + - Relative coordinates are translated to absolute coordinates. + - Ommited coordinate values are compensated. + - Leading zeros are ommited. + +- **Unimportant Command [RS-274x, Excellon]**
+ Commands not affecting final image such as comment are ommited. + +### Negative image polarity +Sometimes, ```%IPNEG*%``` is specified at header of RS-274x file to create negative image.
+As mentioned [above](#Equivalence%20of%20output), ```IP``` command is ommited when pcb-tools-extension generate output file. In this case, image polarity is nagated by using ```LP``` command. However this generated file doesn't equal to original file since it does'nt contain base dark image.
+Please merge base dark rectangle explicitly when you handle negative image file as below. + +```python +import gerberex + +ctx = gerberex.GerberComposition() +base = gerberex.rectangle(width=30, height=30, left=-5, bottom=-5, units='metric') +base.draw_mode = base.DM_FILL +ctx.merge(base) +metal = gerberex.read('negative_image.gtl') +ctx.merge(metal) +``` + +## Limitations + +### RS-274x +pcb-tools-extension cannot handle all commands that the RS-274x parser implemented in +[pcb-tool](https://github.com/curtacircuitos/pcb-tools) doesn't handle so far.
+From the imaging point of view, pcb-tools-extension has following limitations. + +- Files contains ```IJ``` and ```IO``` commands, that affect entire image, cannot be handled correctly. +- Files contains ```SR``` command to specify repeated pattern cannot be handled correctly. +- Aperture block defined by ```AB``` command cannot be handled correctly. + +### Excellon +pcb-tools-extension extends excellon parser in [pcb-tool](https://github.com/curtacircuitos/pcb-tools) to support routing operation. However following limitations still remain. + +- User defined stored pattern defined by ```M99``` command cannot be handled. +- Canned text specified by ```M97``` command cannot be handled. +- Patten defined by ```M25``` command cannot be handled. + + -- cgit From 882bf14a8df67e7a3d703bf4acb37650cefbe9f8 Mon Sep 17 00:00:00 2001 From: Hiroshi Murayama Date: Sun, 15 Sep 2019 21:31:39 +0900 Subject: change README --- README.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 6c879f2..8deccd0 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ This example board image is generated by following scripts from [these source da - [imaging script](https://github.com/opiopan/pcb-tools-extension/blob/master/examples/genimage.py)

-description +description

## Notes @@ -159,7 +159,7 @@ pcb-tools-extension generate data block stream to focus equivalence of final ima There are some difference between input data and output data as below. - **File Scope Modifier [RS-274x]**
- Sometimes, commands that affect entire image and should be specified only once in a file, such as ```MI``` (Mirror Image) command, cause contradiction when multiple gerber file are merged.
+ Commands that affect entire image and should be specified only once in a file, such as ```MI``` (Mirror Image) command, sometimes cause contradiction when multiple gerber file are merged.
For example, when mergeing a file containing ```%MIA1B0*%``` command and a file containing ```%MIA0B1*``` command, which command should remain as output? Of cause, it is impossible that generate correct merged image by specifiing any ```MI``` command.
pcb-tools-extension translate coordinate data reflecting these file socpe modifier to address this probrem, then ommit these modifier command.
@@ -172,12 +172,21 @@ There are some difference between input data and output data as below. - Ommited coordinate values are compensated. - Leading zeros are ommited. +- **Single Quadlant mode [RS-274x]**
+ Cercular interpolation coordinate data in single quadlant is difficult to rotate, because circular arc may pass across two quadlants after rotation.
+ In order to avoid this problem, pcb-tools-extension change single quadlant mode coordinates specification to multi quadlangt mode. + +- **NC controll command [Excellon]**
+ Form histrical reason, Excellon NC controll format is used to specify drill information to PCB fabricator.
+ On the other hand, from PCB fabricator point of view, they don't need information other than geometric information, such as drill speed. Because these NC controll sequence doesn't send to NC machine directly, PCB fabricator import customers excellon NC file to their CAD / CAM to pnaelize and check, then they export NC controll data for their NC machine.
+ pcb-tools-extension ommit all NC command which do not contribute to geometry expression. Specifically, only tool definitions (diametor of drill), tool selections, drilling coordinates, and routing paths are output. + - **Unimportant Command [RS-274x, Excellon]**
Commands not affecting final image such as comment are ommited. ### Negative image polarity Sometimes, ```%IPNEG*%``` is specified at header of RS-274x file to create negative image.
-As mentioned [above](#Equivalence%20of%20output), ```IP``` command is ommited when pcb-tools-extension generate output file. In this case, image polarity is nagated by using ```LP``` command. However this generated file doesn't equal to original file since it does'nt contain base dark image.
+As mentioned [above](#Equivalence%20of%20output), ```IP``` command is ommited when pcb-tools-extension generate output file. In this case, image polarity is nagated by using ```LP``` command. However this generated file doesn't equal to original image since it does'nt contain base dark image.
Please merge base dark rectangle explicitly when you handle negative image file as below. ```python @@ -195,7 +204,7 @@ ctx.merge(metal) ### RS-274x pcb-tools-extension cannot handle all commands that the RS-274x parser implemented in -[pcb-tool](https://github.com/curtacircuitos/pcb-tools) doesn't handle so far.
+[pcb-tools](https://github.com/curtacircuitos/pcb-tools) doesn't handle so far.
From the imaging point of view, pcb-tools-extension has following limitations. - Files contains ```IJ``` and ```IO``` commands, that affect entire image, cannot be handled correctly. @@ -203,7 +212,7 @@ From the imaging point of view, pcb-tools-extension has following limitations. - Aperture block defined by ```AB``` command cannot be handled correctly. ### Excellon -pcb-tools-extension extends excellon parser in [pcb-tool](https://github.com/curtacircuitos/pcb-tools) to support routing operation. However following limitations still remain. +pcb-tools-extension extends excellon parser in [pcb-tools](https://github.com/curtacircuitos/pcb-tools) to support routing operation. However following limitations still remain. - User defined stored pattern defined by ```M99``` command cannot be handled. - Canned text specified by ```M97``` command cannot be handled. -- cgit From fc3f1a23b87d9c4e51967abb0ed4107daa2be5cf Mon Sep 17 00:00:00 2001 From: Hiroshi Murayama Date: Sat, 28 Sep 2019 17:40:09 +0900 Subject: improve DXF file handling functions: - DM_LINE mode support to generate Excellon routing sequence - DM_MOUSE_BITES mode support to generate mouse bites along all path also, not only line object --- README.md | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 8deccd0..6f84cb7 100644 --- a/README.md +++ b/README.md @@ -70,19 +70,21 @@ ctx.dump('panelized-board.txt') ## DXF file translation ### PCB Outline -You can also load a dxf file and handle that as same as RX-274x gerber file.
+You can also load a dxf file and handle that as same as RX-274x gerber file or Excellon NC file.
This function is useful to generate outline data of pnanelized PCB boad. ```python import gerberex -ctx = gerberex.GerberComposition() dxf = gerberex.read('outline.dxf') -ctx.merge(dxf) +ctx1 = gerberex.GerberComposition() +ctx1.merge(dxf) +ctx2 = gerberex.DrillComposition() +ctx2.merge(dxf) ``` Circle object, Arc object, Line object and Polyline object are supported. Other kind of objects in DXF file are ignored when translating to gerber data. -You can specify line width (default 0). PCB tools extension will translate DXF primitive shape to RX-274x line or arc sequense using circle aperture with diamater as same as specified line width.
+You can specify line width (default 0). PCB tools extension will translate DXF primitive shape to RX-274x line or arc sequense using circle aperture with diamater as same as specified line width.
```python import gerberex @@ -93,6 +95,19 @@ dxf.width = 0.004 dxf.write('outline.gml') ``` +If ```FT_EXCELLON``` is specified for ```filetype``` argument of ```write()```, Excellon NC data is generated. In this case, Excellon file consists of routing commands using a specified width drill. + + +```python +import gerberex + +dxf = gerberex.read('outline.dxf') +dxf.to_metric() +dxf.width = 0.3 +dxf.write('outline.txt', filetype=dxf.FT_EXCELLON) +``` + + You can also translate DXF closed shape such as circle to RX-274x polygon fill sequence.
In order to fill closed shape, ```DM_FILL``` has to be set to ```draw_mode``` property. In this mode, All object except closed shapes listed below are ignored. @@ -100,6 +115,8 @@ In order to fill closed shape, ```DM_FILL``` has to be set to ```draw_mode``` pr - closed polyline - closed path which consists of lines and arcs +NOTE: ```DM_FILL``` can be used only to generate RX-274x data, it cannot be used to generate Excellon data. + ```python import gerberex @@ -122,7 +139,7 @@ outline.write('outline.gml') mouse bites -If ```DM_MOUSE_BITES``` is specified for ```draw_mode```, filled circles are arranged along a DXF line object at equal intervals.
+If ```DM_MOUSE_BITES``` is specified for ```draw_mode```, filled circles are arranged at equal intervals along a paths consisted of DXF line, arc, circle, and plyline objects.
DXF file object in this state can be merged to excellon file also. That means you can arrange mouse bites easily. ```python -- cgit From 242dc2ae173659a47c694c7423b62125aeb6c9a6 Mon Sep 17 00:00:00 2001 From: Hiroshi Murayama Date: Sun, 29 Sep 2019 19:53:53 +0900 Subject: change README --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index 6f84cb7..2831672 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,25 @@ This example board image is generated by following scripts from [these source da pcb-tools-extension generate data block stream to focus equivalence of final image, but not focus equivalence of data block sequence. There are some difference between input data and output data as below. +- **Aperture definition [RS-274x]**
+ When gerber data is rotated, it's necessory to rotate not only coordinates whilch indicate locations of drawing aperture, but also aperture geometory itself. + However, standard aperture templates, such as rectangle, cannot rotate. These standard aperture templates can be placed only horizontally or vertically.
+ Threfore, pcb-tools-extension replace aperture definitions using standard aperture template to aperture macro that represent equivalent shape.
+ For example, In case of rotating folowing aperture definition 20 degrees counter clockwise, + + ```rs-274x + %ADD10R,1X0.5X0.2*% + ``` + + pcb-toolse-extension generate a aperture macro definition and a aperture definition referencing that macro as below. + + ```rs-274x + %AMMACR* + 21,1,$1,$2,0,0,20* + 1,0,$3,0,0,20*% + %ADD10MACR,1X0.5X0.2*% + ``` + - **File Scope Modifier [RS-274x]**
Commands that affect entire image and should be specified only once in a file, such as ```MI``` (Mirror Image) command, sometimes cause contradiction when multiple gerber file are merged.
For example, when mergeing a file containing ```%MIA1B0*%``` command and a file containing ```%MIA0B1*``` command, which command should remain as output? @@ -233,6 +252,6 @@ pcb-tools-extension extends excellon parser in [pcb-tools](https://github.com/cu - User defined stored pattern defined by ```M99``` command cannot be handled. - Canned text specified by ```M97``` command cannot be handled. -- Patten defined by ```M25``` command cannot be handled. +- Pattern defined by ```M25``` command cannot be handled. -- cgit From 244fcaa5346f4fad819cc2b72857cfb2c472944a Mon Sep 17 00:00:00 2001 From: Hiroshi Murayama Date: Sat, 28 Dec 2019 23:45:33 +0900 Subject: add a function that generate filled gerberdata with representing internal shape by fliping polarity --- README.md | 141 ++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 83 insertions(+), 58 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 2831672..252de53 100644 --- a/README.md +++ b/README.md @@ -68,96 +68,121 @@ ctx.dump('panelized-board.txt') ``` ## DXF file translation +pcb-tools-extension hsa a function to load a DXF file and handle that as same as RX-274x gerber file or Excellon NC file.
+In this version, Only line, circle, arc, and polyline objects are recognized and are translated to gerber file or NC file. -### PCB Outline -You can also load a dxf file and handle that as same as RX-274x gerber file or Excellon NC file.
-This function is useful to generate outline data of pnanelized PCB boad. +### Two way to tranlate DXF file +Both composition objects, ```GerberComposition``` for RX-274x and ```DrillionComposition``` for Excellon, can accept an object created as result of DXF file loaded. When composition object dump text stream, DXF data tranclate to appropriate format data.
+The object which represent DXF file, can also output translated data directly by ```save``` method. In this case output format is specified by ```filetype``` argument. If ```filetype``` argument is ommited, DXF data is translated to RX-274x gerber data. ```python import gerberex +dxf = gerberex.read('sample.dxf') -dxf = gerberex.read('outline.dxf') -ctx1 = gerberex.GerberComposition() -ctx1.merge(dxf) -ctx2 = gerberex.DrillComposition() -ctx2.merge(dxf) +# translate to RX-274x using composition object +ctx = gerberex.GerberComposition() +ctx.merge(dxf) +ctx.dump('sample.gml') + +# translate to Excellon using composition object +ctx = gerberex.DrillComposition() +ctx.merge(dxf) +ctx.dump('sample.txt') + +# translate to RX-274x directly +dxf.save('sample2.gml') + +# translate to Excellon directly +dxf.save('sample2.txt', filetype=dxf.FT_EXCELLON) ``` -Circle object, Arc object, Line object and Polyline object are supported. Other kind of objects in DXF file are ignored when translating to gerber data. -You can specify line width (default 0). PCB tools extension will translate DXF primitive shape to RX-274x line or arc sequense using circle aperture with diamater as same as specified line width.
+### Generating Rectangle +If you want to arrange simple rectangle for PCB outline, ```gerberex.rectangle()``` is better solution. This generate a object representing a rectangle compatible with DXF file object.
```python import gerberex -dxf = gerberex.read('outline.dxf') -dxf.to_inch() -dxf.width = 0.004 -dxf.write('outline.gml') +outline = gerberex.rectangle(width=100, height=100, units='metric') +outline.write('outline.gml') ``` -If ```FT_EXCELLON``` is specified for ```filetype``` argument of ```write()```, Excellon NC data is generated. In this case, Excellon file consists of routing commands using a specified width drill. +### Drawing Mode +PCB tools extension provide three type of translation method that affects geometric finish. These method are specified a value for ```draw_mode``` attribute, ```DM_LINE```, ```DM_MOUSE_BITES```, or ```DM_FILL```.
+```DM_LINE``` and ```DM_MOUSE_BITES``` are used to translate to both of RX-274x and Excellon, however ```DM_FILL``` is used to translate to only RX-274x. +![Drawing Mode](https://raw.githubusercontent.com/wiki/opiopan/pcb-tools-extension/images/draw_mode.jpg) -```python -import gerberex +- **draw_mode = DM_LINE**
+ All edge expressed as DXF line object, circle object, arc object and plyline objects are translated to line and arc applied a circular aperture in case of RX-274x. That circular aperture r radius is specified by ```width``` attribute. Default value of width is 0.
+ In case of Excellon, DXF objects are translated to routing path command sequence. + This function is useful to generate outline data of pnanelized PCB boad. -dxf = gerberex.read('outline.dxf') -dxf.to_metric() -dxf.width = 0.3 -dxf.write('outline.txt', filetype=dxf.FT_EXCELLON) -``` + ```python + import gerberex + dxf = gerberex.read('outline.dxf') + dxf.to_inch() + dxf.width = 0.004 + dxf.write('outline.gml') + ``` -You can also translate DXF closed shape such as circle to RX-274x polygon fill sequence.
-In order to fill closed shape, ```DM_FILL``` has to be set to ```draw_mode``` property. In this mode, All object except closed shapes listed below are ignored. +- **draw_mode = DM_MOUSE_BITES**
+ mouse bites + If DM_MOUSE_BITES is specified for draw_mode, filled circles are arranged at equal intervals along a paths consisted of DXF line, arc, circle, and plyline objects. + DXF file object in this state can be merged to excellon file also. That means you can arrange mouse bites easily. -- circle -- closed polyline -- closed path which consists of lines and arcs + ```python + import gerberex -NOTE: ```DM_FILL``` can be used only to generate RX-274x data, it cannot be used to generate Excellon data. + ctx = gerberex.DrillComposition() + drill = gerberex.read('drill.txt') + ctx.merge(drill) -```python -import gerberex + dxf = gerberex.read('mousebites.dxf') + dxf.draw_mode = dxf.DM_MOUSE_BITES + dxf.to_metric() + dxf.width = 0.5 + dxf.pitch = 1 + ctx.merge(dxf) -dxf = gerberex.read('outline.dxf') -dxf.draw_mode = dxf.DM_FILL -dxf.write('outline.gml') -``` + ctx.dump('merged_drill.txt') + ``` -If you want to arrange simple rectangle for PCB outline, ```gerberex.rectangle()``` is better solution. This generate a object representing a rectangle compatible with DXF file object.
+- **draw_mode = DM_FILL**
+ You can translate DXF closed shape such as circle to RX-274x polygon fill sequence.
+ In order to fill closed shape, ```DM_FILL``` has to be set to ```draw_mode``` property. In this mode, All object except closed shapes listed below are ignored. -```python -import gerberex + - circle + - closed polyline + - closed path which consists of lines and arcs -outline = gerberex.rectangle(width=100, height=100, units='metric') -outline.write('outline.gml') -``` + If a closed shape is completly included in other closed shape, The inner shape will be draw with reversed polality of container shape as above example image.
-### Mouse bites + I assume there are two typical usecase for this mode.
+ One is to arrange logo design on silk layer. This is superior to other method generating raster image data since image data express as vector data.
+ The other one is generating gerber data represented cropped area of panelized PCB. + By merging rectangle and PCB outline data, generate a file represented cropped area as below, and this kind of data is useful to make PCB image look good a little bit.
+ [This script](https://github.com/opiopan/pcb-tools-extension/blob/master/examples/genimage.py) which generate example image shown below, also uses this technic. -mouse bites + ```python + import gerberex + ctx = gerberex.GerberComposition() -If ```DM_MOUSE_BITES``` is specified for ```draw_mode```, filled circles are arranged at equal intervals along a paths consisted of DXF line, arc, circle, and plyline objects.
-DXF file object in this state can be merged to excellon file also. That means you can arrange mouse bites easily. + rectangle = gerberex.rectangle(width=100, height=100, units='metric') + rectangle.draw_mode = rectangle.DM_FILL + ctx.merge(rectangle) + + outline = gerberex.read('outline.dxf') + outline.draw_mode = outline.DM_FILL + outline.negate_polarity() + ctx.merge(outline) -```python -import gerberex + ctx.dump('cropped_area.gml') + ``` -ctx = gerberex.DrillComposition() -drill = gerberex.read('drill.txt') -ctx.merge(drill) - -dxf = gerberex.read('mousebites.dxf') -dxf.draw_mode = dxf.DM_MOUSE_BITES -dxf.to_metric() -dxf.width = 0.5 -dxf.pitch = 1 -ctx.merge(dxf) + NOTE: ```DM_FILL``` can be used only to generate RX-274x data, it cannot be used to generate Excellon data. -ctx.dump('merged_drill.txt') -``` ## Panelizing Example This example board image is generated by following scripts from [these source data](https://github.com/opiopan/pcb-tools-extension/tree/master/examples/inputs). -- cgit From ca23fbd9534ab3cba3fd7b032816766c1150ebf9 Mon Sep 17 00:00:00 2001 From: Hiroshi Murayama Date: Mon, 30 Dec 2019 17:51:48 +0900 Subject: fix bugs that fail judgement of path's containment --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 252de53..a95dc56 100644 --- a/README.md +++ b/README.md @@ -107,14 +107,14 @@ outline.write('outline.gml') ``` ### Drawing Mode -PCB tools extension provide three type of translation method that affects geometric finish. These method are specified a value for ```draw_mode``` attribute, ```DM_LINE```, ```DM_MOUSE_BITES```, or ```DM_FILL```.
+PCB tools extension provide three type of translation method that affects geometric finish. These method are specified a value for ```draw_mode``` attribute, as ```DM_LINE```, ```DM_MOUSE_BITES```, or ```DM_FILL```.
```DM_LINE``` and ```DM_MOUSE_BITES``` are used to translate to both of RX-274x and Excellon, however ```DM_FILL``` is used to translate to only RX-274x. ![Drawing Mode](https://raw.githubusercontent.com/wiki/opiopan/pcb-tools-extension/images/draw_mode.jpg) - **draw_mode = DM_LINE**
- All edge expressed as DXF line object, circle object, arc object and plyline objects are translated to line and arc applied a circular aperture in case of RX-274x. That circular aperture r radius is specified by ```width``` attribute. Default value of width is 0.
- In case of Excellon, DXF objects are translated to routing path command sequence. + All edge expressed as DXF line object, circle object, arc object and plyline objects are translated to line and arc applied a circular aperture in case of RX-274x. That circular aperture radius is specified by ```width``` attribute. Default value of width is 0.
+ In case of Excellon, DXF objects are translated to routing path command sequence.
This function is useful to generate outline data of pnanelized PCB boad. ```python @@ -149,8 +149,8 @@ PCB tools extension provide three type of translation method that affects geomet ``` - **draw_mode = DM_FILL**
- You can translate DXF closed shape such as circle to RX-274x polygon fill sequence.
- In order to fill closed shape, ```DM_FILL``` has to be set to ```draw_mode``` property. In this mode, All object except closed shapes listed below are ignored. + You can translate DXF closed shapes such as circle to RX-274x polygon fill sequence.
+ In order to fill closed shapes, ```DM_FILL``` has to be set to ```draw_mode``` property. In this mode, All object except closed shapes listed below are ignored. - circle - closed polyline @@ -158,7 +158,7 @@ PCB tools extension provide three type of translation method that affects geomet If a closed shape is completly included in other closed shape, The inner shape will be draw with reversed polality of container shape as above example image.
- I assume there are two typical usecase for this mode.
+ I assume there are two typical use cases for this mode.
One is to arrange logo design on silk layer. This is superior to other method generating raster image data since image data express as vector data.
The other one is generating gerber data represented cropped area of panelized PCB. By merging rectangle and PCB outline data, generate a file represented cropped area as below, and this kind of data is useful to make PCB image look good a little bit.
@@ -169,7 +169,7 @@ PCB tools extension provide three type of translation method that affects geomet ctx = gerberex.GerberComposition() - rectangle = gerberex.rectangle(width=100, height=100, units='metric') + rectangle = gerberex.rectangle(width=100, height=100, left=0, bottom=0, units='metric') rectangle.draw_mode = rectangle.DM_FILL ctx.merge(rectangle) -- cgit