[LDCad] open Stud.io-file with correct colors


[LDCad] open Stud.io-file with correct colors
#1
I got a stud.io file with all inlined parts, size is about 7 MB. Opening this file in Stud.io is nearly impossible as I'm waiting now for about 45 minutes and still having "parsing a file 0%", while LDCad opens it in a few seconds. Smile  Unfortunately, all colors are Stud.io/Bricklink-colors, so they are "MISSING" in LDCad.

Is there an easy way in LDCad to activate an import-filter replacing all Stud.io/Bricklink-colors by LDraw-colors on load or is there a small script to replace colors after loading? If so: does such a script exist already? As far as I understand, especially the -1 and -2 colors need special attention as they map to 16/24 in the LDraw universe.

Thanks for any hint, I'm willing to implement the converting script if this is the way to go and not done yet.
Reply
RE: [LDCad] open Stud.io-file with correct colors
#2
What are these Stud.io/Bricklink link colors, that are different from LDraw ones? I always thought Studio used the same LDconfig for its colors as everyone else… Huh
Reply
RE: [LDCad] open Stud.io-file with correct colors
#3
The color definition of Stud.io seems to be the same (or at least: mostly the same) as Bricklink. The Stud.io color definition file (in the data directory after installation) has a mapping table, ie. it shows both Stud.io/Bricklink and LDraw color ids and names.
Reply
RE: [LDCad] open Stud.io-file with correct colors
#4
(2022-03-25, 11:13)Stefan Frenz Wrote: I got a stud.io file with all inlined parts, size is about 7 MB. Opening this file in Stud.io is nearly impossible as I'm waiting now for about 45 minutes and still having "parsing a file 0%", while LDCad opens it in a few seconds. Smile  Unfortunately, all colors are Stud.io/Bricklink-colors, so they are "MISSING" in LDCad.

Is there an easy way in LDCad to activate an import-filter replacing all Stud.io/Bricklink-colors by LDraw-colors on load or is there a small script to replace colors after loading? If so: does such a script exist already? As far as I understand, especially the -1 and -2 colors need special attention as they map to 16/24 in the LDraw universe.

Thanks for any hint, I'm willing to implement the converting script if this is the way to go and not done yet.

Does it include all parts even official ones?

If so you might have thought it won't be necessary to install the ldraw library at all.

But the library also includes the default color definitions trough LDConfig.ldr

You can fix this by installing the complete.zip library or just LDConfig.ldr and configure it manaully in the "prefs/ldraw/configuration files" menu.
Reply
RE: [LDCad] open Stud.io-file with correct colors
#5
Thanks for the hint, but I'm not sure if I understand your suggestion correctly.
What I have:
  • Fully working LDCad 1.6d and 1.7-alpha with installed LDraw. Everything is fine.
  • Very-Large Stud.io-file having all colors in BrickLink-Style (-1 instead of 16, -2 instead of 24, etc.)

So the suggestion is to replace the LDraw color configuration by the one contained in Stud.io? Uh, this I really wanted to circumvent as I would like to have the Stud.io-file in "normal" (i.e. LDraw/LDConfig style).
Reply
RE: [LDCad] open Stud.io-file with correct colors
#6
Hi Stefan,

The file yo try to open seems to be directly extracted from Studio file. But this one does contain two files, one is a regular LDraw file with normal LDraw colors (model.ldr), the other contains embedded parts and use BL colors (model2.ldr). Why not use the first one?
Otherwise it should be possible to write a LDCad script to convert BL colors to Ldraw ones...
Reply
RE: [LDCad] open Stud.io-file with correct colors
#7
Hi Philippe,

thanks, but unfortunately there is no model.ldr or model2.ldr in my file. Maybe I got the model2.ldr-extract from the stud.io file.

So I will write a LDCad perl script to convert the colors. Smile
Reply
RE: [LDCad] open Stud.io-file with correct colors
#8
...ended up to write a perl script:
Code:
#!/usr/bin/perl

use strict;
use warnings;

my $num_args = $#ARGV + 1;
if ($num_args != 1) {
    print "Usage: convertColors.pl inputfile\n";
    exit;
}

my $file = $ARGV[0];
open my $fd, $file or die "Could not open $file: $!";

my %replacement = (
    11 => 0,
    7 => 1,
    6 => 2,
    39 => 3,
    5 => 4,
    47 => 5,
    8 => 6,
    9 => 7,
    10 => 8,
    62 => 9,
    36 => 10,
    40 => 11,
    25 => 12,
    23 => 13,
    3 => 14,
    1 => 15,
    -1 => 16,
    38 => 17,
    33 => 18,
    2 => 19,
    44 => 20,
    46 => 21,
    24 => 22,
    109 => 23,
    -2 => 24,
    4 => 25,
    71 => 26,
    34 => 27,
    69 => 28,
    104 => 29,
    157 => 30,
    154 => 31,
    14 => 33,
    20 => 34,
    108 => 35,
    17 => 36,
    50 => 37,
    18 => 38,
    13 => 40,
    74 => 41,
    16 => 42,
    15 => 43,
    107 => 45,
    19 => 46,
    12 => 47,
    51 => 52,
    121 => 54,
    98 => 57,
    57 => 60,
    52 => 61,
    64 => 62,
    82 => 63,
    122 => 64,
    96 => 68,
    88 => 70,
    86 => 71,
    85 => 72,
    42 => 73,
    37 => 74,
    56 => 77,
    90 => 78,
    60 => 79,
    67 => 80,
    70 => 81,
    65 => 82,
    150 => 84,
    91 => 86,
    97 => 89,
    28 => 92,
    26 => 100,
    43 => 110,
    73 => 112,
    100 => 114,
    76 => 115,
    101 => 117,
    41 => 118,
    35 => 120,
    32 => 125,
    84 => 134,
    66 => 135,
    78 => 137,
    61 => 142,
    77 => 148,
    119 => 150,
    99 => 151,
    81 => 178,
    95 => 179,
    83 => 183,
    110 => 191,
    105 => 212,
    27 => 216,
    103 => 226,
    87 => 232,
    63 => 272,
    221 => 285,
    80 => 288,
    118 => 294,
    115 => 297,
    162 => 302,
    120 => 308,
    72 => 313,
    59 => 320,
    153 => 321,
    156 => 322,
    152 => 323,
    158 => 326,
    159 => 329,
    155 => 330,
    21 => 334,
    58 => 335,
    163 => 339,
    94 => 351,
    220 => 353,
    29 => 366,
    54 => 373,
    48 => 378,
    55 => 379,
    22 => 383,
    106 => 450,
    31 => 462,
    68 => 484,
    49 => 503,
    160 => 509
);

my $hadError = 0;

while( my $line = <$fd>)  {
    if ( $line =~ m/^([12345])\s+([-0-9a-fx]+)\s+(.*)/ ) {
        my $dest = $replacement{$2};
        if ( !defined $dest ) {
            print "### ATTENTION: color $2 is not mapped\n";
            $dest = $2;
            $hadError = $hadError + 1;
        }
        print "$1 $dest $3\n";
    }
    else {
        print $line;
    }
}

if ( $hadError > 0) {
    print "\nconversion had $hadError errors\n";
}

close $fd;
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 5 Guest(s)