[LDCad] Use script to create submodel


[LDCad] Use script to create submodel
#1
Hi all,

Is it possible to use a script to create a submodel in LDCad?
I ask this because I have to create multiple submodels that all require some basic other (LPub3D) metacommands and one or more parts, always in the same place.
This should be done by looping through a simple series of model names and descriptions.

I need to have submodels called A1, A2, A3, A4, .... A16
And B1, B2, B3 to B16 etc.
All the way to H.

Then I need submodels LA1, LA2, etc. to LH16

The A1, B1, etc. submodels should all have these lines:


Code:
0 ROTSTEP 90 180 0 ABS
0 !LPUB CALLOUT BEGIN
1 16 0 0 0 -0.5 0 0 0 0.5 0 0 0 -0.5 LA1.ldr
0 !LPUB CALLOUT END
0 !LPUB ASSEM MODEL_SCALE LOCAL  1.2500
0 !LPUB PLI BEGIN IGN
1 71 -150 0 150 1 0 0 0 1 0 0 0 1 91405.dat
0 !LPUB PLI END


Where in line 3 LA1.ldr is, of course, incremental like LA2, LA3, etc.

The LA1, LA2, etc. submodels should have more part lines in them and all start looking like this:

Code:
0 !LPUB ASSEM MODEL_SCALE LOCAL  0.3500
0 !LPUB PLI BEGIN IGN
[many part lines, all the same]
0 !LPUB PLI END

I was thinking about creating some sort of array that contains the names of the submodel files and then loop through to create all the submodels I need.

At least, that is my theory if I can use a script.

Or: can it be done another way?

Thanks all.
Jaco van der Molen
lpub.binarybricks.nl
Reply
RE: [LDCad] Use script to create submodel
#2
(2019-09-16, 19:15)Jaco van der Molen Wrote: Is it possible to use a script to create a submodel in LDCad?

Not directly, as it would need access to the internal file object (owner of all the subfile objects within a ldr/mpd) while currently there is only the ldc.subfile wrapper.

But you can (as of 1.6c) read/write any kind of file you want trough the lua io module.

You could use that to generate the ldraw content as nomal text (so without the ldc.subfile object etc).

Then load an existing file (if you want to append it to an existing model)
Add the new text and save the file again (i recommend using a different name though for backup purposes).

If you appended to a file currently open in LDCad it should trigger a reload in the editor once the script is done.
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 2 Guest(s)