Skip to content

Commit 93b29dc

Browse files
authored
add: properties 'exclude_from_sim' parse for LibSymbol and Symbol (#136)
* add: properties 'exclude_from_sim' parse for LibSymbol and Symbol * add: simple test for attribute `exclude_from_sim`
1 parent 08bbc4f commit 93b29dc

File tree

3 files changed

+323
-1
lines changed

3 files changed

+323
-1
lines changed

src/kicad/schematic.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ export class LibSymbol {
806806
};
807807
in_bom = false;
808808
on_board = false;
809+
exclude_from_sim = false;
809810
properties: Map<string, Property> = new Map();
810811
children: LibSymbol[] = [];
811812
drawings: Drawing[] = [];
@@ -835,6 +836,7 @@ export class LibSymbol {
835836
),
836837
P.pair("in_bom", T.boolean),
837838
P.pair("on_board", T.boolean),
839+
P.pair("exclude_from_sim", T.boolean),
838840
P.mapped_collection(
839841
"properties",
840842
"property",
@@ -1156,6 +1158,7 @@ export class SchematicSymbol {
11561158
convert: number;
11571159
in_bom = false;
11581160
on_board = false;
1161+
exclude_from_sim = false;
11591162
dnp = false;
11601163
fields_autoplaced = false;
11611164
properties: Map<string, Property> = new Map();
@@ -1174,7 +1177,7 @@ export class SchematicSymbol {
11741177
) {
11751178
/*
11761179
(symbol (lib_id "Device:C_Small") (at 134.62 185.42 0) (unit 1)
1177-
(in_bom yes) (on_board yes) (fields_autoplaced)
1180+
(in_bom yes) (on_board yes) (exclude_from_sim no) (fields_autoplaced)
11781181
(uuid 42d20c56-7e92-459e-8ba3-25545a76a4e9)
11791182
(property "Reference" "C311" (id 0) (at 137.16 182.8862 0)
11801183
(effects (font (size 1.27 1.27)) (justify left)))
@@ -1196,6 +1199,7 @@ export class SchematicSymbol {
11961199
P.pair("convert", T.number),
11971200
P.pair("in_bom", T.boolean),
11981201
P.pair("on_board", T.boolean),
1202+
P.pair("exclude_from_sim", T.boolean),
11991203
P.pair("dnp", T.boolean),
12001204
P.atom("fields_autoplaced"),
12011205
P.pair("uuid", T.string),
Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
(kicad_sch
2+
(version 20231120)
3+
(generator "eeschema")
4+
(generator_version "8.0")
5+
(uuid "5efcc5ba-dc52-4033-83ee-2f99ed02f6eb")
6+
(paper "A4")
7+
(lib_symbols
8+
(symbol "Device:C"
9+
(pin_numbers hide)
10+
(pin_names
11+
(offset 0.254)
12+
)
13+
(exclude_from_sim no)
14+
(in_bom yes)
15+
(on_board yes)
16+
(property "Reference" "C"
17+
(at 0.635 2.54 0)
18+
(effects
19+
(font
20+
(size 1.27 1.27)
21+
)
22+
(justify left)
23+
)
24+
)
25+
(property "Value" "C"
26+
(at 0.635 -2.54 0)
27+
(effects
28+
(font
29+
(size 1.27 1.27)
30+
)
31+
(justify left)
32+
)
33+
)
34+
(property "Footprint" ""
35+
(at 0.9652 -3.81 0)
36+
(effects
37+
(font
38+
(size 1.27 1.27)
39+
)
40+
(hide yes)
41+
)
42+
)
43+
(property "Datasheet" "~"
44+
(at 0 0 0)
45+
(effects
46+
(font
47+
(size 1.27 1.27)
48+
)
49+
(hide yes)
50+
)
51+
)
52+
(property "Description" "Unpolarized capacitor"
53+
(at 0 0 0)
54+
(effects
55+
(font
56+
(size 1.27 1.27)
57+
)
58+
(hide yes)
59+
)
60+
)
61+
(property "ki_keywords" "cap capacitor"
62+
(at 0 0 0)
63+
(effects
64+
(font
65+
(size 1.27 1.27)
66+
)
67+
(hide yes)
68+
)
69+
)
70+
(property "ki_fp_filters" "C_*"
71+
(at 0 0 0)
72+
(effects
73+
(font
74+
(size 1.27 1.27)
75+
)
76+
(hide yes)
77+
)
78+
)
79+
(symbol "C_0_1"
80+
(polyline
81+
(pts
82+
(xy -2.032 -0.762) (xy 2.032 -0.762)
83+
)
84+
(stroke
85+
(width 0.508)
86+
(type default)
87+
)
88+
(fill
89+
(type none)
90+
)
91+
)
92+
(polyline
93+
(pts
94+
(xy -2.032 0.762) (xy 2.032 0.762)
95+
)
96+
(stroke
97+
(width 0.508)
98+
(type default)
99+
)
100+
(fill
101+
(type none)
102+
)
103+
)
104+
)
105+
(symbol "C_1_1"
106+
(pin passive line
107+
(at 0 3.81 270)
108+
(length 2.794)
109+
(name "~"
110+
(effects
111+
(font
112+
(size 1.27 1.27)
113+
)
114+
)
115+
)
116+
(number "1"
117+
(effects
118+
(font
119+
(size 1.27 1.27)
120+
)
121+
)
122+
)
123+
)
124+
(pin passive line
125+
(at 0 -3.81 90)
126+
(length 2.794)
127+
(name "~"
128+
(effects
129+
(font
130+
(size 1.27 1.27)
131+
)
132+
)
133+
)
134+
(number "2"
135+
(effects
136+
(font
137+
(size 1.27 1.27)
138+
)
139+
)
140+
)
141+
)
142+
)
143+
)
144+
)
145+
(symbol
146+
(lib_id "Device:C")
147+
(at 12.7 0 0)
148+
(unit 1)
149+
(exclude_from_sim no)
150+
(in_bom yes)
151+
(on_board yes)
152+
(dnp no)
153+
(fields_autoplaced yes)
154+
(uuid "c518709b-7970-4446-a6ce-a3361aa8daa4")
155+
(property "Reference" "C2"
156+
(at 16.51 -1.2701 0)
157+
(effects
158+
(font
159+
(size 1.27 1.27)
160+
)
161+
(justify left)
162+
)
163+
)
164+
(property "Value" "C"
165+
(at 16.51 1.2699 0)
166+
(effects
167+
(font
168+
(size 1.27 1.27)
169+
)
170+
(justify left)
171+
)
172+
)
173+
(property "Footprint" ""
174+
(at 65.7352 57.15 0)
175+
(effects
176+
(font
177+
(size 1.27 1.27)
178+
)
179+
(hide yes)
180+
)
181+
)
182+
(property "Datasheet" "~"
183+
(at 64.77 53.34 0)
184+
(effects
185+
(font
186+
(size 1.27 1.27)
187+
)
188+
(hide yes)
189+
)
190+
)
191+
(property "Description" "Unpolarized capacitor"
192+
(at 64.77 53.34 0)
193+
(effects
194+
(font
195+
(size 1.27 1.27)
196+
)
197+
(hide yes)
198+
)
199+
)
200+
(pin "2"
201+
(uuid "ecf0e567-28d5-429b-83ad-d515e7673928")
202+
)
203+
(pin "1"
204+
(uuid "95b9bb10-4203-4834-9f04-2ccd4fc5c272")
205+
)
206+
(instances
207+
(project "SimpleTest"
208+
(path "/5efcc5ba-dc52-4033-83ee-2f99ed02f6eb"
209+
(reference "C2")
210+
(unit 1)
211+
)
212+
)
213+
)
214+
)
215+
(symbol
216+
(lib_id "Device:C")
217+
(at 0 0 0)
218+
(unit 1)
219+
(exclude_from_sim yes)
220+
(in_bom yes)
221+
(on_board yes)
222+
(dnp no)
223+
(fields_autoplaced yes)
224+
(uuid "df2f177f-34f3-4c06-9674-c418afc0de9a")
225+
(property "Reference" "C1"
226+
(at 3.81 -1.2701 0)
227+
(effects
228+
(font
229+
(size 1.27 1.27)
230+
)
231+
(justify left)
232+
)
233+
)
234+
(property "Value" "C"
235+
(at 3.81 1.2699 0)
236+
(effects
237+
(font
238+
(size 1.27 1.27)
239+
)
240+
(justify left)
241+
)
242+
)
243+
(property "Footprint" ""
244+
(at 53.0352 57.15 0)
245+
(effects
246+
(font
247+
(size 1.27 1.27)
248+
)
249+
(hide yes)
250+
)
251+
)
252+
(property "Datasheet" "~"
253+
(at 52.07 53.34 0)
254+
(effects
255+
(font
256+
(size 1.27 1.27)
257+
)
258+
(hide yes)
259+
)
260+
)
261+
(property "Description" "Unpolarized capacitor"
262+
(at 52.07 53.34 0)
263+
(effects
264+
(font
265+
(size 1.27 1.27)
266+
)
267+
(hide yes)
268+
)
269+
)
270+
(pin "2"
271+
(uuid "df218389-fb20-4a3d-8ddc-74f23fe85c89")
272+
)
273+
(pin "1"
274+
(uuid "17c20f64-6890-40a9-bce6-98b309fa99da")
275+
)
276+
(instances
277+
(project ""
278+
(path "/5efcc5ba-dc52-4033-83ee-2f99ed02f6eb"
279+
(reference "C1")
280+
(unit 1)
281+
)
282+
)
283+
)
284+
)
285+
(sheet_instances
286+
(path "/"
287+
(page "1")
288+
)
289+
)
290+
)

test/kicad/schematic.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import wires_sch_src from "./files/wires.kicad_sch";
1414
import labels_sch_src from "./files/labels.kicad_sch";
1515
import drawings_sch_src from "./files/drawings.kicad_sch";
1616
import symbols_sch_src from "./files/symbols.kicad_sch";
17+
import symbols_kicad8_sch_src from "./files/symbols_kicad8.kicad_sch";
1718

1819
suite("kicad.schematic.KicadSch(): schematic parsing", function () {
1920
test("with empty schematic file", function () {
@@ -564,4 +565,31 @@ suite("kicad.schematic.KicadSch(): schematic parsing", function () {
564565
mirror: "x",
565566
});
566567
});
568+
569+
// check the KiCad8 symbol attributes
570+
test("with KiCad8 exclude_from_sim attribute", function () {
571+
const sch = new schematic.KicadSch(
572+
"test.kicad8_sch",
573+
symbols_kicad8_sch_src,
574+
);
575+
576+
const symbols = Array.from(sch.symbols.values());
577+
assert.equal(symbols.length, 2);
578+
579+
assert.include(symbols[0], {
580+
exclude_from_sim: false,
581+
});
582+
583+
assert.include(symbols[1], {
584+
exclude_from_sim: true,
585+
});
586+
587+
assert_deep_partial(symbols[0]?.properties.get("Reference"), {
588+
text: "C2",
589+
});
590+
591+
assert_deep_partial(symbols[1]?.properties.get("Reference"), {
592+
text: "C1",
593+
});
594+
});
567595
});

0 commit comments

Comments
 (0)