-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathaltium-pcbdata.js
More file actions
128 lines (102 loc) · 3.02 KB
/
altium-pcbdata.js
File metadata and controls
128 lines (102 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
function getfield(_comp_, _fields_) {
var fields = [];
for (const key in _fields_) {
var field = _fields_[key];
if (field == "Value") {
fields.push(_comp_.val);
} else if (field == "Footprint") {
fields.push(_comp_.footprint);
} else {
if (field in _comp_.extra_fields)
fields.push(_comp_.extra_fields[field]);
else
fields.push('');
}
}
return fields;
}
function getgroup(_comp_, _fields_) {
var fields = [];
for (const key in _fields_) {
var field = _fields_[key];
if (field == "Value") {
fields.push(_comp_.val);
} else if (field == "Footprint") {
fields.push(_comp_.footprint);
} else {
if (field in _comp_.extra_fields)
fields.push(_comp_.extra_fields[field]);
else
fields.push('');
}
}
return fields;
}
function fromaltium(_data_, _config_, _altiumconfig_) {
//TODO: no nets
// var _nets = {};
// nets.push("No Net");
// _nets["No Net"] = "No Net";
//TODO: NoBOM<>Skipped looks like it DNP
//bom.skipped.push(index);
var group_fields = _altiumconfig_.group_fields;
var show_fields = _config_.fields;
var bom = {};
bom.B = [];
bom.F = [];
bom.both = [];
bom.fields = {};
bom.skipped = [];
var index = 0;
var _B = {};
var _F = {};
var _both = {};
for (const key in _data_.components) {
var item = _data_.components[key];
var groupKey = JSON.stringify(getgroup(item, group_fields));
if (item.layer == "F") {
if (!(groupKey in _F)) {
_F[groupKey] = [];
}
_F[groupKey].push([item.ref, index]);
}
if (item.layer == "B") {
if (!(groupKey in _B)) {
_B[groupKey] = [];
}
_B[groupKey].push([item.ref, index]);
}
if (!(groupKey in _both)) {
_both[groupKey] = [];
}
_both[groupKey].push([item.ref, index]);
bom.fields[index] = getfield(item, show_fields);
index++;
}
for (const key in _F) {
var group = _F[key];
bom.F.push(group);
}
for (const key in _B) {
var group = _B[key];
bom.B.push(group);
}
for (const key in _both) {
var group = _both[key];
bom.both.push(group);
}
var result = {};
result.bom = bom;
result.drawings = _data_.pcbdata.drawings;
result.edges = _data_.pcbdata.edges;
result.edges_bbox = _data_.pcbdata.edges_bbox;
result.font_data = _data_.pcbdata.font_data;
result.footprints = _data_.pcbdata.footprints;
result.metadata = _data_.pcbdata.metadata;
result.nets = _data_.pcbdata.nets;
result.tracks = _data_.pcbdata.tracks;
result.zones = _data_.pcbdata.zones;
result.ibom_version = "v2.10.0";
return result;
}
var pcbdata = fromaltium(altiumbom, config, altiumconfig);