LDraw.org Discussion Forums
[LDCad] Merge several .mpd files into one - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html)
+--- Forum: LDraw Editors and Viewers (https://forums.ldraw.org/forum-11.html)
+--- Thread: [LDCad] Merge several .mpd files into one (/thread-25454.html)

Pages: 1 2


Merge several .mpd files into one - Milan Vančura - 2021-10-12

Please, do you have any ideas how to solve this task?:

I have several MPD models, complex ones (nested submodels, buffer exchange used many times, hoses and strings etc. All this already interlocked with tons of LPUB3D commands) and now I need to create new mpd with all these models together (i.e. train containing machine and wagons). I do not need to keep original STEPs in original models (wagons), I create few new steps in the result model, showing how to connect wagons.

What's the easiest way to do this, preferably in LDCAD?


So far, I tried:
  • not working: nested mode, select all, copy&paste into new mpd. Strings were not copied, only one instance of each submodel was copied etc.
  • working but hard to do: select all, reorganize->inline several times, until it does something. Manually remove everything between buffer exchange blocks (error prone). Copy&paste into new mpd.
  • working but not sure it is correct solution: for each original mpd I do "File"->"Clean up"->"Add prefix", "embed unofficial". Then, create new empty mpd (with model "main"), join this new file and original mpd files into new one (on commandline, out of LDCAD: "cat new.mpd orig1.mpd orig2.mpd orig3.mpd >m.mpd && mv m.mpd new.mpd"). Open the result mpd in LDCAD again and use "MPD submodels" section in partbin.



RE: Merge several .mpd files into one - Philippe Hurbain - 2021-10-12

(2021-10-12, 11:13)Milan Vančura Wrote: working but not sure it is correct solution: for each original mpd I do "File"->"Clean up"->"Add prefix", "embed unofficial". Then, create new empty mpd (with model "main"), join this new file and original mpd files into new one (on commandline, out of LDCAD: "cat new.mpd orig1.mpd orig2.mpd orig3.mpd >m.mpd && mv m.mpd new.mpd"). Open the result mpd in LDCAD again and use "MPD submodels" section in partbin.
I think this is a correct method (it's the one I would have used before reading your proposals). Not sure though that "embed unofficial" is useful there.
But I'd be glad to be shown a simpler method Wink


RE: Merge several .mpd files into one - Milan Vančura - 2021-10-12

(2021-10-12, 11:57)Philippe Hurbain Wrote: I think this is a correct method (it's the one I would have used before reading your proposals). Not sure though that "embed unofficial" is useful there.
But I'd be glad to be shown a simpler method Wink

Embed unofficial is needed in my case - I need to include helpers (like arrows) or my own stickers. It might be you do not need this if your models do not contain such features.

Thanks for agreeing with my method - you made me more sure I did not create any hidden problems in the result model Smile But I'm also curious if there is a simpler method. This method has also drawbacks - for example all those original STEPs are kept in the new file what is not what I want. If there is a method how to copy just the result model, as it looks after its last step, with all buffer exchanges and submodels etc, I'd be happy.


RE: Merge several .mpd files into one - Philippe Hurbain - 2021-10-12

(2021-10-12, 12:30)Milan Vančura Wrote: Embed unofficial is needed in my case - I need to include helpers (like arrows) or my own stickers. It might be you do not need this if your models do not contain such features.
Right. I thought all unofficial parts to be available from all MPDs (so only one embedding after last step would be useful), but indeed that may not be the case!


RE: Merge several .mpd files into one - Roland Melkert - 2021-10-12

(2021-10-12, 11:13)Milan Vančura Wrote: not working: nested mode, select all, copy&paste into new mpd. Strings were not copied, only one instance of each submodel was copied etc.
Nested select all copy paste should work (visually wise), so those are bugs.

edit:
Just checked with 5510, which worked (wheels wise) so are you sure you are using 1.6d?
The strings not going trough isn't technically a bug though, as those meta's are only allowed in a managed content subfile so they will be filtered out during the paste action into a normal subfile.
end of edit


(2021-10-12, 11:13)Milan Vančura Wrote: working but not sure it is correct solution: for each original mpd I do "File"->"Clean up"->"Add prefix", "embed unofficial".
I think this would be possible in a single click if I added "Models" to the "Embed" section of the file cleanup feature.


RE: Merge several .mpd files into one - Milan Vančura - 2021-10-12

(2021-10-12, 18:12)Roland Melkert Wrote: Nested select all copy paste should work (visually wise), so those are bugs.

edit:
Just checked with 5510, which worked (wheels wise) so are you sure you are using 1.6d?
The strings not going trough isn't technically a bug though, as those meta's are only allowed in a managed content subfile so they will be filtered out during the paste action into a normal subfile.
end of edit
For some unknown reason, I lost all my configuration of 1.6d, 3 days ago, so I temporarily use 1.6c. If you think this is a bug solved in 1.6d, I find time to test my usecase in 1.6d as well. However, hoses and strings are important parts of models, I cannot loose them during copy&paste. So if there is no way to tell ldcad to keep them, this way of copying models is a no-go for me anyway. Unfortunately - because, otherwise, this method works better in mycase - it copies the result model only, without STEPs and buffer exchange.


RE: Merge several .mpd files into one - Milan Vančura - 2021-10-13

(2021-10-12, 18:12)Roland Melkert Wrote: Nested select all copy paste should work (visually wise), so those are bugs.
Thank you again, Roland, for a tip about 1.6d. I reinstalled 1.6d this morning and I may confirm everything bug flexible parts works, problems with nested submodels etc. are gone.

Please, what can I do with flexible parts?
  • Can you improve copy&paste to work with these in the next version?
  • Can I copy&paste them manually, somehow? Using source window? Or anything else?
  • Another alternative: can you add a feature "include this submodel"? Description: If I open two mpd files in LDCAD, I see all their submodels together in the partbin. But, so far, I cannot use them in the other mpd file. Could you extend this feature?

Maybe my ideas are too futuristic, I'm sorry I absolutely don't know how hard these features are. I just estimate this using a simple idea: LDCAD already understands mpd structure very well, including the tree of submodel dependencies, so it should be possible Smile


RE: Merge several .mpd files into one - Roland Melkert - 2021-10-13

(2021-10-13, 7:13)Milan Vančura Wrote: Can you improve copy&paste to work with these in the next version?
This is difficult as copy paste is text based, a paste in LDCad does not 'know' where it came from it just appends those lines to the current model one by one parsing them as they come. The problem is certain lines are not allowed inside a normal model (like the path constrains etc), so those will be skipped during paste. Leaving the references to them as 'missing' parts.
You can re-add those parts by adding a new (path) submodel using the same name though.
And then copy paste the path constrain lines etc from the original.

(2021-10-13, 7:13)Milan Vančura Wrote: Can I copy&paste them manually, somehow? Using source window? Or anything else?
You could copy the "0 FILE myBendedPart.ldr" upto "0 !LDCAD GENERATED...." and append it to the new file using an external plain text editor.
This should resolve the above mentioned missing parts.

(2021-10-13, 7:13)Milan Vančura Wrote: Another alternative: can you add a feature "include this submodel"? Description: If I open two mpd files in LDCAD, I see all their submodels together in the partbin. But, so far, I cannot use them in the other mpd file. Could you extend this feature?
MPD submodels can only be used within the same mpd, this is a LDraw limitation. If you want to use a submodel from multiple MPD's you must save it in a seperate .ldr file (via 'session/detach ...' or 'session/duplicate..' which offers to make a new standalone file of the duplicate.)


RE: Merge several .mpd files into one - Milan Vančura - 2021-10-14

Thank you for the explanation and ideas, Roland. So far, it looks for me that a combination with "File->Cleanup" functionality is an easier way. I do some tests later this month.

(2021-10-13, 19:16)Roland Melkert Wrote: MPD submodels can only be used within the same mpd, this is a LDraw limitation. If you want to use a submodel from multiple MPD's you must save it in a seperate .ldr file (via 'session/detach ...' or 'session/duplicate..' which offers to make a new standalone file of the duplicate.)

This is, I believe, a misunderstanding - ldraw standard does not allow _linking_ of other mpd files and their submodels, right? But there is no reason to forbid textual copy of them into another file (like text editor can do). This is my idea: as LDCAD already knows all parts of this job, it's just about to put all these partial features together: LDCAD's understanding of submodels and their dependencies, plus function "file->Cleanup->Embed Unofficial" and a partbin knowing to show all submodels of all sessions together. Then it should be possible something like "Embed missing submodels" using that set of submodels from the partbin. Or another idea: when user tries to put such submodel from partbin to the model, LDCAD may offer an option "it's from another file, copy it here?".

Too crazy ideas, Roland? Smile I hope not... It would so useful! Everytime I work for some customer I need such function. (This is, BTW, why I will have more time for deeper tests later this month, I must finish the project first. Customer takes no care about my problemswith LPUB or LDCAD, thay just want to get the project done Smile )


RE: Merge several .mpd files into one - Roland Melkert - 2021-10-14

(2021-10-14, 19:17)Milan Vančura Wrote: This is, I believe, a misunderstanding - ldraw standard does not allow _linking_ of other mpd files and their submodels, right?
LDraw does not care about what kind of file a type 1 line references, as long it's a text file with LDraw content.

So a type 1 line can reference a MPD file (e.g. city.mpd uses a bunch of house.mpd references) just fine.

But you can not reference a submodel inside another mpd, eg "1 16 0 0 0 1 0 0 0 1 0 0 0 1 house.mpd?2ndFloor.ldr"

It would try to load the "house.mpd?2ndFloor.ldr" from disk as a literal file name, which it can't so you'll end up with a missing file reference.

That said it can be a surprise what you get while using such recursive models depending on the program loading the files.

This because the LDraw search location mechanics are somewhat ambiguous/skewed (imho), something I have tried to simplify with the standards board for some time now.

LDCad uses a simple (stack) approach, namely:

Inside current file (mpd submodels)
Inside current file's folder (ldr submodels)
Library folders

And this is done using the 'context' of the current (recursively) loaded file.