LDraw.org Discussion Forums

Full Version: Parts search paths
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was wondering if there is an official specification for parts folder priorities and limitations, I looked at the LDraw file format spec and it is somewhat vague in this area.

When loading an MPD file I search folders in this order:

- MPD subfiles
- unofficial parts folder
- unofficial p folder
- parts folder
- p folder
- MPD folder

And as for restrictions, should a file inside the MPD take priority over another file in the library (including primitives)? For example, if the MPD has a file called stud.dat, should it replace the studs in a part in the library?

It would be great to have some clarity on this to ensure consistency between applications.
(2019-11-25, 22:29)Leonardo Zide Wrote: [ -> ]And as for restrictions, should a file inside the MPD take priority over another file in the library (including primitives)? For example, if the MPD has a file called stud.dat, should it replace the studs in a part in the library?

Yes.
(2019-11-25, 22:36)Orion Pobursky Wrote: [ -> ]Yes.

What about if there's a file called stud.dat in the same folder as the mpd, should it be loaded instead of the one inside the mpd?

And if you're loading a plain ldr file and there's a file called stud.dat in the same folder as the ldr, does this stud.dat take priority over the one in the library as well?
(2019-11-26, 19:25)Leonardo Zide Wrote: [ -> ]What about if there's a file called stud.dat in the same folder as the mpd, should it be loaded instead of the one inside the mpd?
I would expect the embedded file to have priority. If the person who prepared the mpd embedded the file, it's to use that file and not another.
Quote:And if you're loading a plain ldr file and there's a file called stud.dat in the same folder as the ldr, does this stud.dat take priority over the one in the library as well?
That's the default behaviour I think.
(2019-11-26, 19:31)Philippe Hurbain Wrote: [ -> ]That's the default behaviour I think.

Would it be possible to remove this uncertainty (even you said "I think") by having the official spec state the correct search order?

From what you're saying it should be:

MPD subfiles
Model folder
Unoficial/P
Unoficial/Parts
P
Parts

Does P come before Parts or the other way?
(2019-11-26, 23:13)Leonardo Zide Wrote: [ -> ]Would it be possible to remove this uncertainty (even you said "I think") by having the official spec state the correct search order?

From what you're saying it should be:

MPD subfiles
Model folder
Unoficial/P
Unoficial/Parts
P
Parts

Does P come before Parts or the other way?

In LDView, P comes before Parts. Furthermore, <LDrawDir>/Models is also at the end of the list (due to original LDRAW.EXE having that in its search path). Whether that's a good thing or a bad thing is debatable.

I think it would be reasonable to codify the list in a spec.
(2019-11-26, 23:13)Leonardo Zide Wrote: [ -> ]Would it be possible to remove this uncertainty (even you said "I think") by having the official spec state the correct search order?
My restriction was more on a functional side: I have been caught many times by loading a model on the web and open it directly while it is in my temp folder... and then old weird part files sitting there may appear in the model and somehow break it!!!

As Travis said it would be a nice thing to clarify (and write) these rules.
(2019-11-27, 4:35)Travis Cobbs Wrote: [ -> ]In LDView, P comes before Parts. Furthermore, <LDrawDir>/Models is also at the end of the list (due to original LDRAW.EXE having that in its search path). Whether that's a good thing or a bad thing is debatable.

I think it would be reasonable to codify the list in a spec.


I was having a conversation with Trevor about a bug in LPub3D related to this and looks like both LDView and LDCad search the official folders before unofficial so the search order I posted is wrong. I'll be changing LeoCAD to follow the other tools but this is really something that should be in the standard.

What's the procedure to proposing an update to the spec?
(2021-03-13, 18:02)Leonardo Zide Wrote: [ -> ]and looks like both LDView and LDCad search the official folders before unofficial

LDCad has no hardcoded order except the 'p' and 'parts' one. Libraries them selves are searched in the order the user puts them in the configuration dialog.
(2021-03-13, 18:02)Leonardo Zide Wrote: [ -> ]I was having a conversation with Trevor about a bug in LPub3D related to this and looks like both LDView and LDCad search the official folders before unofficial so the search order I posted is wrong. I'll be changing LeoCAD to follow the other tools but this is really something that should be in the standard.

What's the procedure to proposing an update to the spec?

Apparently I was misremembering when I originally posted that. I just looked at the source code, and LDView's default search path is like this:

[color=rgba(255, 255, 255, 0.85)]   return "<MODELDIR>"[/color]
[color=rgba(255, 255, 255, 0.85)]   "|<HIDE><DEFPRIM><LDRAWDIR>\\P"[/color]
[color=rgba(255, 255, 255, 0.85)]   "|<DEFPART><LDRAWDIR>\\PARTS"[/color]
[color=rgba(255, 255, 255, 0.85)]   "|<LDRAWDIR>\\MODELS"[/color]
[color=rgba(255, 255, 255, 0.85)]   "|<UNOFFIC><HIDE><DEFPRIM><LDRAWDIR>\\Unofficial\\P"[/color]
[color=rgba(255, 255, 255, 0.85)]   "|<UNOFFIC><DEFPART><LDRAWDIR>\\Unofficial\\PARTS"[color=rgba(255, 255, 255, 0.85)];[/color][/color]

The above comes from Lars C. Hassing's LDrawIni (which LDView uses). Before looking for a file on the disk (using LDrawIni), LDView first checks if the file has been loaded from an MPD. So files in MPD files always come first.

As for updating the spec, I'll get that process started.