Adding multiple objects via command line
 
Notifications
Clear all

Adding multiple objects via command line  

  RSS
Shea
 Shea
(@shea)
New Member
Adding multiple objects via command line

I'm trying to figure out a command that allows me to add multiple instances at specified x,y coordinates for each instance (not in a grid.)  I've tried various combinations of --merge, --dont-arrange, and --single-instance and am not having luck.  I'm not a programmer, so I'm hoping someone wiser than me can help.

My goal is to print multiple instances of the same part, completing one instance at a time.  I've got multiple printer configurations, each with a different pattern to maximize the number I can print.  Differences in extruders and gantries require different spacings, and I'm not using simple "cylinder" and "height" requirements.  I've tuned each layout to account for that printer's geometry and the auto-arrange function can't replicate it.  For example, due to asymmetry of the extruder assembly, I'll print right to left on one printer, and left to right on another.  This allows me to get closer spacing than if I use the cylinder spacing method.

I want to be able to automatically regenerate each layout with each new stl.  For example, say I want to add 4 instances at the following locations.

1: 190,20

2: 135,30

3: 80,40

4: 15,50

Anyone know if this is possible, and how to do it if so?

Best Answer by Diem:

Er, I didn't keep the sources so rather than just the .stl files I'll show the method:

This tiny OpenSCAD file generates an off centre cube:

x=10;
y=10;
z=0;
translate([x.y.z]){
    cube([10,10,10]);
}

Use it to create test1.stl

Change the value of x to -10 and re-run it to create test2.stl

This is the line that worked:

./PrusaSlicer-2.2.0+linux-x64-202003211856.AppImage --merge --export-stl test1.stl test2.stl 

Unfortunately it overwrote t1.stl (my carelessness) so I didn't retry to check whether --merge was doing anything.

I wanted an output file to check without the gcode step, should have tried export-amf or specified the file name, of course you will eventually use --export-gcode

 

Hth, Cheerio,

Posted : 30/12/2020 6:05 pm
Diem
 Diem
(@diem)
Illustrious Member
RE: Adding multiple objects via command line

I've not tried usng the command line in anger.  If

--duplicate-grid X,Y

is not suitable I suggest you experiment with:

 --align-xy X,Y 
--center X,Y

Hth, Cheerio,

Posted : 31/12/2020 12:55 am
Shea
 Shea
(@shea)
New Member
Topic starter answered:
RE: Adding multiple objects via command line

@diem

Thanks.  Unfortunately grid doesn't work for me.

I've been trying center and align, but I can't get it to position the objects independently.  No matter how I arrange the .stl and --center or --align-xy commands, it just moves all instances to the last x,y coordinates listed.  Either my google-fu is failing me, or nobody else is trying to use it this way.  But I'm hoping I just don't have the right syntax.  I'm looking for an example command that places two objects at different x,y coordinates.

Posted : 31/12/2020 4:29 am
Diem
 Diem
(@diem)
Illustrious Member
RE: Adding multiple objects via command line

Quick experiments have repeated your results but I might have a workaround.

Instead of duplicating the part I tried loading two, each with a different starting offset in the stl ( translate ), and found that the offset is preserved so placing them in their own position.

Hth, Cheerio,

Posted : 01/01/2021 9:59 am
Shea
 Shea
(@shea)
New Member
Topic starter answered:
RE: Adding multiple objects via command line

@diem

Thank you for taking the time to experiment.  Could you post an example of the command(s) that worked?   I tried that with no luck.

Posted : 01/01/2021 2:04 pm
Diem
 Diem
(@diem)
Illustrious Member
RE: Adding multiple objects via command line

Er, I didn't keep the sources so rather than just the .stl files I'll show the method:

This tiny OpenSCAD file generates an off centre cube:

x=10;
y=10;
z=0;
translate([x.y.z]){
    cube([10,10,10]);
}

Use it to create test1.stl

Change the value of x to -10 and re-run it to create test2.stl

This is the line that worked:

./PrusaSlicer-2.2.0+linux-x64-202003211856.AppImage --merge --export-stl test1.stl test2.stl 

Unfortunately it overwrote t1.stl (my carelessness) so I didn't retry to check whether --merge was doing anything.

I wanted an output file to check without the gcode step, should have tried export-amf or specified the file name, of course you will eventually use --export-gcode

 

Hth, Cheerio,

Posted : 01/01/2021 5:54 pm
Diem
 Diem
(@diem)
Illustrious Member
RE: Adding multiple objects via command line

Grrr, why does the editing time run out so fast?

Typing code into a browser rather than an editor leads to daft errors; substitute commas instead of stops in the translate parameters.

Cheerio,

Posted : 01/01/2021 6:04 pm
Shea
 Shea
(@shea)
New Member
Topic starter answered:
RE: Adding multiple objects via command line

@diem

Brilliant!  Thank you so much for pointing me in the right direction.  I put together a script to use your workaround and it's exactly what I'm looking for.  For anyone trying to do this in the future, it can all be done with PrusaSlicer console commands.
 
Repeat this command for each instance location:
prusa-slicer-console --export-stl --center x,y myfile.stl -o iteration-n.stl

Then run this, adding all your instances at the end.

prusa-slicer-console --merge --export-stl [add all iteration-n.stl here]

 

Posted : 04/01/2021 7:14 pm
Share: