Add 3D model by script

Hi,
I imported an eagle project into KiCad to get a 3D model. The assignement of the 3D parts is not done. So I’m trying to write a script to assign them. It worked once, but I do not remember what I did to get it run. Now I’m getting the error code : -1073740940 (0xC0000374)

    board = pcbnew.LoadBoard(path)

    for module in board.GetModules():
        lib_id = module.GetFPID()
        footprintName = str(lib_id.GetLibItemName())
        models = module.Models()
        if len(models):
            model = models[0]
        else:
            continue

        module.Add3DModel(model)

In this example I just try to add the model again.
Is there anywhere a description of all these exit codes?

Look into archive_project.py

Thank you MitjaN!
So that means you don’t use the Add3DModel, but push it back directly to the model. Why my approach does not work?

I think that you cannot add 3D models to the footprints already on board. You’ll have to instantiate new footprint, add 3D model and only then add the footprint to the board. But I am not certain that this fits with your needs.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.