LDraw.org Discussion Forums

Full Version: How to save comprehensive parts list for multiple models?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to take multiple models in one file (6 of this, 3 of that, etc) and save a big old master parts list that doesn't break it down by model, so that I can buy them all at once. This is a bunch of miniature game pieces that someone designed, and I want to buy enough to play a game with. The problem is that when I save a parts list, it's just one of every model and none of the parts are consolidated (lots of similar parts). Also, I would have to go in and manually edit the parts list by multiplying pieces by how many I need, ad nauseam. I was doing this, until 3/4 of the way through I realized I'd marked a color improperly, and had to generate all new parts lists. Can anyone help me out?

For simplicity's sake, let's say I have 50 different models.
I need 6 of some, 3 of some, 4 of some, and 5 of some others, while only 1 of a few of them. I want a master parts list, all consolidated, that I can use for ordering parts.
When I was creating peeron.org part lists some years ago,
I used to simply create mpd file of the model.

I think mpd would also be the file format of your choice here.

The only thing missing is probably a tool which takes an mpd file as input and converts it to a csv
(which I suggest because it is so highly portable) parts list...


I don't know of such a tool yet.
I can help you but the instructions depend on what LDraw editor you are using. If you give me that info, I'll whip up a tutorial.
I'm using MLcad, and my file is already an mpd. I'd love a tutorial!
I've been missing such a tool for long already.

I don't want to use some other "bigger" tool like an editor (Mlcad) or viewer (LDView) to do that conversion.

Having such a tool available would offer the possibility at peeron.com to allow the upload of *.mpd files,
instead of having to convert to some peeron-proprietary set inventory format.
But what about the extra parts that come in the box but aren't part of the model?

Would the MPD not be an actual model of the set but just a collection of the correct type/color/count of the parts that come in the box, not organized into a proper model?

How do you want parts of the same type but different color represented?

"part number", color_code, number_of_parts
"same part number", different_color_code, number_of_parts_of_the_other_color
"different part number", color_code, number_of_parts
be what you're looking for?

For example, for this MPD:
0 FILE some-model
1 1 10 -32 10 1 0 0 0 1 0 -0 0 1 3024.dat
1 1 0 0 0 1 0 0 0 1 0 -0 0 1 some-submodel
0 FILE some-submodel
1 4 0 0 0 1 0 0 0 1 0 -0 0 1 3001.dat
1 2 -10 -24 0 1 0 0 0 1 0 -0 0 1 3002.dat

Would you be looking for something like this?
"3001", 4, 5
"3001", 1, 2
"3024", 2, 1

Would you prefer the output in JSON because it could represent a hierarchy of the submodels within the parts as well?

If I remember correctly, LDView's code for generating the HTML parts list didn't rely too heavily on previous processing of the model, so I think most of the work is pretty much done already. (At least for CSV or any other flat format.)
couldn't it just be like the regular parts list says?

number - color - part no. - part name
or something like that?
All I wanted was a list that combined all sub-model's parts into one, without breaks or sections for each model.
If the end goal is to buy the parts, are you aware of Brickforge

I believe it does what you want, and it can even generate XML that can be bulk-uploaded directly to bricklink to make it easier to buy exactly the parts you need.

I'm not proposing this as the Peeron solution, but rather a solution for Derek.
> But what about the extra parts that come in the box but aren't part of the model?

IMHO, that can be decided by the mpd author:
if that should be wanted, he can create a mpd consisting of 2 portions: the model and the spare parts.

> couldn't it just be like the regular parts list says?
> number - color - part no. - part name

IMHO, that would create a new proprietary file format.
Maybe a converter tool can offer various output formats:
(a) csv
(b) json
© txt

You probably want ©.

after some more consideration and reading the other replies in this thread, I figured 2 more things:
one is: maybe XML is missing in that list. But which scheme to use?
When thinking some more, both JSON and XML will be a re-implementation of everything that MPD already
is, just in another proprietary syntax. Just using simple CSV will be so universal that you can edit it with
existing calculation programs like LibrOffice or Excel, and sites like peeron could be using that format.
Would we invent a new json hierarchy, or support various XML schemes x, y, z, etc.,
we would re-invent the wheel of MPD actually.
How would you CSV it? Specifically what data would you CSV and in what order?
well, I was thinking of something very, very, very simple.
actually, the mpd file already carries all needed information,
just in a non-accumulated way.
so probably json is a little overkill, since it re-invents what mpd already is.

the csv, accumulating the part counts, however, could be used in creating statistics, inventories, etc.

for this purpose, a simple accumulation by counting parts would be sufficient IMHO:
a simple sequence of lines, each line consisting of
, the last element being optional. So, a model consisting of
1x part 4083 in black,
28x part 3005 in yellow,
28x part 3005 in red
would have this csv representation:


actually, it is not really "comma-separated", but instead "semicolon-separated",
but that variant in many programs is understood. maybe the tool can have an option for choosing the separation char.
we could also use


, or we could use the filename instead of the part number:


please consider all this just as an inspiration.
Having such a tool would prevent set inventories sites
from having to invent an own, proprietary format again and again.
can BrickForge import *.mpd / *.ldr / *.dat files?
[Image: Dpb51.png]

Wouldn't have brought it up if it didn't. Tongue
Interesting but it crashes when I try to open files. I'm going to try and build from the source and see if the problem persists.
OK, you can't build it from source since QSA hasn't been available since 2008 Sad
This was actually going to be one of the first chores for my parser when i get there!
My first iteration took a root ldr and read down through all of the placements.
It doesn't support mpds - I'm actually working out how to do that now.

I have a prototype, no guarantees are given, it uses dialogs (prompts on the title bar), and prints messages to a console.
If you'd like to try it you can download from http://home.comcast.net/~greg.teft/
If you don't need to see the additional messages, just double click on the jar - you need a current java 6 runtime or later.
To run in console/command prompt, just run "java -jar QuickPartLister.jar".

attached is output for my Eiffel Tower (I have not checked it for accuracy yet).
Jean-Philippe, Brickforge for some reason doesn't like some of my files. They don't import properly. Also, can I buy legos through brickforge, or will it just make me an awesome list?
Specifically which parts?
Can you post the model?

As for buying parts...

According to the page I linked to it can.

I believe the process would be to import the model, and Export > "BrickLink Wanted List XML to Clipboard"

I just tried it now to be sure and it seems to work, but I would need to remember my bricklink password to actually test it.

I remember doing it a long time ago for this little desk placard thing. It worked flawlessly except that I couldn't find a 3482 in black (not sure they even exist). Sorry I can't give you an exact procedure, but I assure you that it's possible.

Side-note: I just realized I referred to the software as BrickForge. This is not its name. To avoid any possible confusion, the software is called BrickStore, it originates on the website brickforge.de. My mistake.
When I imported this, it only imported the first .ldr file, and not all the pieces. This .mpd contains one of each .ldr that I plan to construct (although the actual list will include multiples of certain models). Maybe you have more success? Is there another parts inventory that BrickStore uses that I can import?

That is expected behavior. Only the first model is supposed to be loaded, the other models should only be loaded if they are referenced from the first model. See the OMR spec for a more detailed explanation.

I believe the proper thing to do would be to insert one submodel at the top which just contains references to each other model in the MPD you wish to include. However, some of your submodels have the same file name which will definitely cause trouble. I started to rename them, but then realized that if your MPD is fairly conventional (no wacky meta commands) and assuming you want exactly one of each model in the MPD, then removing every line that is not a part should yield a proper parts list. I did not throughly inspect your MPD (it was quite long, props for the hard work) and compare it to the parts list, but I see no immediately evident reason why it would be incorrect.

Even though I believe the attached model generates an accurate parts list, I would suggest getting a 2nd opinion from someone more experienced than I before purchasing the parts.

Regardless of the above, there are still 23 parts unrecognized by BrickStore (at least on my system) which will need to be manually "Fixed" to get the correct item type for BrickLink.

Hope this helps.
actually, this does help. I can't seem to reconcile the missing parts, the brickstore inventory goes from Slope 30 to Slope33, and Slope 31 is rather important to me.

How did you make those submodels work like that? When I import submodeels, they're one uneditable model without a parts list. I could just import them all with no steps and have MLCAD generate me a part list and buy them manually.

As far as the size, it's a combination of Dan Efran's OGRE Lego models, I have to give him credit: http://www.efran.org/embassy/lego-gev.html
I just recolored them and added ones from another one of his .ldr files (on a linked page)
Derek Wrote:How did you make those submodels work like that? When I import submodeels, they're one uneditable model without a parts list. I could just import them all with no steps and have MLCAD generate me a part list and buy them manually.

Work like what? I'm afraid I don't actually know what you mean here. All I did was essentially combine all your submodels into one model (which would be a very terrible thing to do for anything other than a parts list).
Yes! I realize that, but for the sake of a parts list, how do I combine submodels into one model? When I do it, the submodels are one unit, not a series of pieces.
If I understand your question ("how do I transform the file I (Derek) posted into the file you (Jean-Philippe) posted?") then it is a simple matter of opening the file in a text editor and removing every line that does not begin with the number 1.

I actually did it using the following command:
grep ^1 derek.mpd > derek-new.ldr
where derek.mpd is a file in your working directory, and derek-new.mpd is the resulting file will all submodels combined.

Note that this ONLY works for models where each submodel is included exactly once. It is also bad because it removes the headers (file name, author name, etc.). This is by no means a proper approach, but it works in this specific case.
oh, so I can't combine multiple submodels this way. I guess I'll get cracking on drudging through the text documents and manually editing them.
If I made a copy of the file, then I copied each submodel as many times as I needed it, but did so by highlighting pieces and copying and pasting them inside the submodel (example, LGEV's submodel now contains 8 copies of all the requisite parts, the HVY model contains 6, etc), and did this for all of the submodels I've got, would that work?
Yes it would.

Also, you don't need to paste the parts in the same model, you could just create a duplicate model if you wish... as long as each part appears the correct number of times in the file, it doesn't matter which submodel it is in, because submodels are all joined anyway, but please understand that this is not a proper solution at all. It just works in this case. You shouldn't rely on it to work for all models.
I understand that this is neither proper or ideal, but at least I can get it to him some time around christmas.
Good luck, I hope it works out.

If you have any other questions, don't hesitate to ask.
For future reference...

Bricksmith can generate a parts list:
[Image: zNUtv.png]
[Image: e5TbJ.png]
and clicking "Export Parts List..." yields a file containing:
Quantity    Part    Description    Color
1    3001.dat    Brick  2 x  4    Blue
1    3002.dat    Brick  2 x  3    Green
1    3003.dat    Brick  2 x  2    Red

LDView can also generate parts lists:
[Image: 1bpic.png]
[Image: RgQei.png]
generates an HTML file which looks like
[Image: 1aBvy.png]
I'm pretty sure LDView can write the parts list in other formats too, but right now I can't seem to find how. Nope. Read the next post.

and many other tools can do so as well. I'm pretty sure LPub can generate a graphical bill of materials... and if I recall correctly MLCad can also generate a parts list... Point being, there are many tools that you can use, it's just convenient to use BrickStore because it can export XML that you can paste directly into Bricklink to automatically fill your shopping cart with the parts in your model, if that's your end goal.
There have been requests for LDView to generate an XML parts list, but it currently only supports the HTML one. I have considered adding an XML one, but didn't mainly because there were other ways to do that, and I wasn't sure how to best format the XML.
Just a thought.

It's easy enough to convert the outputted html into whatever you want though. (and even easier to convert the output of other programs.)