I am reposting here the same topic posted on https://github.com/realthunder/FreeCAD/issues/422.
I would lika to have a script to convert a layout (made with klayout) into a FC document.
Here annexed a first version of this script but I need help to go on with the development.
Usage: layout2fc.py -stack stack_file dxf_file
The document generated by klayout consists of a dxf file (containing several layers) and a stackup definition.
The latter is formatted with following colums:
layerNum/LayerDataType : zstart zstop #user layer name (not parsed)
Here is an example of stack_file:
scale: 0.001 0
10/0: 0.0 70.0 # TR
4/0: 70.0 71.0 # N1
6/0: 70.0 71.0 # RM
16/0: 70.0 71.0 # RHWH
5/0: 71.0 71.19 # DPC
40/0: 71.19 74.19 # EL
40/2: 74.19 77.19 # EL2
40/1: 77.19 80.19 # EL1:
This format is identical to the Z stack section of the tecnology file generated by klayout (Tools/Manage Technology/...)
But, to be used by my script, these data must be separated in a new file with extension ".stack"
The scale entry was added by me (not present in the klayout technology file) to handle the conversion from micron (unit used in klayout) to mm (unit used in FC).
The script is already able to generate a 3D structure but there are some problems:
1) Generated objects are not visible in the opened FC document. Visibility can be toggled on manually but it is nasty because, typically, a PCB struture may hold many thousends of objects. I do not like to use Select All because I do not want to make visible sketches that are childs of pads.
Ideally I would like to make visible all objects with Visibility=True set on 91 and 112 of annexed script:
Code: Select all
91: body.Visibility = True
112: pad.Visibility =True
2) When I open the generated document I get a lot of error messages like:
Code: Select all
0.000354148 Selection.cpp(1964): Sub-object Stage_1_2_3_LNA_layout_EM#DPC.Y_Axis. not found
0.00052545 Selection.cpp(1964): Sub-object Stage_1_2_3_LNA_layout_EM#DPC.Z_Axis. not found
0.000678069 Selection.cpp(1964): Sub-object Stage_1_2_3_LNA_layout_EM#DPC.XY_Plane. not found
0.000830951 Selection.cpp(1964): Sub-object Stage_1_2_3_LNA_layout_EM#DPC.XZ_Plane. not found
0.00097343 Selection.cpp(1964): Sub-object Stage_1_2_3_LNA_layout_EM#DPC.YZ_Plane. not found
0.0124574 Selection.cpp(1964): Sub-object Stage_1_2_3_LNA_layout_EM#TR.X_Axis001. not found
0.0126192 Selection.cpp(1964): Sub-object Stage_1_2_3_LNA_layout_EM#TR.Y_Axis001. not found
If somebody would like to help on this he should install klayout (on ubuntu/debian using "klayout_0.27.9-1_amd64.deb") and draw a test layout.
The recommanded FC branch is LinkDaily because there are many things on each layer. The script puts all these things in a single body (named as the layer). Unfortunately the one solid per body limitation of master prevents its usage in this application.