Giter Site home page Giter Site logo

benckx / lego-compare-inventory-vs-wanted Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 108 KB

Compare Bricklinks XML parts list in order to filter out the ones you already own

Home Page: https://www.bricklink.com/

Kotlin 100.00%
lego xml-parser bricklink rebrickable script

lego-compare-inventory-vs-wanted's Introduction

About

When viewing Lego models on BrickLink, it is possible to add all the necessary parts to a "Wanted List" (and then use this list to purchase the parts). However, it doesn't seem possible to automatically filter out the parts you already own (from the sets you already own) from those "Wanted List".

So I wrote a script that updates the "Wanted List" XML file by taking into account the parts you already own (based on the inventory generated from Rebrickable). You can then upload the updated XML on BrickLink to create a new "Wanted List" and purchase the parts from this list instead.

Maybe there's already a more simple solution directly on BrickLink, but I could not find it (if you know the solution, feel free to open an issue). There are options on BrickLink to add and part out sets, but it doesn't seem to be taken into account while making a "Wanted List". But maybe I'm missing something obvious.

In any case I'll be able to do more custom things with my parts lists this way.

How To

on Rebrickable

First add all the sets you own: go to "My LEGO" -> "My Sets Lists". Create a list and add your sets. This will allow Rebrickable to create an inventory of all the parts you own. You can also add individual parts.

You can then export your inventory from Rebrickable in the BrickLink format (go to "My LEGO" -> "All my parts" -> " Export Parts" -> "BrickLink XML") and replace data/inventory.xml by the export result.

on BrickLink

Go to your "Wanted List" and click "Download". Move the file under the data folder.

In Code

Replace the "Wanted List" XML file accordingly:

fun main() {
    val filterer = InventoryFilterer("data/razor-crest-75331.xml")
    filterer.execute()
}

The script will output 2 files:

  • data/razor-crest-75331-updated.xml where the parts you own have been subtracted
  • data/razor-crest-75331-output-report.csv CSV report in the following format, so you can double-check the modifications:
modification type part id color code color qty needed qty inventory qty missing
sufficient 18649 86 Light Bluish Gray 4 4 0
sufficient 22484 85 Dark Bluish Gray 1 2 0
... ... ... ... ... ... ...
insufficient 10247 11 Black 6 2 4

Ideas for future iterations

  • Implement some kind of rules engine that allow for color substitution (e.g. "use dark grey if I don't have the part in black") or part substitution (e.g. "use two 2x2 brick if I don't have one 2x4 brick") (something like that already exists in the Studio app of BrickLink)
  • Maybe a UI and an executable, so it's user-friendly for everyone

lego-compare-inventory-vs-wanted's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.