LDraw.org Discussion Forums

Full Version: Sort parts by position?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a tool that can sort or group parts based on their position coordinates? Thanks.
(2020-02-03, 0:09)Michael Horvath Wrote: [ -> ]Is there a tool that can sort or group parts based on their position coordinates? Thanks.
Not sure what you're trying to achieve, but the simple-minded answer is Excel (or any other spreadsheet program). Open the .ldr file as text, delimited by spaces, and you can do just about anything you like with it. It's all in fixed columns.
(2020-02-03, 8:31)Martin James Wrote: [ -> ]Not sure what you're trying to achieve, but the simple-minded answer is Excel (or any other spreadsheet program). Open the .ldr file as text, delimited by spaces, and you can do just about anything you like with it. It's all in fixed columns.

That's a good suggestion. But is it possible for spaces to exist in an LDR file that aren't delimiters? Inline POV statements could mess things up too.
(2020-02-03, 0:09)Michael Horvath Wrote: [ -> ]Is there a tool that can sort or group parts based on their position coordinates? Thanks.

I forgot that I implemented this ability into LDraw Design Pad (LDDP). Select the block of text you want to sort and choose Tools->Sort
(2020-02-04, 3:04)Orion Pobursky Wrote: [ -> ]I forgot that I implemented this ability into LDraw Design Pad (LDDP). Select the block of text you want to sort and choose Tools->Sort

Note that if there are bugs or implementation limitations with this feature, I can't fix them since I no longer have the ability to compile the source code (for now).
I haven't used LDDP in a long while. Can I sort just by three columns of text (X, Y and Z position) and ignore the others?
(2020-02-03, 23:36)Michael Horvath Wrote: [ -> ]That's a good suggestion. But is it possible for spaces to exist in an LDR file that aren't delimiters? Inline POV statements could mess things up too.
Yes, there can be spaces in other places, but you can first filter out all the rows that have "0" as the first colum, leaving just the part definitions.
(2020-02-04, 7:24)Michael Horvath Wrote: [ -> ]I haven't used LDDP in a long while. Can I sort just by three columns of text (X, Y and Z position) and ignore the others?

You can sort on center, max, or min x/y/z, color, linetype, and subfile.
(2020-02-04, 23:51)Orion Pobursky Wrote: [ -> ]You can sort on center, max, or min x/y/z, color, linetype, and subfile.

Thank you.
(2020-02-03, 0:09)Michael Horvath Wrote: [ -> ]Is there a tool that can sort or group parts based on their position coordinates? Thanks.

Both MLCad and LDCad can sort by height, can they not?
I ended up writing a small script that splits a model into several models depending on the x and z coordinates. It is in the Datsville GitHub repo. I'm not sure if I should parse for multiple kinds of white space between coordinate values or just regular spaces however. So the script may fail, depending.