How to determine whether a file is a part or a subpart


How to determine whether a file is a part or a subpart
#1
Is there a way to definitively know whether a particular .ldr or .dat file is a full part as opposed to a subpart or primitive? I'm writing an online LDraw visualizer using three.js, and one feature I'd like to add is an animation of the model "blowing up" - all of the pieces coming apart and falling to the floor. In order to do this, I'll need to know which definitions are linked and which aren't (i.e., I don't want the studs coming off the bricks).

My first thought is to assume that all subfile references in the root .ldr file are their own parts. However, I'm not sure if this is a reasonable assumption to make (this would do strange things if one was viewing a part directly, like a 2x4 brick (3001.dat) ).

Being able to identify individual parts will also help with seam width calculations.
Reply
Re: How to determine whether a file is a part or a subpart
#2
As far as I know the best is to look for an official header, where you can read if it is a subpart or a primitive.
There are some more ideas where you can look for, but this one is the most efficient I think.
Reply
Re: How to determine whether a file is a part or a subpart
#3
Official parts will have a 0 !LDRAW_ORG Part meta-statement. To the best of my knowledge all official parts will contain this meta-statement, and furthermore, all official files that contain this statement will be parts (not sub-parts or primitives). Having said that, many official parts are simply references to another file, which is also a part. In the context of a model that uses the first file, that instance of the second file isn't a part; it's a sub-part. So you have to have a run-time rule that state that in order to be a part, none of the file's ancestors can be a part. Or, probably easier, once you find a part, you know all its children aren't parts.

Unofficial parts are harder to recognize. LDView looks for quite a few different things when deciding if something is an unofficial part. I don't remember all of them off the top of my head, but it definitely looks for common meta-statements, as well as paying attention to the directory the file came from. I believe that it is set up so that if a file is loaded from a parts directory, it is considered to be a part if none of its ancestors was a part.
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 1 Guest(s)