LDraw.org Discussion Forums
Sort parts by position? - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html)
+--- Forum: LDraw File Processing and Conversion (https://forums.ldraw.org/forum-22.html)
+--- Thread: Sort parts by position? (/thread-23875.html)



Sort parts by position? - Michael Horvath - 2020-02-03

Is there a tool that can sort or group parts based on their position coordinates? Thanks.


RE: Sort parts by position? - Martin James - 2020-02-03

(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.


RE: Sort parts by position? - Michael Horvath - 2020-02-03

(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.


RE: Sort parts by position? - Orion Pobursky - 2020-02-04

(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


RE: Sort parts by position? - Orion Pobursky - 2020-02-04

(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).


RE: Sort parts by position? - Michael Horvath - 2020-02-04

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?


RE: Sort parts by position? - Martin James - 2020-02-04

(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.


RE: Sort parts by position? - Orion Pobursky - 2020-02-04

(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.


RE: Sort parts by position? - Michael Horvath - 2020-02-08

(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.


RE: Sort parts by position? - Jaco van der Molen - 2020-02-12

(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?


RE: Sort parts by position? - Michael Horvath - 2020-02-12

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.