|
| 1 | +# pcbdata struct |
| 2 | + |
| 3 | +This document describes pcbdata json structure that plugin |
| 4 | +extracts from PCB file and injects into generated bom page. |
| 5 | + |
| 6 | +```js |
| 7 | +pcbdata = { |
| 8 | + // Describes bounding box of all edge cut drawings. |
| 9 | + // Used for determining default zoom and pan values to fit |
| 10 | + // whole board on canvas. |
| 11 | + "edges_bbox": { |
| 12 | + "minx": 1, |
| 13 | + "miny": 2, |
| 14 | + "maxx": 100, |
| 15 | + "maxy": 200, |
| 16 | + }, |
| 17 | + // Describes all edge cut drawings including ones in footprints. |
| 18 | + // See drawing structure description below. |
| 19 | + "edges": [drawing1, drawing2, ...], |
| 20 | + // Contains all drawings + reference + value texts on silkscreen |
| 21 | + // layer grouped by front and back. |
| 22 | + "silkscreen": { |
| 23 | + "F": [drawing1, drawing2, ...], |
| 24 | + "B": [drawing1, drawing2, ...], |
| 25 | + }, |
| 26 | + // Same as above but for fabrication layer. |
| 27 | + "fabrication": { |
| 28 | + "F": [drawing1, drawing2, ...], |
| 29 | + "B": [drawing1, drawing2, ...], |
| 30 | + }, |
| 31 | + // Describes footprints. |
| 32 | + // See footprint structure description below. |
| 33 | + "modules": [ |
| 34 | + footprint1, |
| 35 | + footprint2, |
| 36 | + ... |
| 37 | + ], |
| 38 | + // PCB metadata from the title block. |
| 39 | + "metadata": { |
| 40 | + "title": "title", |
| 41 | + "revision": "rev", |
| 42 | + "company": "Horns and Hoofs", |
| 43 | + "date": "2019-04-18", |
| 44 | + }, |
| 45 | + // Contains full bom table as well as filtered by front/back. |
| 46 | + // See bom row description below. |
| 47 | + "bom": { |
| 48 | + "both": [bomrow1, bomrow2, ...], |
| 49 | + "F": [bomrow1, bomrow2, ...], |
| 50 | + "B": [bomrow1, bomrow2, ...], |
| 51 | + }, |
| 52 | + // Contains parsed stroke data from newstroke font for |
| 53 | + // characters used on the pcb. |
| 54 | + "font_data": { |
| 55 | + "a": { |
| 56 | + "w": character_width, |
| 57 | + // Contains array of polylines that form the character shape. |
| 58 | + "l": [ |
| 59 | + [[point1x, point1y], [point2x, point2y],...], |
| 60 | + ... |
| 61 | + ] |
| 62 | + }, |
| 63 | + "%": { |
| 64 | + ... |
| 65 | + }, |
| 66 | + ... |
| 67 | + }, |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +# drawing struct |
| 72 | + |
| 73 | +All drawings are either graphical items (arcs, lines, circles) |
| 74 | +or text. |
| 75 | +Rendering method and properties are determined based on `type` |
| 76 | +attribute. |
| 77 | + |
| 78 | + |
| 79 | +## graphical items |
| 80 | + |
| 81 | +### segment |
| 82 | + |
| 83 | +```js |
| 84 | +{ |
| 85 | + "type": "segment", |
| 86 | + "start": [x, y], |
| 87 | + "end": end, |
| 88 | + "width": width, |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +### circle |
| 93 | + |
| 94 | +```js |
| 95 | +{ |
| 96 | + "type": "circle", |
| 97 | + "start": [x, y], |
| 98 | + "radius": radius, |
| 99 | + "width": width, |
| 100 | +} |
| 101 | +``` |
| 102 | + |
| 103 | +### arc |
| 104 | + |
| 105 | +```js |
| 106 | +{ |
| 107 | + "type": "arc", |
| 108 | + "start": [x, y], |
| 109 | + "radius": radius, |
| 110 | + "startangle": angle1, |
| 111 | + "endangle": angle2, |
| 112 | + "width": width, |
| 113 | +} |
| 114 | +``` |
| 115 | + |
| 116 | +### polygon |
| 117 | + |
| 118 | +```js |
| 119 | +{ |
| 120 | + "type": "polygon", |
| 121 | + "pos": [x, y], |
| 122 | + "angle": angle, |
| 123 | + "polygons": [ |
| 124 | + // Polygons are described as set of outlines. |
| 125 | + [ |
| 126 | + [point1x, point1y], [point2x, point2y], ... |
| 127 | + ], |
| 128 | + ... |
| 129 | + ] |
| 130 | +} |
| 131 | +``` |
| 132 | + |
| 133 | +## text |
| 134 | + |
| 135 | +```js |
| 136 | +{ |
| 137 | + "pos": [x, y], |
| 138 | + "text": text, |
| 139 | + "height": height, |
| 140 | + "width": width, |
| 141 | + // -1: justify left |
| 142 | + // 0: justify center |
| 143 | + // 1: justify right |
| 144 | + "horiz_justify": justify, |
| 145 | + "thickness": thickness, |
| 146 | + "attr": [ |
| 147 | + // may include none, one or both |
| 148 | + "italic", "mirrored" |
| 149 | + ], |
| 150 | + "angle": angle |
| 151 | +} |
| 152 | +``` |
| 153 | + |
| 154 | +# footprint struct |
| 155 | + |
| 156 | +Footprints are a collection of pads, drawings and some metadata. |
| 157 | + |
| 158 | +```js |
| 159 | +{ |
| 160 | + "ref": reference, |
| 161 | + "center": [x, y], |
| 162 | + "bbox": { |
| 163 | + "pos": [x, y], |
| 164 | + "size": [x, y], |
| 165 | + }, |
| 166 | + "pads": [ |
| 167 | + { |
| 168 | + "layers": [ |
| 169 | + // Contains one or both |
| 170 | + "F", "B", |
| 171 | + ], |
| 172 | + "pos": [x, y], |
| 173 | + "size": [x, y], |
| 174 | + "angle": angle, |
| 175 | + // Only present if pad is considered first pin. |
| 176 | + // Pins are considered first if it's name is one of |
| 177 | + // 1, A, A1, P1, PAD1 |
| 178 | + // OR footprint has no pads named as one of above and |
| 179 | + // current pad's name is lexicographically smallest. |
| 180 | + "pin1": 1, |
| 181 | + // Shape is one of "rect", "oval", "circle", "roundrect", "custom". |
| 182 | + "shape": shape, |
| 183 | + // Only present if shape is "custom". |
| 184 | + "polygons": [ |
| 185 | + // Set of polylines same as in polygon drawing. |
| 186 | + [[point1x, point1y], [point2x, point2y], ...], |
| 187 | + ... |
| 188 | + ], |
| 189 | + // Only present if shape is "roundrect". |
| 190 | + "radius": radius, |
| 191 | + // Pad type is "th" for standard and NPTH pads |
| 192 | + // "smd" otherwise. |
| 193 | + "type": type, |
| 194 | + // Present only if type is "th". |
| 195 | + // One of "circle", "oblong". |
| 196 | + "drillshape": drillshape, |
| 197 | + // Optional attribute. |
| 198 | + "offset": [x, y], |
| 199 | + }, |
| 200 | + ... |
| 201 | + ], |
| 202 | + "drawings": [ |
| 203 | + // Contains only copper F_Cu, B_Cu drawings of the footprint. |
| 204 | + { |
| 205 | + // One of "F", "B". |
| 206 | + "layer": layer, |
| 207 | + // See drawing struct description above. |
| 208 | + "drawing": drawing, |
| 209 | + }, |
| 210 | + ... |
| 211 | + ], |
| 212 | + // One of "F", "B". |
| 213 | + "layer": layer, |
| 214 | +} |
| 215 | +``` |
| 216 | + |
| 217 | +# bom row struct |
| 218 | + |
| 219 | +Bom row is a 5-tuple (array in js) |
| 220 | + |
| 221 | +```js |
| 222 | +[ |
| 223 | + group_component_count, |
| 224 | + value, |
| 225 | + footprint_name, |
| 226 | + reference_set, |
| 227 | + extra_data |
| 228 | +] |
| 229 | +``` |
| 230 | + |
| 231 | +Reference set is array of tuples of (ref, id) where id is just |
| 232 | +a unique numeric identifier for each footprint that helps avoid |
| 233 | +collisions when references are duplicated. |
| 234 | + |
| 235 | +```js |
| 236 | +[ |
| 237 | + [reference_name, footprint_id], |
| 238 | + ... |
| 239 | +] |
| 240 | +``` |
| 241 | + |
| 242 | +Extra data is array of extra field data. It's order corresponds |
| 243 | +to order of extra field data in config struct. |
| 244 | + |
| 245 | +```js |
| 246 | +[field1_value, field2_value, ...] |
| 247 | +``` |
| 248 | + |
| 249 | +# config struct |
| 250 | + |
| 251 | +```js |
| 252 | +config = { |
| 253 | + "dark_mode": bool, |
| 254 | + "show_pads": bool, |
| 255 | + "show_fabrication": bool, |
| 256 | + "show_silkscreen": bool, |
| 257 | + "highlight_pin1": bool, |
| 258 | + "redraw_on_drag": bool, |
| 259 | + "board_rotation": int, |
| 260 | + "checkboxes": "checkbox1,checkbox2,...", |
| 261 | + // One of "bom-only", "left-right", "top-bottom". |
| 262 | + "bom_view": bom_view, |
| 263 | + // One of "F", "FB", "B". |
| 264 | + "layer_view": layer_view, |
| 265 | + "extra_fields": ["field1_name", "field2_name", ...], |
| 266 | +} |
| 267 | +``` |
0 commit comments