Author Topic: BLB file ---> Parts list  (Read 1077 times)

I "sorta" mentioned this idea to Ephi today, but he is a busy guy and I realize that I am kinda limiting the potential of this ever occuring if I wasn't going to mention this to the community at large.

"ZOMG you posted in the wrong forum RW!!!" - Yeah, but it's pretty obvious that few with talent actually read that cesspool of converging failures.

Anyway, what I really need/desire is a simple converter that will take the information stored within a BLB file and give a useful reading of what bricks appear in a build.

Here is the kind of output that I hope the hypothetical program would display even if only in a raw text form....

Code: [Select]
2x4  = 132 in blue
        =  26 in red
Code: [Select]
1x1x5  =  52 in yellow
           =  7 in green
           =  12 in blue

Basically it is just a brick counter. Why would I/anyone else want this? So we can order the bricks we need from Lego.com and recreate our favorite builds in real life.

Any takers?

With the virtualbricklist I have, this should be easy :D. I can have it ready pretty quickly.

I'll do this, but it will require you to append a label to each of the colours at the top of the file beforehand, eg:
Quote from: code
0.000000 1.000000 0.000000 1.000000 green
I could try a colour matching system where the colours are compared with common ones, but they're never very accurate.
    
Warning - while you were typing a new reply has been posted. You may wish to review your post.
- I'll still try it anyway
« Last Edit: July 10, 2008, 09:48:23 PM by Randy »


Nvm.

What?

Oh, incase anyone wishes to know, Nitram did not complete this program, so the idea is still up in the air.

*turns to face Nitramtj*

"You have failed me for the last time..." Darth Vader voice

What should happen with print bricks?

Something like this:
Quote
1x2F Print
   12 in grey with "base/data/prints/2x1/vent.png"
   3 in black with "base/data/prints/2x1/vent.png"

Or just not mention the prints, or whatever?

[Edit] Ok I've finished it, let me know if you find any bugs.

To use:
  • Open up your save file, and add name at the end of each colour.
    eg. 0.749020 0.749020 0.749020 1.000000 light grey
  • Type in the console:
    exportBricklist("path/to/file.bls");
    eg. exportBricklist("base/saves/Bedroom/YourSaveName.bls");
  • This will create a file called YourSaveName_bricklist.txt in the same directory as your save file.

Code: [Select]
function exportBricklist(%path){
if(!isFile(%path)){
error("Invalid file path.");
return;
}
%file = new FileObject();
%file.openForRead(%path);
%numDiffBricks = 0;
while(!%file.isEOF()){
%linenum++;
%line = %file.readLine();
if(%linenum > 3 && %linenum < 68){
%colourlist[%linenum-4] = getWords(%line, 4, getWordCount(%line)-1);
continue;
}
if(%linenum <= 68 || getSubStr(%line, 0, 2) $= "+-" || %line $= "")
continue;
%divide = strpos(%line, "\"");
%name = getSubStr(%line, 0, %divide);
%rest = getSubStr(%line, %divide+2, strlen(%line)-%divide-2);
%thisColour = getWord(%rest, 5);
%exists = -1;
for(%i=0;%i<%numDiffBricks;%i++){
if(%brickName[%i] $= %name){
%exists = %i;
break;
}
}
if(%exists >= 0){
%colExists = -1;
for(%i=0;%i<%numDiffColours[%exists];%i++){
if(%brickColour[%exists, %i] == %thisColour){
%colExists = %i;
break;
}
}
if(%colExists >= 0){
%numBricks[%exists, %colExists]++;
} else {
%brickColour[%exists, %numDiffColours[%exists]] = %thisColour;
%numBricks[%exists, %numDiffColours[%exists]]++;
%numDiffColours[%exists]++;
}
continue;
}
%brickName[%numDiffBricks] = %name;
%numDiffColours[%numDiffBricks] = 1;
%brickColour[%numDiffBricks, 0] = %thisColour;
%numBricks[%numDiffBricks, 0] = 1;
%numDiffBricks++;
}
%file.close();
%name = fileName(%path);
%filename = getSubStr(%name, 0, strpos(%name, ".")) @ "_bricklist.txt";
echo(filePath(%path) @ "/" @ %filename);
%file.openForWrite(filePath(%path) @ "/" @ %filename);
for(%a=0;%a<%numDiffBricks;%a++){
%file.writeLine(%brickName[%a]);
for(%b=0;%b<%numDiffColours[%a];%b++){
echo(%colourlist[%brickColour[%a, %b]] SPC %brickColour[%a, %b]);
%file.writeLine("\t" @ %numBricks[%a, %b] SPC %colourlist[%brickColour[%a, %b]]);
}
}
%file.close();
%file.delete();
}
« Last Edit: July 14, 2008, 07:32:09 PM by Randy »

Looks good Randy! Unfortunately I got sidetracked on something else but the resulting script was worth it :) Should this be released as an add-on after fixing some bugs and maybe adding some more features?

Thanks, I'll either look into some efficient colour matching methods, or set up a GUI prompting the user to name each colour (which would be annoying).

Ah, I've just found a list of all the valid colours that lego bricks can be, so that means I'll probably try colour matching.
http://peeron.com/cgi-bin/invcgis/colorguide.cgi

I realize beggars can't be choosers, but your method is a bit...complicated? Randy.

It turns out is probably just better if I build it in LDD, since not all the bricks are available in the store, that are in Blockland.

I think it would be more appealing if it were simpler to use.