bambulab / BambuStudio

PC Software for BambuLab and other 3D printers
GNU Affero General Public License v3.0
2.13k stars 283 forks source link

CLI - Arrange specific STL files at specific positions of multiple plates from the command line - Assemble list JSON #3544

Open abdullahtahiriyo opened 9 months ago

abdullahtahiriyo commented 9 months ago

I am in need to programmatically generate from the command line some 10 plates of objects, each plate having three different objects which need to be arranged in a very specific position (auto arrange won't work in this case, I cannot share the model).

A possible way to do it with what is in place might be via: ./BambuStudio_linux_ubuntu_v01.08.04.51_20240117.AppImage --load-assemble-list assemble_list.json

This option is however not documented. I have only seen references to it in the source code. It looks it has the potential:

#define JSON_ASSEMPLE_PLATES                   "plates"
#define JSON_ASSEMPLE_PLATE_PARAMS             "plate_params"
#define JSON_ASSEMPLE_PLATE_NAME               "plate_name"
#define JSON_ASSEMPLE_PLATE_NEED_ARRANGE       "need_arrange"
#define JSON_ASSEMPLE_OBJECTS                  "objects"
#define JSON_ASSEMPLE_OBJECT_PATH              "path"
#define JSON_ASSEMPLE_OBJECT_COUNT             "count"
#define JSON_ASSEMPLE_OBJECT_FILAMENTS         "filaments"
#define JSON_ASSEMPLE_OBJECT_POS_X             "pos_x"
#define JSON_ASSEMPLE_OBJECT_POS_Y             "pos_y"
#define JSON_ASSEMPLE_OBJECT_POS_Z             "pos_z"
#define JSON_ASSEMPLE_OBJECT_ASSEMBLE_INDEX    "assemble_index"
#define JSON_ASSEMPLE_OBJECT_PRINT_PARAMS      "print_params"

typedef struct _assemble_object_info {
    std::string         path;
    int                 count;

    std::vector<int>    filaments;
    std::vector<int>    assemble_index;
    std::vector<float>  pos_x;
    std::vector<float>  pos_y;
    std::vector<float>  pos_z;
    std::map<std::string, std::string> print_params;
}assemble_object_info_t;

typedef struct _assemble_plate_info {
    std::string         plate_name;
    bool                need_arrange {false};
    int                 filaments_count {0};

    std::map<std::string, std::string> plate_params;
    std::vector<assemble_object_info_t> assemble_obj_list;
    std::vector<ModelObject *> loaded_obj_list;
}assemble_plate_info_t;

But I would need a proper assemble_list.json file, as otherwise, reverse engineering it would take me some time.

So, I would be grateful if you could give me some orientation about how to do what I want to do, and whether this option could be helpful (and if so an example JSON code would be very welcome). If you see an alternative way of doing what I want it is also very welcome.

Thanks!!

abdullahtahiriyo commented 8 months ago

@lanewei120

Any chance to get a sample assemble-list.json?

lanewei120 commented 8 months ago

@abdullahtahiriyo yes, we will share you a sample json after we returned to work(currently on our holidays)

abdullahtahiriyo commented 8 months ago

新年快乐

lanewei120 commented 8 months ago

@abdullahtahiriyo thanks

please find it from assemble_list_sample.json

abdullahtahiriyo commented 8 months ago

Thank you!

dd-dkenney commented 8 months ago

@lanewei120 hello again - I just wanted to confirm if the path defined in the assembly list JSON you provided is able to be set as an absolute path to the file on the filesystem somewhere?

lanewei120 commented 6 months ago

oops, just missed this thread before the path can be an absolute path and I think you should already verified it

praetp commented 5 months ago

Can you share a fully working example ?

lanewei120 commented 5 months ago

@abdullahtahiriyo thanks

please find it from assemble_list_sample.json

here is the example input file, just run following command: ./bin/bambu-studio --export-3mf out.3mf --load-settings="machine.json;process.json" --load-filaments="pla_basic.json;pla_basic.json;pla_basic.json;pla_basic.json" --filament-colour="#FFFFFF;#0000FF;#00FF00;#FF0000" --load-assemble-list="assemble_list_sample.json"

rizwansarwar commented 2 months ago

@lanewei120 is this still working? I just opened a bug because this process fails for me. I am using pretty much same command as above. see #4666

lanewei120 commented 2 months ago

it should still work do you mean it worked before, and can not work now? @rizwansarwar

rizwansarwar commented 2 months ago

@lanewei120 I personally never had it working. I was asking because you posted a couple of times implying it was and is working for you.

lanewei120 commented 2 months ago

you need to use the full config file image