Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

LDR Importer searches wrong pathes for referenced files #40

Closed
MinnieTheMoocher opened this issue Dec 27, 2013 · 31 comments
Closed

LDR Importer searches wrong pathes for referenced files #40

MinnieTheMoocher opened this issue Dec 27, 2013 · 31 comments

Comments

@MinnieTheMoocher
Copy link

When creating a .ldr file, it sometimes references other *.ldr files
lying next to it in the same folder.

This is seemingly not supported in LDR Importer 1.1:
It fails importing my 6372.dat file which references 6372-Minifig-2.ldr
which is lying next to it.

This should not happen. LDR Importer needs to check folders for files
in the following order:
(1) first see if the referenced file is lying next to the current one
(2) if not found there, check the ldraw\models folder
(3) if not found there, check the ldraw\parts folder
(4) if not found there, check the ldraw\p folder

Step (1) is seemingly missing from the LDR Importer implementation.
I guess that Step (2) also is missing.

As a workaround I currently inline all referenced files into my .ldr file,
but that's something I do not really want to be forced to.

@MinnieTheMoocher
Copy link
Author

sorry, but even when inlining these 2 files I cannot load my model successfully.

I have attached the files for you to this issue.

I tried to load file "6372.ldr".

It references files "6372-Minifig-1.ldr" and "6372-Minifig-2.ldr", which both reference "6372-Chair.ldr".

Note that the file references some unofficial parts, so you need to download the latest bunch
of LDRAW's unofficial parts first.

Please see in the attached screenshot how distorted my import result is :(

@MinnieTheMoocher
Copy link
Author

6372

@MinnieTheMoocher
Copy link
Author

Unfortunately I cannot attach files to this issue.
So I am giving you the files here in plain sourcecode:

=== FILE: 6372.ldr ===================================================================

0 Set 6372
0 Name: 6372.ldr
0 Unofficial Model
0 ROTATION CENTER 0 0 0 1 "Custom" 
0 ROTATION CONFIG -3 1
1 2 0 -4 0 -1 0 0 0 1 0 0 0 -1 3857.dat
1 0 -280 -12 -140 -1 0 0 0 1 0 0 0 -1 3022.dat
1 0 80 -28 10 -1 0 0 0 1 0 0 0 -1 3004.dat
1 0 -120 -28 10 1 0 0 0 1 0 0 0 1 3004.dat
1 0 -130 -28 40 0 0 -1 0 1 0 1 0 0 3004.dat
1 0 90 -28 60 0 0 -1 0 1 0 1 0 0 3010.dat
1 0 -150 -28 70 -1 0 0 0 1 0 0 0 -1 3622.dat
1 0 -290 -28 70 -1 0 0 0 1 0 0 0 -1 3622.dat
1 1 310 -28 120 0 0 -1 0 1 0 1 0 0 3010.dat
1 0 90 -28 120 0 0 -1 0 1 0 1 0 0 3004.dat
1 15 -280 -28 120 0 0 1 0 1 0 -1 0 0 3001.DAT
1 0 -310 -28 120 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 260 -28 150 -1 0 0 0 1 0 0 0 -1 3010.dat
1 1 180 -28 150 -1 0 0 0 1 0 0 0 -1 3010.dat
1 1 110 -28 150 1 0 0 0 1 0 0 0 1 3622.dat
1 1 -130 -28 150 -1 0 0 0 1 0 0 0 -1 3005.dat
1 15 -290 -2.543 -30 -0.965926 0 -0.258819 0 1 0 0.258819 0 -0.965926 3741c01.dat
1 14 230 -4 -130 0.965926 0 0.258819 0 1 0 -0.258819 0 0.965926 3741c01.dat
1 14 90 -4 -130 0.866025 0 -0.5 0 1 0 0.5 0 0.866025 3741c01.dat
1 4 169.976 -4 -129.202 -0.173648 0 -0.984808 0 1 0 0.984808 0 -0.173648 3741c01.dat
1 15 -30 -4 -130 0.965926 0 -0.258819 0 1 0 0.258819 0 0.965926 3741c01.dat
1 4 -90 -4 -130 -0.965926 0 -0.258819 0 1 0 0.258819 0 -0.965926 3741c01.dat
1 14 -150 -4 -130 0.965926 0 0.258819 0 1 0 -0.258819 0 0.965926 3741c01.dat
1 4 100 -36 100 -1 0 0 0 1 0 0 0 -1 3031.dat
1 14 -280 -60 -140 1 0 0 0 1 0 0 0 1 4345ap03.dat
1 14 110 -44 100 0 0 1 0 1 0 -1 0 0 3069b.dat
1 1 70 -52 10 -1 0 0 0 1 0 0 0 -1 3005.dat
1 1 -110 -52 10 -1 0 0 0 1 0 0 0 -1 3005.dat
1 1 -130 -52 40 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 -160 -52 70 -1 0 0 0 1 0 0 0 -1 3004.dat
1 1 -280 -52 70 -1 0 0 0 1 0 0 0 -1 3004.dat
1 1 -310 -52 90 0 0 1 0 1 0 -1 0 0 3622.dat
1 1 310 -52 110 0 0 -1 0 1 0 1 0 0 3622.dat
1 15 -280 -52 120 0 0 1 0 1 0 -1 0 0 3001.DAT
1 1 -310 -52 140 0 0 -1 0 1 0 1 0 0 3004.dat
1 1 290 -52 150 1 0 0 0 1 0 0 0 1 3622.dat
1 1 220 -52 150 -1 0 0 0 1 0 0 0 -1 3010.dat
1 1 140 -52 150 -1 0 0 0 1 0 0 0 -1 3010.dat
1 1 -130 -52 150 -1 0 0 0 1 0 0 0 -1 3005.dat
1 14 -280 -66.605 -165.349 1 0 0 0 0.866025 -0.5 0 0.5 0.866025 4346p03.dat
1 15 -280 -60 100 0 0 -1 0 1 0 1 0 0 3068bp07.dat
1 15 -280 -60 140 0 0 -1 0 1 0 1 0 0 3068bd01.dat
1 1 80 -76 10 1 0 0 0 1 0 0 0 1 3004.dat
1 14 20 -124 10 1 0 0 0 1 0 0 0 1 2493b.dat
1 47 20 -124 10 1 0 0 0 1 0 0 0 1 2494.dat
1 14 -60 -124 10 1 0 0 0 1 0 0 0 1 2493b.dat
1 47 -60 -124 10 1 0 0 0 1 0 0 0 1 2494.dat
1 1 -120 -76 10 -1 0 0 0 1 0 0 0 -1 3004.dat
1 1 -130 -76 40 0 0 -1 0 1 0 1 0 0 3004.dat
1 14 -190 -124 70 -0.5 0 -0.866025 0 1 0 0.866025 0 -0.5 3861.dat
1 1 -150 -76 70 -1 0 0 0 1 0 0 0 -1 3622.dat
1 1 -290 -76 70 -1 0 0 0 1 0 0 0 -1 3622.dat
1 0 90 -68 100 0 0 1 0 1 0 -1 0 0 3023.dat
1 4 70 -76 100 0 0 1 0 1 0 -1 0 0 3710.dat
1 4 90 -68 70 -1 0 0 0 1 0 0 0 -1 3623.dat
1 1 310 -76 120 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 -310 -76 120 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 270 -76 150 1 0 0 0 1 0 0 0 1 3622.dat
1 1 200 -76 150 -1 0 0 0 1 0 0 0 -1 3010.dat
1 1 120 -76 150 -1 0 0 0 1 0 0 0 -1 3010.dat
1 1 -130 -76 150 -1 0 0 0 1 0 0 0 -1 3005.dat
1 15 -280 -72 -142.929 -0.707107 0 -0.707107 0 1 0 0.707107 0 -0.707107 3069bp01.dat
1 15 -280 -80 -135 0 0 1 0 1 0 -1 0 0 3069bp01.dat
1 1 -290 -84 70 -1 0 0 0 1 0 0 0 -1 3024.dat
1 4 110 -100 90 1 0 0 0 1 0 0 0 1 3045.dat
1 4 110 -100 110 0 0 -1 0 1 0 1 0 0 3045.dat
1 1 70 -100 10 -1 0 0 0 1 0 0 0 -1 3005.dat
1 1 -110 -100 10 -1 0 0 0 1 0 0 0 -1 3005.dat
1 1 90 -100 40 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 -130 -100 40 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 -160 -100 70 -1 0 0 0 1 0 0 0 -1 3004.dat
1 1 -270 -100 70 -1 0 0 0 1 0 0 0 -1 3005.dat
1 0 -290 -92 70 0 0 -1 0 1 0 1 0 0 3623.dat
1 1 -310 -100 90 0 0 -1 0 1 0 1 0 0 3622.dat
1 1 90 -100 120 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 -310 -100 140 0 0 -1 0 1 0 1 0 0 3004.dat
1 1 -130 -100 150 -1 0 0 0 1 0 0 0 -1 3005.dat
1 1 -290 -100 70 -1 0 0 0 1 0 0 0 -1 3024.dat
1 47 -290 -114.543 90 0.258819 0 0.965926 0 1 0 -0.965926 0 0.258819 3899.dat
1 46 -290 -116 50 -1 0 0 0 1 0 0 0 -1 3062B.DAT
1 4 110 -124 100 0 0 -1 0 1 0 1 0 0 3004.dat
1 1 80 -124 10 -1 0 0 0 1 0 0 0 -1 3004.dat
1 1 -120 -124 10 -1 0 0 0 1 0 0 0 -1 3004.dat
1 1 -130 -124 40 0 0 -1 0 1 0 1 0 0 3004.dat
1 1 90 -124 60 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 -150 -124 70 -1 0 0 0 1 0 0 0 -1 3622.dat
1 1 -290 -124 70 -1 0 0 0 1 0 0 0 -1 3622.dat
1 1 -310 -124 120 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 90 -124 130 0 0 -1 0 1 0 1 0 0 3622.dat
1 1 -130 -124 150 -1 0 0 0 1 0 0 0 -1 3005.dat
1 0 -290 -124 50 -1 0 0 0 1 0 0 0 -1 3024.dat
1 4 110 -148 100 0 0 -1 0 1 0 1 0 0 3004.dat
1 4 40 -148 10 1 0 0 0 1 0 0 0 1 3297.dat
1 4 -40 -148 10 1 0 0 0 1 0 0 0 1 3297.dat
1 15 -20 -148 10 1 0 0 0 1 0 0 0 1 194325ac01.dat
1 4 -100 -148 10 1 0 0 0 1 0 0 0 1 3298.dat
1 1 -130 -148 40 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 -220 -148 70 1 0 0 0 1 0 0 0 1 3008.dat
1 1 90 -148 80 0 0 -1 0 1 0 1 0 0 3008.dat
1 1 -310 -148 100 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 -130 -148 150 0 0 1 0 1 0 -1 0 0 3665.dat
1 1 -310 -148 150 0 0 -1 0 1 0 1 0 0 3665.dat
1 1 40 -156 20 -1 0 0 0 1 0 0 0 -1 3795.DAT
1 1 -80 -156 20 -1 0 0 0 1 0 0 0 -1 3795.DAT
1 4 110 -180 100 0 0 -1 0 1 0 1 0 0 3004.dat
1 1 -20 -156 100 -1 0 0 0 1 0 0 0 -1 3028.dat
1 4 -240 -156 100 -1 0 0 0 1 0 0 0 -1 3033.dat
1 4 80 -180 30 1 0 0 0 1 0 0 0 1 3297.dat
1 1 50 -180 50 -1 0 0 0 1 0 0 0 -1 3005.dat
1 4 0 -180 30 1 0 0 0 1 0 0 0 1 3297.dat
1 4 -80 -180 30 1 0 0 0 1 0 0 0 1 3297.dat
1 1 -90 -180 50 -1 0 0 0 1 0 0 0 -1 3005.dat
1 4 -140 -180 30 1 0 0 0 1 0 0 0 1 3298.dat
1 1 90 -180 100 0 0 -1 0 1 0 1 0 0 3009.DAT
1 1 -130 -180 100 0 0 -1 0 1 0 1 0 0 3009.DAT
1 0 -300 -180 120 -1 0 0 0 1 0 0 0 -1 3062B.DAT
1 4 110 -204 100 0 0 -1 0 1 0 1 0 0 3004.dat
1 4 110 -228 100 0 0 -1 0 1 0 1 0 0 3004.dat
1 1 50 -204 40 0 0 -1 0 1 0 1 0 0 3004.dat
1 1 -90 -204 40 0 0 -1 0 1 0 1 0 0 3004.dat
1 4 90 -204 50 1 0 0 0 1 0 0 0 1 3038.dat
1 4 -130 -204 50 1 0 0 0 1 0 0 0 1 3038.dat
1 1 90 -204 90 0 0 -1 0 1 0 1 0 0 3622.dat
1 1 -130 -204 90 0 0 -1 0 1 0 1 0 0 3622.dat
1 1 90 -204 140 0 0 -1 0 1 0 1 0 0 3004.dat
1 1 -130 -204 140 0 0 -1 0 1 0 1 0 0 3004.dat
1 4 110 -156 100 0 0 -1 0 1 0 1 0 0 3023.dat
1 14 20 -228 30 1 0 0 0 1 0 0 0 1 3081cc01.dat
1 14 -20 -228 30 1 0 0 0 1 0 0 0 1 3081cc01.dat
1 14 -60 -228 30 1 0 0 0 1 0 0 0 1 3081cc01.dat
1 1 50 -228 40 0 0 -1 0 1 0 1 0 0 3004.dat
1 1 -90 -228 40 0 0 -1 0 1 0 1 0 0 3004.dat
1 4 90 -228 70 1 0 0 0 1 0 0 0 1 3038.dat
1 4 -130 -228 70 1 0 0 0 1 0 0 0 1 3038.dat
1 1 90 -228 120 0 0 -1 0 1 0 1 0 0 3010.dat
1 1 -130 -228 120 0 0 -1 0 1 0 1 0 0 3010.dat
1 4 70 -252 70 -1 0 0 0 1 0 0 0 -1 3005.dat
1 4 40 -252 50 1 0 0 0 1 0 0 0 1 3297.dat
1 4 -40 -252 50 1 0 0 0 1 0 0 0 1 3297.dat
1 4 -100 -252 50 1 0 0 0 1 0 0 0 1 3298.dat
1 4 -110 -252 70 -1 0 0 0 1 0 0 0 -1 3005.dat
1 4 100 -276 100 -1 0 0 0 1 0 0 0 -1 3003.dat
1 4 -140 -252 90 1 0 0 0 1 0 0 0 1 3039.DAT
1 1 90 -252 130 0 0 -1 0 1 0 1 0 0 3622.dat
1 1 -130 -252 130 0 0 -1 0 1 0 1 0 0 3622.dat
1 4 100 -300 110 0 0 1 0 1 0 -1 0 0 3002.DAT
1 4 60 -276 90 1 0 0 0 1 0 0 0 1 3298.dat
1 4 0 -276 90 1 0 0 0 1 0 0 0 1 3297.dat
1 4 -80 -276 90 1 0 0 0 1 0 0 0 1 3297.dat
1 4 -140 -276 110 1 0 0 0 1 0 0 0 1 3039.DAT
1 1 90 -276 140 0 0 1 0 1 0 -1 0 0 3660.dat
1 1 -130 -276 140 0 0 -1 0 1 0 1 0 0 3660.dat
1 1 60 -284 150 -1 0 0 0 1 0 0 0 -1 3710.dat
1 1 -20 -284 150 -1 0 0 0 1 0 0 0 -1 3710.dat
1 1 -100 -284 150 -1 0 0 0 1 0 0 0 -1 3710.dat
1 4 100 -252 90 1 0 0 0 1 0 0 0 1 3039.DAT
1 4 110 -252 110 -1 0 0 0 1 0 0 0 -1 3005.dat
1 4 -140 -300 130 1 0 0 0 1 0 0 0 1 3039.DAT
1 4 40 -300 130 1 0 0 0 1 0 0 0 1 3297.dat
1 1 40 -292 150 -1 0 0 0 1 0 0 0 -1 3666.dat
1 4 -40 -300 130 1 0 0 0 1 0 0 0 1 3297.dat
1 1 -80 -292 150 -1 0 0 0 1 0 0 0 -1 3666.dat
1 4 -100 -300 130 1 0 0 0 1 0 0 0 1 3298.dat
1 1 60 -300 150 -1 0 0 0 1 0 0 0 -1 3710.dat
1 1 -20 -300 150 -1 0 0 0 1 0 0 0 -1 3710.dat
1 1 -100 -300 150 -1 0 0 0 1 0 0 0 -1 3710.dat
1 4 80 -324 140 -1 0 0 0 1 0 0 0 -1 3299.dat
1 4 0 -324 140 -1 0 0 0 1 0 0 0 -1 3299.dat
1 4 -80 -324 140 -1 0 0 0 1 0 0 0 -1 3299.dat
1 4 -140 -324 140 -1 0 0 0 1 0 0 0 -1 3300.dat
1 4 100 -324 100 -1 0 0 0 1 0 0 0 -1 3003.dat
1 0 110 -348 90 -1 0 0 0 1 0 0 0 -1 3062B.DAT
1 0 90 -348 90 -1 0 0 0 1 0 0 0 -1 3062B.DAT
1 0 110 -348 110 -1 0 0 0 1 0 0 0 -1 3062B.DAT
1 0 90 -348 110 -1 0 0 0 1 0 0 0 -1 3062B.DAT
1 4 90 -60 130 -1 0 0 0 1 0 0 0 -1 3622.dat
1 4 90 -60 70 -1 0 0 0 1 0 0 0 -1 3622.dat
1 4 90 -68 130 -1 0 0 0 1 0 0 0 -1 3623.dat
1 4 100 -76 100 0 0 -1 0 1 0 1 0 0 3020.dat
1 1 90 -52 30 0 0 -1 0 1 0 1 0 0 3622.dat
1 1 90 -76 40 0 0 -1 0 1 0 1 0 0 3004.dat
1 1 90 -52 150 -1 0 0 0 1 0 0 0 -1 3005.dat
1 7 310 -84 110 -1 0 0 0 1 0 0 0 -1 3957a.dat
1 15 310 -172 110 -1 0 0 0 1 0 0 0 -1 3960p04.dat
1 15 20 -164 50 -1 0 0 0 1 0 0 0 -1 3023.dat
1 15 20 -172 100 0 0 -1 0 1 0 1 0 0 3795.DAT
1 15 20 -164 150 -1 0 0 0 1 0 0 0 -1 3023.dat
1 15 20 -180 60 -1 0 0 0 1 0 0 0 -1 3068b.dat
1 15 -20 -180 100 -1 0 0 0 1 0 0 0 -1 3003.dat
1 47 -20 -204 100 -1 0 0 0 1 0 0 0 -1 3626a.dat
1 0 -20 -212 100 -1 0 0 0 1 0 0 0 -1 3024.dat
1 15 -60 -164 50 -1 0 0 0 1 0 0 0 -1 3023.dat
1 15 -60 -172 100 0 0 -1 0 1 0 1 0 0 3795.DAT
1 15 -60 -164 150 -1 0 0 0 1 0 0 0 -1 3023.dat
1 15 -60 -180 60 -1 0 0 0 1 0 0 0 -1 3068b.dat
1 47 -20 -84 60 -1 0 0 0 1 0 0 0 -1 3626a.dat
1 0 -20 -92 60 -1 0 0 0 1 0 0 0 -1 3024.dat
1 15 -20 -36 60 0 0 -1 0 1 0 1 0 0 3020.dat
1 15 -60 -12 60 0 0 -1 0 1 0 1 0 0 4079.DAT
1 15 20 -12 60 0 0 1 0 1 0 -1 0 0 4079.DAT
1 15 -20 -28 60 -1 0 0 0 1 0 0 0 -1 3003.dat
1 0 -20 -60 60 -1 0 0 0 1 0 0 0 -1 3062B.DAT
1 47 190 -84 9 0.70711 0 -0.70711 0 1 0 0.70711 0 0.70711 3899.dat
1 47 190 -60 9 -1 0 0 0 1 0 0 0 -1 3626a.dat
1 15 200 -36 20 -1 0 0 0 1 0 0 0 -1 3031.dat
1 15 200 -28 19 -1 0 0 0 1 0 0 0 -1 3003.dat
1 15 200 -12 100 -1 0 0 0 1 0 0 0 -1 3680.dat
1 15 280 -12 20 -1 0 0 0 1 0 0 0 -1 3680.dat
1 15 200 -20 100 0.89101 0 -0.45399 0 1 0 0.45399 0 0.89101 6372-Minifig-1.ldr
1 15 280 -20 20 -0.40674 0 0.91354 0 1 0 -0.91354 0 -0.40674 6372-Minifig-2.ldr

=== FILE: 6372-Minifig-1.ldr ======================================================

0 6372-Minifig-1.ldr
0 Name: 6372-Minifig-1.ldr
0 Unofficial Model
0 ROTATION CENTER 0 0 0 1 "Custom" 
0 ROTATION CONFIG 0 0
0 BFC CERTIFY CW
1 0 0 -77 8 1 0 0 0 1 0 0 0 1 3625.dat
1 14 0 -77 8 1 0 0 0 1 0 0 0 1 3626bp01.dat
1 15 0 -53 8 1 0 0 0 1 0 0 0 1 973p01.dat
1 4 0 -21 8 1 0 0 0 1 0 0 0 1 3815.dat
1 47 -3.981 -49.593 -37.144 0.62756 -0.113859 -0.770198 -0.113859 0.965192 -0.235458 0.770198 0.235458 0.592752 3899.dat
1 1 -15.552 -44 8 0.985 -0.109274 -0.130228 0.17 0.633146 0.754554 0 -0.766044 0.642788 3818.dat
1 1 14.666 -44.381 7.96 0.985 0.109274 0.130228 -0.17 0.633146 0.754554 0 -0.766044 0.642788 3819.dat
1 14 -21.38 -40.793 -13.006 0.985 -0.169328 -0.0148142 0.17 0.981104 0.0858354 0 -0.0871426 0.996044 3820.dat
1 14 21.38 -40.793 -13.006 0.961905 0.27136 0.0148142 -0.271622 0.957959 0.0858354 0.00910888 -0.0866652 0.996044 3820.dat
1 4 0 -9 8 1 0 0 0 0 1 0 -1 0 3816.dat
1 4 0 -9 8 1 0 0 0 0 1 0 -1 0 3817.dat
1 16 0 0 0 1 0 0 0 1 0 0 0 1 6372-Chair.ldr
0

=== FILE: 6372-Minifig-2.ldr =========================================================

0 6372-Minifig-2.ldr
0 Name: 6372-Minifig-2.ldr
0 Unofficial Model
0 BFC CERTIFY CW
1 0 0 -77 8 1 0 0 0 1 0 0 0 1 3901.dat
1 14 0 -77 8 1 0 0 0 1 0 0 0 1 3626bp01.dat
1 0 0 -21 8 1 0 0 0 1 0 0 0 1 3815.dat
1 4 -15.552 -44 8 0.985 -0.109274 -0.130228 0.17 0.633146 0.754554 0 -0.766044 0.642788 3818.dat
1 4 15.552 -44 8 0.985 0.11594 0.12433 -0.17 0.671768 0.720383 0 -0.731354 0.681998 3819.dat
1 14 -21.38 -40.793 -13.006 0.985 -0.169328 -0.0148142 0.17 0.981104 0.0858354 0 -0.0871426 0.996044 3820.dat
1 14 21.566 -39.716 -12.76 0.985 0.169871 0.00593202 -0.17 0.984251 0.0343708 0 -0.0348942 0.99924 3820.dat
1 0 0 -9 8 1 0 0 0 0 1 0 -1 0 3816.dat
1 0 0 -9 8 1 0 0 0 0 1 0 -1 0 3817.dat
1 47 -0.979 -53.844 -33.62 0.43721 -0.174494 -0.88227 -0.100542 0.965365 -0.240752 0.893722 0.193964 0.404523 3899.dat
1 4 0 -53 8.38 1 0 0 0 1 0 0 0 1 973p13.dat
1 16 0 0 0 1 0 0 0 1 0 0 0 1 6372-Chair.ldr

=== FILE: 6372-Chair.ldr ====================================================

0 6372-Chair.ldr
0 Name: 6372-Chair.ldr
0 Unofficial Model
0 BFC CERTIFY CW
1 16 0 0 0 1 0 0 0 1 0 0 0 1 4079.dat
1 7 0 8 0 0 0 1 0 1 0 -1 0 0 3679.dat

@MinnieTheMoocher
Copy link
Author

behaviour confirmed by testing.
Steps (1) and (2) described in this issue (see above) are missing.
Files located there are not found properly.

@MinnieTheMoocher
Copy link
Author

I've looked into the sourcecode, and the error is located in function
def locate(pattern):

and can be easily spotted there.

the pathes being checked are wrong. they currently are:

ldrawPath = os.path.join(LDrawDir, fname)
hiResPath = os.path.join(LDrawDir, "p".lower(), "48".lower(), fname)
primitivesPath = os.path.join(LDrawDir, "p".lower(), fname)
partsPath = os.path.join(LDrawDir, "parts".lower(), fname)
partsSPath = os.path.join(LDrawDir, "parts".lower(), "s".lower(), fname)

# Unoffical Paths
UnofficialPath = os.path.join(LDrawDir, "unofficial".lower(), fname)
UnofficialhiResPath = os.path.join(LDrawDir, "unofficial".lower(),
                                   "p".lower(), "48".lower(), fname)
UnofficialPrimPath = os.path.join(LDrawDir, "unofficial".lower(),
                                  "p".lower(), fname)
UnofficialPartsPath = os.path.join(LDrawDir, "unofficial".lower(),
                                   "parts".lower(), fname)
UnofficialPartsSPath = os.path.join(LDrawDir, "unofficial".lower(),
                                    "parts".lower(), "s".lower(), fname)

I'll simplify things here for display. I will use C:\LDRAW instead of LDrawDir for simplification.
The order currently implemented in that function is:

c:\ldraw
c:\ldraw\p\48
c:\ldraw\p
c:\ldraw\parts\s
c:\ldraw\parts
c:\ldraw\unofficial
c:\ldraw\unofficial\p\48
c:\ldraw\unofficial\p
c:\ldraw\unofficial\parts
c:\ldraw\unofficial\parts\s\

This order is all wrong in many ways! The proper order would be:

(current folder of the currently loaded model)
c:\ldraw\models
c:\ldraw\parts
(c:\ldraw\p\48 only if the user has chosen to substitute ALL primtives by their 48 versions!)
c:\ldraw\p
c:\ldraw\unofficial\parts
(c:\ldraw\unofficial\p\48 only if the user has chosen to substitute ALL primtives by their 48 versions!)
c:\ldraw\unofficial\p\

Note that this is a totally different list!

The folders c:\ldraw\ and c:\ldraw\unofficial\ need not to be scanned at all.
No parts are expected to be located there.
Only ldconfig.ldr, but that anyway should be loaded by a different function.
See also that the current folder of a file to be loaded takes precedence over all others.
Then comes the "models" folder (missing in your implementation).
Then comes the "parts" folder (in your implementation: in wrong order after "p").
Then comes the "p" folder.
The "parts\s" folder needs not to be scanned because s\ files always have to be referenced by "s\xyz.dat",
thus will be found while scanning the "parts" or "unofficial\parts" folder.
The "48" folder needs not to be scanned because 48\ files always have to be referenced by "48\xyz.dat",
thus will be found while scanning the "p" or "unofficial\p" folder.
You only need to scan that folder if your user has chosen to substitute ALL primitives by "48" versions,
which should not be the default but only be done on explicit user choice.

@MinnieTheMoocher
Copy link
Author

here is the corrected code. note that you still need to work on the line marked # XXX

def locate(pattern):
"""
Locate all files matching supplied filename pattern in and below
supplied root directory.
Check all available possible folders so every single brick
can be imported, even unofficial ones.
"""
fname = pattern.replace("", os.path.sep)

isPart = True # isSubPart(pattern) # TODO refactor! wrong logic. a file is a "part" only if its header states so.

pathes = []
pathes.append(r"D:\LEGO\playbox\scenes\houses") # XXX todo: use the folder of the currently imported file here, not a hardcoded path!
pathes.append(os.path.join(LDrawDir, "models"))
pathes.append(os.path.join(LDrawDir, "parts"))
if HighRes:
   pathes.append(os.path.join(LDrawDir, "p", "48"))
pathes.append(os.path.join(LDrawDir, "p"))
pathes.append(os.path.join(LDrawDir, "unofficial", "parts"))
if HighRes:
   pathes.append(os.path.join(LDrawDir, "unofficial", "p", "48"))
pathes.append(os.path.join(LDrawDir, "unofficial", "p"))

for path in pathes:
   fname2 = os.path.join(path, fname)
   if os.path.exists(fname2):
      return (fname2, isPart)

debugPrint("Could not find file {0}".format(fname))
return ("ERROR, FILE NOT FOUND", isPart) # TODO wrong! return error to caller, for example by returning an empty string!

@JoshTheDerf
Copy link
Collaborator

I could probably fix this very quickly, but as usual, I have very little time today. Will look into it.

Thank you for your report and contribution!

@le717
Copy link
Owner

le717 commented Dec 28, 2013

I'll comment on all this when I can. Thanks for looking into this! I would not have known how to fix it! If you'd like, fork the repo, make a new branch of the master branch, perform the changes, submit a pull request, and we'll review it. 😃

@MinnieTheMoocher
Copy link
Author

may I ask to get this fix into the planned release 1.2
#41
?

It is quite important to have a corrected files search algorithm in it.
Searching in the currently wrong order can produce weird/unwanted results.

@le717
Copy link
Owner

le717 commented Dec 28, 2013

If you can write a patch, we can add it to that. We were planning on making v1.2 a rewrite (which is badly needed), but considering the reports and patches added recently, we might end up doing a minor release to tide things over and fix these issues.

@MinnieTheMoocher
Copy link
Author

you can see the patch above. the only thing missing in it is the line marked # XXX where I have
hardcoded a path as workaround. you there need to use the path where the currently imported file is located.

Here is a screenshot with the result Blender gives when using my code suggestion above.
It works fine then.

6372_ok

@JoshTheDerf
Copy link
Collaborator

The hardcoded path fix shouldn't be hard. I'll look into it.

Looking at your repositories, are you a .NET/Mono programmer? </offtopic>

@MinnieTheMoocher
Copy link
Author

yes, mainly C++ and C#. For >10 years ;)

@JoshTheDerf
Copy link
Collaborator

whistles
NICE. I'm into Java a lot right now, the only thing keeping me from C++ being the need to install development libraries. (I don't have administrator access to my machine)

@le717
Copy link
Owner

le717 commented Dec 28, 2013

Looks like the only thing missing in the patch is the new /p/8 folder, which I would assume we would need to support.

@JoshTheDerf
Copy link
Collaborator

No biggie, but will we need an option for 'low-res bricks'?

@MinnieTheMoocher
Copy link
Author

It is not necessary right now.
You could convert your current option "Replace all primitives by High-Res (48ed) primitives",
which currently is a boolean, to a multiple choice option.
The default is and should be "no primitives replacement".
Another value could be "substitute high-res (48ed) primitives".
In that case, you will search the p\48 folders BEFORE the p folders.

The new value of that option would be "substitute low-res (8ed) primitives".
In that case, you will search the p\8 folders BEFORE the p folders.

Note that you need to do that both times, i.e., in the official and unofficial folders.

So the code above becomes:

pathes = []
pathes.append(r"D:\LEGO\playbox\scenes\houses") # XXX todo: use the folder of the currently imported file here, not a hardcoded path!
pathes.append(os.path.join(LDrawDir, "models"))
pathes.append(os.path.join(LDrawDir, "parts"))
if HighRes:
pathes.append(os.path.join(LDrawDir, "p", "48"))
elif LowRes:
pathes.append(os.path.join(LDrawDir, "p", "8"))
pathes.append(os.path.join(LDrawDir, "p"))
pathes.append(os.path.join(LDrawDir, "unofficial", "parts"))
if HighRes:
pathes.append(os.path.join(LDrawDir, "unofficial", "p", "48"))
elif LowRes:
pathes.append(os.path.join(LDrawDir, "unofficial", "p", "8"))
pathes.append(os.path.join(LDrawDir, "unofficial", "p"))

Adding that option is not very important, as usually a user will most probably not want
to get low-res primitives into blender.
What would be much, much more important and interesting would be primitives
substitution by native Blender 3D objects, similar to the way LDView does it.
The request for adding that feature is a separate issue, #44

@JoshTheDerf
Copy link
Collaborator

Looking at the code, the recursive form of the LDrawFile class strikes again! It's hard to get the proper working directory for the file when the same code is being used to parse the individual parts themselves.

Can I use a global variable?

@MinnieTheMoocher
Copy link
Author

I think that would be the easiest way.
In your main function, simply compute the path of the file being imported and store it in a global variable.
Then use that variable when looking for files.

While you are at that, I suggest that you optimize the code a little more:
Currently the "pathes" array gets constructed in EACH and EVERY call of the "locate" function.
That's not necessary.
You can setup that array in your main function.
It will be the list of folders to be searched.
The good thing is that there you can add the folder of the file being imported very easily.

So this will solve 2 problems with 1 change :D

@le717
Copy link
Owner

le717 commented Dec 28, 2013

And that, my friend, will go with #35, AKA rewrite. :)

@MinnieTheMoocher
Copy link
Author

yes, but the change suggested above can also be added easily to the current code and would already
bugfix the current loading process.

I would suggest to add the simple fix above to the current implementation
and THEN start the refacturing.

Otherwise, I have to wait for this fix until you've finished the refacturing :( ,
and as every refacturing, you should take all time you need for that...

@le717
Copy link
Owner

le717 commented Dec 28, 2013

Is the patch in #40 (comment) the entire locate() function? I'm was about to add it on the fix_import_paths branch, but I need to make sure before I started.

@MinnieTheMoocher
Copy link
Author

yes. however, adding the global variable mentioned will require to touch more/other locations.
however, it will be near to trivial to do that.

@le717
Copy link
Owner

le717 commented Dec 28, 2013

Also, is
isPart = True # isSubPart(pattern) # TODO refactor! wrong logic. a file is a "part" only if its header states so.
supposed to be all on one line and isSubPart(pattern) is simply part of the comment, or is isSubPart(pattern) on a new line but commented out?

@MinnieTheMoocher
Copy link
Author

currently, I hardcoded isPart to be always true because I didn't want to refacture too much.
the current logic of that is too poor. it needs to be extended.
a part is only a part if in it a header line is contained
0 !LDRAW_ORG Part
or
0 !LDRAW_ORG Unofficial_Part
Note that after that, more characters can come, so a real life example is
0 !LDRAW_ORG Part UPDATE 1998-06

This requires looking INTO the file to determine if it is a part or not.

I did not check where that IsPart flag is being used for.
I suspect that its current use is not really necessary, and you can abolish it.

I can only imagine 1 useful use of that information:
it a file is a part, then it can be scaled down a tiny, tiny bit to create a visual gap
between parts. LDView for example does that.
That gap of course must NOT be created for primitives, or files which are shortcuts,
i.e., assemblies of parts. Or models. So it only must happen for files which carry the information
in their header that they are a part.

However, adding that parsing requires a major reworking of the script, so my suggestion is
to currently leave that away and get rid of the current IsPart variable at all.
I have created a separate issue for that "gap" feature: #46

@JoshTheDerf
Copy link
Collaborator

I seem to have gotten it working correctly on linux, complete with the directory of the current file, but MinnieTheMoocher's ldr file can't find the part: 3062B.DAT Or STUD4.DAT

Also, it's spelled 'paths' not 'pathes'. It's a common spelling mistake. :3

EDIT: Added .lower() to fname2 so that it doesn't fail when finding badly capitalized files (see above). All ldraw parts should be named. The bad news is, that means all external files must be lowercase.... Not sure how to fix that. ATM

EDIT2: MinnieTheMoocher's solution works, but seems to cause a MAJOR speed hit. Not sure why, it might be something else in the new version that I just forked.

My 4kb test file has been going for nearly 30 minutes, removing vertices for about 27 of them, even though I selected "Original LDraw model"

@MinnieTheMoocher
Copy link
Author

(a) the ldraw files in the file system can be upper or lowercase or mixed. you need to find them case-insensitively...

(b) speed: the paths[] array construction should be moved out of the locate function. it is expensive and only needs to be done once.

@JoshTheDerf
Copy link
Collaborator

(a) Just fixed that.

(b) The paths array construction slows it down a bit, but the slowest part seems to be the "removing of vertices"

@le717
Copy link
Owner

le717 commented Dec 28, 2013

For information, I added the code from here in the fix_import_paths branch.

What you said here, Steffen, if I can comprehend it enough (bit unfocused ATM), I may attempt to work on it.

EDIT2: MinnieTheMoocher's solution works, but seems to cause a MAJOR speed hit. Not sure why, it might be something else in the new version that I just forked.

My 4kb test file has been going for nearly 30 minutes, removing vertices for about 27 of them, even though I selected "Original LDraw model"

(b) The paths array construction slows it down a bit, but the slowest part seems to be the "removing of vertices"

Oh yes, the script has taken a major speed hit, but I'm not sure where. His code did slow it down, but it also seems to be slower without it. The only things it could be is #45 or #47, but I'm not sure either of those slow down the actual importing process. The latter should actually speed it up, but I'm not sure.

His patch for the proper locations also seems to do something which should not happen.

blender 2013-12-28 18-46-28-08

Changing isPart in locate() to False fixes this issue and imports the models as they should be and restores the speed lost by the patch (though that does not explain what is going on in the master).

blender 2013-12-28 18-48-22-19

As Steffen (MinnieTheMoocher) said, isSubPart(pattern) needs to be refactored to work correctly which solves that issue. However, with this horrid LDrawFile class, I'm not sure how to proceed and not slow it down any more.

@JoshTheDerf
Copy link
Collaborator

Ah, that explains it. Alrighty, I have a complete directory patch. (Linux)

EDIT: Apparently the issues with certain parts not importing correctly (mainly concave round parts) has been fixed in git! :D

le717 added a commit that referenced this issue Jan 6, 2014
gh-40 - "(b) speed: the paths[] array construction should be moved out
of the locate function. it is expensive and only needs to be done once."
@le717 le717 mentioned this issue Jan 7, 2014
10 tasks
@ghost ghost assigned JoshTheDerf and le717 Jan 9, 2014
@le717
Copy link
Owner

le717 commented Jan 9, 2014

I'm closing this issue now because it was fixed with #50, but I'll keep this in mind for later reference for a few things. ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants