npnp 0.1.4

Normalize Pin Net Pad (npnp): pure Rust LCEDA/EasyEDA downloader and Altium library exporter
Documentation
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
# npnp


<p align="center">
  <img src="assets/npnp.png" alt="npnp app logo" width="360">
</p>

<p align="center">
  <a href="Cargo.toml"><img src="https://img.shields.io/badge/version-0.1.3-e05d44?style=flat-square" alt="version 0.1.3"></a>
  <a href="LICENSE.md"><img src="https://img.shields.io/badge/license-PolyForm--NC%201.0-f08c5a?style=flat-square" alt="license PolyForm NC 1.0"></a>
  <a href=".github/workflows/windows-release.yml"><img src="https://img.shields.io/badge/platform-Windows-2ea44f?style=flat-square" alt="platform Windows"></a>
  <a href="https://www.rust-lang.org/"><img src="https://img.shields.io/badge/rust-edition%202024-f28d1a?style=flat-square" alt="rust edition 2024"></a>
</p>

Languages: English | [Chinese]README.zh-CN.md

Normalize Pin Net Pad (`npnp`) is an LCEDA/EasyEDA downloader and Altium library exporter written in pure Rust.

`npnp` searches LCEDA/LCSC components, downloads upstream EasyEDA source data and 3D models, and exports Altium-compatible schematic and PCB footprint libraries.

## Features


- Search LCEDA/LCSC components by keyword, part name, or LCSC ID.
- Download 3D models as STEP or OBJ/MTL.
- Export raw EasyEDA symbol and footprint JSON for inspection.
- Export Altium schematic libraries (`.SchLib`).
- Export Altium PCB footprint libraries (`.PcbLib`).
- Embed STEP models into PCB libraries when upstream STEP data is available.
- Batch export many LCSC IDs from a text file.
- Export either one file per component or merged library pairs.
- Append new components into an existing merged `npnp` library pair without duplicating existing LCSC IDs.
- Show live batch progress with counts, active workers, elapsed time, and the most recently processed component.
- Resume non-merged batch exports with checkpoint files.
- Retry transient LCEDA/EasyEDA request failures automatically.

## Requirements


- Rust toolchain for building from source.
- Network access to LCEDA/EasyEDA APIs when searching, downloading, or exporting.
- Altium Designer is recommended for final visual verification of generated `.SchLib` and `.PcbLib` files.

Install Rust from <https://rustup.rs/> if you do not already have it.

## Build From Source


Clone the repository:

```powershell
git clone https://github.com/linkyourbin/npnp.git npnp
cd npnp
```

Build a debug binary:

```powershell
cargo build
```

Build an optimized release binary:

```powershell
cargo build --release
```

Run the test suite:

```powershell
cargo test
```

Run formatting before publishing or sending a pull request:

```powershell
cargo fmt
```

Run a compile check without producing a release binary:

```powershell
cargo check
```

## Run From Source


When running through Cargo, put `--` before `npnp` arguments:

```powershell
cargo run --quiet --bin npnp -- --help
```

Show ready-to-run examples:

```powershell
cargo run --quiet --bin npnp -- --prompt
```

Show the package version:

```powershell
cargo run --quiet --bin npnp -- --version
```

Run any command from source:

```powershell
cargo run --quiet --bin npnp -- <COMMAND> [OPTIONS]
```

Example source-run search:

```powershell
cargo run --quiet --bin npnp -- search C2040 --limit 5
```

## Run As A Binary


After `cargo build --release`, the Windows binary is:

```powershell
.\target\release\npnp.exe
```

Show help from the built binary:

```powershell
.\target\release\npnp.exe --help
```

Show ready-to-run command examples:

```powershell
.\target\release\npnp.exe --prompt
```

Show the version:

```powershell
.\target\release\npnp.exe --version
```

Run a command with the built binary:

```powershell
.\target\release\npnp.exe <COMMAND> [OPTIONS]
```

If `npnp.exe` is on your `PATH`, use it directly:

```powershell
npnp --help
```

```powershell
npnp --prompt
```

```powershell
npnp search C2040 --limit 5
```

## Install Locally


Install the current checkout as a local Cargo binary:

```powershell
cargo install --path .
```

Verify the installed binary:

```powershell
npnp --version
```

Uninstall the local Cargo-installed binary:

```powershell
cargo uninstall npnp
```

The tool is published to crates.io. Users with a Rust development environment can install it with:

```powershell
cargo install npnp
```

## Command Overview


Top-level help:

```powershell
npnp --help
```

Ready-to-run examples:

```powershell
npnp --prompt
```

Help for a specific command:

```powershell
npnp <COMMAND> --help
```

Available commands:

- `search`
- `download-step`
- `download-obj`
- `export-source`
- `export-schlib`
- `export-pcblib`
- `bundle`
- `batch`

## Command: `search`


Search components by keyword, LCSC ID, manufacturer part, or broad text.

Usage:

```powershell
npnp search <KEYWORD> [--limit <LIMIT>]
```

Examples:

```powershell
npnp search C2040 --limit 5
```

```powershell
npnp search RP2040 --limit 10
```

```powershell
npnp search TYPE-C --limit 20
```

Options:

- `--limit <LIMIT>` controls how many search rows are printed. Default: `20`.

Output includes the search result index, display name, LCSC ID when available, manufacturer, and whether a 3D model is listed.

## Search Result Indexes


Most export/download commands accept `--index <INDEX>`. The default is `--index 1`.

Use this workflow for broad searches:

```powershell
npnp search TYPE-C --limit 20
```

Then export the exact row you want:

```powershell
npnp export-schlib TYPE-C --index 3 --output schlib --force
```

When `<KEYWORD>` is an exact LCSC ID like `C2040` and `--index` is left at `1`, `npnp` prefers the search result whose LCSC ID exactly matches the keyword. Explicit non-default indexes still select the requested search row.

## Command: `download-step`


Download a STEP file for the selected component result.

Usage:

```powershell
npnp download-step <KEYWORD> [--index <INDEX>] [--output <DIR>] [--force]
```

Examples:

```powershell
npnp download-step C2040 --output step --force
```

```powershell
npnp download-step RP2040 --index 1 --output models\step --force
```

Options:

- `--index <INDEX>` selects the search result row. Default: `1`.
- `--output <DIR>` sets the output directory. Default: `step`.
- `--force` overwrites an existing output file.

Typical output layout:

```text
step/
  <footprint-or-component-name>.step
```

## Command: `download-obj`


Download OBJ and MTL files for the selected component result.

Usage:

```powershell
npnp download-obj <KEYWORD> [--index <INDEX>] [--output <DIR>] [--force]
```

Examples:

```powershell
npnp download-obj C2040 --output obj --force
```

```powershell
npnp download-obj RP2040 --index 1 --output models\obj --force
```

Options:

- `--index <INDEX>` selects the search result row. Default: `1`.
- `--output <DIR>` sets the output directory. Default: `obj`.
- `--force` overwrites existing OBJ/MTL files.

Typical output layout:

```text
obj/
  <component-name>.obj
  <component-name>.mtl
```

## Command: `export-source`


Export raw EasyEDA symbol and footprint source JSON files only.

Use this command when you want to inspect upstream payloads before generating Altium libraries.

Usage:

```powershell
npnp export-source <KEYWORD> [--index <INDEX>] [--output <DIR>] [--force]
```

Examples:

```powershell
npnp export-source C2040 --output easyeda_src --force
```

```powershell
npnp export-source RP2040 --index 1 --output debug\easyeda_src --force
```

Options:

- `--index <INDEX>` selects the search result row. Default: `1`.
- `--output <DIR>` sets the output directory. Default: `easyeda_src`.
- `--force` overwrites existing source JSON files.

Typical output layout:

```text
easyeda_src/
  <component-name>_symbol_easyeda.json
  <component-name>_footprint_easyeda.json
```

## Command: `export-schlib`


Export a pure Rust Altium schematic library (`.SchLib`).

Usage:

```powershell
npnp export-schlib <KEYWORD> [--index <INDEX>] [--output <DIR>] [--force]
```

Examples:

```powershell
npnp export-schlib C2040 --output schlib --force
```

```powershell
npnp export-schlib RP2040 --index 1 --output out\schlib --force
```

Options:

- `--index <INDEX>` selects the search result row. Default: `1`.
- `--output <DIR>` sets the output directory. Default: `schlib`.
- `--force` overwrites an existing `.SchLib` file.

Current schematic export includes:

- Symbol body and graphics.
- Pins.
- Multipart symbols when present in source data.
- Metadata records such as `Designator`, `Comment`, `Description`, and parameters.
- PCB footprint implementation links when footprint data is available.

Typical output layout:

```text
schlib/
  <component-name>.SchLib
```

## Command: `export-pcblib`


Export a pure Rust Altium PCB footprint library (`.PcbLib`).

Usage:

```powershell
npnp export-pcblib <KEYWORD> [--index <INDEX>] [--output <DIR>] [--force]
```

Examples:

```powershell
npnp export-pcblib C2040 --output pcblib --force
```

```powershell
npnp export-pcblib RP2040 --index 1 --output out\pcblib --force
```

Options:

- `--index <INDEX>` selects the search result row. Default: `1`.
- `--output <DIR>` sets the output directory. Default: `pcblib`.
- `--force` overwrites an existing `.PcbLib` file.

Current PCB export includes:

- Pads.
- Tracks, arcs, regions, and footprint primitives mapped from EasyEDA data.
- 3D STEP model embedding when a usable upstream STEP model exists.
- Empty 3D body output when no usable STEP model is available.

Typical output layout:

```text
pcblib/
  <component-name>.PcbLib
```

## Command: `bundle`


Export a source bundle for one selected component.

The bundle command writes EasyEDA source JSON files, a STEP file when available, and a manifest JSON file that records the selected component and generated artifacts.

Usage:

```powershell
npnp bundle <KEYWORD> [--index <INDEX>] [--output <DIR>] [--force]
```

Examples:

```powershell
npnp bundle C2040 --output bundle --force
```

```powershell
npnp bundle RP2040 --index 1 --output out\bundle --force
```

Options:

- `--index <INDEX>` selects the search result row. Default: `1`.
- `--output <DIR>` sets the output directory. Default: `bundle`.
- `--force` overwrites existing bundle files.

Typical output layout:

```text
bundle/
  <component-name>_symbol_easyeda.json
  <component-name>_footprint_easyeda.json
  <footprint-or-component-name>.step
  <component-name>_bundle.json
```

The STEP file appears only when the selected component has an upstream 3D model.

## Command: `batch`


Batch export Altium libraries from a text file containing LCSC IDs.

Usage:

```powershell
npnp batch --input <FILE> [--output <DIR>] [--schlib] [--pcblib] [--full] [--merge] [--append] [--library-name <NAME>] [--parallel <N>] [--continue-on-error] [--force]
```

Short input flag:

```powershell
npnp batch -i ids.txt --output batch_out --full --force
```

The input parser extracts IDs in the form `C<number>` from arbitrary text. It accepts lowercase IDs like `c2040`, deduplicates repeated IDs, and preserves first-seen order.

Example `ids.txt`:

```text
C2040
C12074
C569043
```

Export both schematic and PCB libraries, one file per component:

```powershell
npnp batch --input ids.txt --output batch_out --full --parallel 4 --continue-on-error --force
```

Export only schematic libraries:

```powershell
npnp batch --input ids.txt --output batch_schlib --schlib --parallel 4 --continue-on-error --force
```

Export only PCB libraries:

```powershell
npnp batch --input ids.txt --output batch_pcblib --pcblib --parallel 4 --continue-on-error --force
```

Export both targets using explicit flags instead of `--full`:

```powershell
npnp batch --input ids.txt --output batch_out --schlib --pcblib --parallel 4 --continue-on-error --force
```

Write one merged `.SchLib` and one merged `.PcbLib`:

```powershell
npnp batch --input ids.txt --output merged_out --merge --library-name MyLib --full --continue-on-error --force
```

Write only a merged schematic library:

```powershell
npnp batch --input ids.txt --output merged_schlib --merge --library-name MySchLib --schlib --continue-on-error --force
```

Write only a merged PCB library:

```powershell
npnp batch --input ids.txt --output merged_pcblib --merge --library-name MyPcbLib --pcblib --continue-on-error --force
```

Append only the missing parts into an existing merged library pair created by `npnp`:

```powershell
npnp batch --input new_ids.txt --output merged_out --merge --append --library-name MyLib --full --continue-on-error
```

Batch options:

- `--input <FILE>` or `-i <FILE>` is required.
- `--output <DIR>` sets the output directory. Default: `batch`.
- `--schlib` exports schematic libraries.
- `--pcblib` exports PCB libraries.
- `--full` exports both schematic and PCB libraries.
- `--merge` writes one merged library per selected target instead of one file per component.
- `--append` adds only missing components into an existing merged `npnp` library pair and skips duplicate LCSC IDs.
- `--library-name <NAME>` sets the merged output filename prefix.
- `--parallel <N>` sets concurrent jobs for non-merged batch export. Default: `4`.
- `--continue-on-error` keeps processing remaining IDs if one ID fails.
- `--force` ignores checkpoint skips and overwrites existing outputs.

Non-merged batch output layout:

```text
batch_out/
  .checkpoint
  schlib/
    <component-a>.SchLib
    <component-b>.SchLib
  pcblib/
    <component-a>.PcbLib
    <component-b>.PcbLib
```

Merged batch output layout:

```text
merged_out/
  MyLib.SchLib
  MyLib.PcbLib
```

Checkpoint behavior:

- Non-merged batch exports create `.checkpoint` in the output directory.
- Completed IDs are written to `.checkpoint`.
- Later runs skip completed IDs unless `--force` is used.
- Merged batch exports rebuild the merged output and do not use the non-merged checkpoint layout.
- Merged `--append` runs reuse the existing merged `npnp` libraries, skip duplicate LCSC IDs, and write back one updated merged pair.

## Recommended Workflows


Exact LCSC ID workflow:

```powershell
npnp search C2040 --limit 5
npnp export-schlib C2040 --output out\schlib --force
npnp export-pcblib C2040 --output out\pcblib --force
```

Broad keyword workflow:

```powershell
npnp search TYPE-C --limit 20
npnp export-schlib TYPE-C --index 3 --output out\schlib --force
npnp export-pcblib TYPE-C --index 3 --output out\pcblib --force
```

Source inspection workflow:

```powershell
npnp export-source C2040 --output inspect\easyeda --force
npnp bundle C2040 --output inspect\bundle --force
```

Batch verification workflow:

```powershell
npnp batch --input ids.txt --output generated\check --full --force --continue-on-error
```

Merged library verification workflow:

```powershell
npnp batch --input ids.txt --output generated\merged_check --merge --library-name MyLib --full --force --continue-on-error
```

Merged append workflow:

```powershell
npnp batch --input more_ids.txt --output generated\merged_check --merge --append --library-name MyLib --full --continue-on-error
```

## Merge Output Screenshots


The `imgs/` directory stores screenshots generated from merged-library output produced by `npnp`.

These examples come from a merged export workflow such as:

```powershell
npnp batch --input ids.txt --output generated\merged_check --merge --library-name MyLib --full --force --continue-on-error
```

Overview:

![Merged output overview](imgs/overview.png)

Schematic library screenshots:

<p align="center">
  <img src="imgs/sch_01.png" alt="Merged schematic screenshot 1" width="32%">
  <img src="imgs/sch_02.png" alt="Merged schematic screenshot 2" width="32%">
  <img src="imgs/sch_03.png" alt="Merged schematic screenshot 3" width="32%">
</p>

PCB library screenshots:

<p align="center">
  <img src="imgs/pcb_01.png" alt="Merged PCB screenshot 1" width="32%">
  <img src="imgs/pcb_02.png" alt="Merged PCB screenshot 2" width="32%">
  <img src="imgs/pcb_03.png" alt="Merged PCB screenshot 3" width="32%">
</p>

## License


`npnp` now uses the closest standard license to the current project intent: `PolyForm-Noncommercial-1.0.0` in `LICENSE.md`.

- Non-commercial use, research, evaluation, and personal experimentation are allowed.
- Commercial use, paid redistribution, paid service use, or use inside a commercial workflow requires separate permission from the author.
- If you redistribute the project, keep the license text and required notices.
- The PolyForm license does not legally require pull requests. This project still asks anyone publishing modified versions to mention the original `npnp` project and, when possible, send changes back as a pull request.
- This is source-available and non-commercial, not an OSI open-source license.


## Notes On Generated Files


- Output filenames are sanitized for Windows-unsafe characters.
- Existing files are preserved unless `--force` is passed.
- STEP embedding depends on upstream LCEDA/EasyEDA model availability and payload quality.
- If a footprint opens without a 3D body, the upstream STEP model may be missing, invalid, or not linked from the selected component.
- The generated libraries should be opened in Altium Designer for final visual verification before production use.

## Troubleshooting


Batch terminal progress:

- `batch` shows a live progress line with `ok`, `skip`, `fail`, `active`, elapsed time, and the last processed component.
- `SKIP ...` and `FAILED ...` lines are printed as separate events during the run.
- Merged and append runs print extra stage lines when they load existing libraries or write the final merged outputs.


No valid IDs found in batch input:

```powershell
npnp batch --input ids.txt --output batch_out --full
```

Check that `ids.txt` contains values like:

```text
C2040
C12074
C569043
```

Wrong component exported from a broad keyword:

```powershell
npnp search <KEYWORD> --limit 20
```

Then pass the desired result row:

```powershell
npnp export-schlib <KEYWORD> --index <ROW> --output schlib --force
```

Existing output was not overwritten:

```powershell
npnp export-pcblib C2040 --output pcblib --force
```

Resume or rerun a non-merged batch export:

```powershell
npnp batch --input ids.txt --output batch_out --full --continue-on-error
```

Force a full non-merged batch rebuild:

```powershell
npnp batch --input ids.txt --output batch_out --full --force --continue-on-error
```

Network/API issues:

- Confirm that the machine can reach LCEDA/EasyEDA APIs.
- Retry later if LCEDA/EasyEDA is temporarily unavailable.
- `npnp` automatically retries transient request failures such as timeouts, connection failures, rate limiting, and server-side `5xx` responses.