Recommended Posts

Hi all,

I cobbled together a little command-line¹ program to convert LXF models to LDR. I put it in a gitlab repo here.

Contrarily to LDD’s own conversion process, it tries to convert decorations (though a lot are missing/different in LDraw) and flexible parts (though unflexed).

On the technical part: it’s source only², tested under Linux only but should compile and work on other OSes (needs Qt5 core, QuaZIP and yaml-cpp).

On the legal part: it’s GPLv3+.

Constructive comments are welcome. :classic:

———

¹ Yes, command-line, no GUI. Feel free to add one if you wish.  A minimal GUI was added in March, 2018.

² I won’t provide binaries. Feel free to do so for your OS (pointing to the sources as per GPLv3+).

Edited by SylvainLS
GUI comment

Share this post


Link to post
Share on other sites

Nice work! :classic: :thumbup:
I'll add it to the forum index (which is probably maybe kinda outdated...)

How do you create the parts in LDraw? LSynth style, LDCad style or maybe something of your own? 

Share this post


Link to post
Share on other sites

Thanks :classic:

LXF stores intermediary data as “bones.” I’m not sure yet if they are placed at the center of a rigid part (b-spline-like) or at the joints. It seems to depend on the part.

For now (not on the gitlab version (yet)), I just tried placing LDraw subparts at these points. It works great for some parts (as the one I linked, which is very simple) but not very well for others (technic flex-system hose or the tool belt 17).

So, next step is to look into how LSynth and LDCad do it and chose the easiest one, er, I mean, the one that translates best :wink:

Share this post


Link to post
Share on other sites
9 hours ago, SylvainLS said:

So, next step is to look into how LSynth and LDCad do it and chose the easiest one, er, I mean, the one that translates best :wink:

If you need info on the LDCad side let me know. In short it uses bezier control points combined with 'atom' parts and spreading rules.

Share this post


Link to post
Share on other sites
9 hours ago, roland said:

If you need info on the LDCad side let me know. In short it uses bezier control points combined with 'atom' parts and spreading rules.

I was wondering. LDCad saves the file with the fully generated part (e.g. a hose), so it can be viewed in other LDraw based programs. What if this lxf2ldr program would only generate the 'ldcad meta-data' such as your bezier points and such. Would LDCad then generate the full part when the file is opened?

Share this post


Link to post
Share on other sites

@roland Thanks Roland, but it seems LSynth’s way would be simpler: LDD’s bones can serve as LSynth’s constraints: the curve goes through them. With Bezier, the intermediary points are outside the curve. So, unless you have a simple method to interpolate Bezier c.p. from points of/in the curve, I’ll go with LSynth :classic:

@legolijntje As I’m lazy, that’s exactly what lxf2ldr will do, but with LSynth commands. I don’t want to reimplement LSynth’s interpolation. (Depending on the part, there are more or less “bones” than there will be LDraw parts. So I’d need to interpolate parts’s positions and rotations from the bones/passage points, which is exactly what LSynth does.)

Share this post


Link to post
Share on other sites
10 hours ago, legolijntje said:

I was wondering. LDCad saves the file with the fully generated part (e.g. a hose), so it can be viewed in other LDraw based programs. What if this lxf2ldr program would only generate the 'ldcad meta-data' such as your bezier points and such. Would LDCad then generate the full part when the file is opened?

If there is no "GENERATED" meta it will (re)generate the dynamic part upon opening it in LDCad, Otherwise it will only regenerate when you change something.

5 hours ago, SylvainLS said:

@roland Thanks Roland, but it seems LSynth’s way would be simpler: LDD’s bones can serve as LSynth’s constraints: the curve goes through them. With Bezier, the intermediary points are outside the curve. So, unless you have a simple method to interpolate Bezier c.p. from points of/in the curve, I’ll go with LSynth :classic:

I understand, you could probably use LSynth through an external call to generate it for you. I recommend embedding the needed LS*.dat part inside the resulting (mpd) model though.

Share this post


Link to post
Share on other sites

@SylvainLS Thanks for creating this. It will be nice to be able to do this from linux instead of starting a Windows VM.

Share this post


Link to post
Share on other sites

I just pushed a new version:

  • Groups are converted to submodels, centered on their first part or submodel.
  • Flexible parts are converted to LSynth commands. (It means you need to run LSynth on the generated file if you used flexible parts. (Cleaning up and removing a lot of control points before is recommended.))
  • Parse errors are now properly reported.
  • Code has been cleaned up and comments added.

A modified lsynth.mpd file is provided. It adds 3 new flexible parts: Minifig Chain Link 5L (92338), Hose Flexible 11.5L (14301), and Technic Tool Belt 17M (98567). (Latest LDraw Unofficial Library needed for 14301.)

Share this post


Link to post
Share on other sites

I just pushed a few improvements:

  • Assemblies (minifig hips and legs, torsos and arms and hands…) are regrouped in submodels.
  • Update ldraw.xml

(I will only post about big modifications from now on.)

Share this post


Link to post
Share on other sites
55 minutes ago, SylvainLS said:

I just pushed a few improvements:

  • Assemblies (minifig hips and legs, torsos and arms and hands…) are regrouped in submodels.

[...]

Cool! I don't use LDD myself, but there's some kind of grouping functionality right? Would it be possible to export those groups as submodels too? I can imagine that that might be useful for people.

Share this post


Link to post
Share on other sites
1 minute ago, legolijntje said:

Cool! I don't use LDD myself, but there's some kind of grouping functionality right? Would it be possible to export those groups as submodels too? I can imagine that that might be useful for people.

Yep:

On 22/5/2017 at 0:52 AM, SylvainLS said:

Groups are converted to submodels

:wink:

Share this post


Link to post
Share on other sites

Reminder: The program hasn’t changed (much) for a while but the decors (colors and patterns) and parts matches (a.k.a. ldraw.xml) are updated as soon as a new part is added in LDraw Unofficial :wink:

Share this post


Link to post
Share on other sites

Hey @SylvainLS any chance we can get a simple gui interface? Just browse to find the lxf file to convert and pick where the ldr goes? I am not to comfortable on the command line but I would like to use this for some builds I have. 

Share this post


Link to post
Share on other sites

I get an error when trying to add this with the git command on my mac.

fMTw96D.png

Like I said I am not a command line guy so I am not even sure what i did is right. 

Share this post


Link to post
Share on other sites

Big OOPS!  That’s the gitlab member URL. This is the anonymous download: 

git clone https://gitlab.com/sylvainls/lxf2ldr.git

Correcting the README right now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.