INTI-CMNB/KiBot

blender_export in CI

Haschtl opened this issue · 2 comments

I'm currently trying to integrate the blender_export pipeline in Gitlab CI.
The blender_export does not work with the latest version of pcb2blender-importer in blender (#498).

The main problem is, that no kibot docker-image includes blender and the pcb2blender-importer plugin.
I've created an image including blender: haschtl/kicad7_auto_full_blender

I've created this Dockerfile:

FROM ghcr.io/inti-cmnb/kicad7_auto_full:latest

COPY installPcb2blenderImporter.py ./installPcb2blenderImporter.py
RUN apt update
RUN pip3 install skia-python --break-system-packages
RUN apt install -y blender wget python3-pil python3-numpy
RUN wget https://github.com/30350n/pcb2blender/releases/download/v2.6-k7.0-b3.5/pcb2blender_importer_2-6.zip
RUN blender -b  -y  --python ./installPcb2blenderImporter.py

WORKDIR /mnt

with the python-script installPcb2blenderImporter.py to install the blender plugin:

import bpy

bpy.ops.preferences.addon_install(overwrite=True, filepath='./pcb2blender_importer_2-6.zip')
bpy.ops.preferences.addon_enable(module='pcb2blender_importer')
bpy.ops.wm.save_userpref()

The installation of blender and the pcb2blender plugin works fine, it currently crashes when the pcb3d-file is imported. This is the error message from my CI output:

Importing PCB3D file ...
Failed to open file: /tmp/pcb2blender_tmp/test_kicad_pro-blender_export_pcb3d_11242776195456250025/pcb.wrl
Failed to open file: /tmp/pcb2blender_tmp/test_kicad_pro-blender_export_pcb3d_11242776195456250025/components/TQFP-144_20x20mm_P0.5mm.wrl
Error: Python: Traceback (most recent call last):
  File "/root/.config/blender/3.4/scripts/addons/pcb2blender_importer/importer.py", line 154, in execute
    if (pcb := self.import_pcb3d(context, filepath)) == {"CANCELLED"}:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.config/blender/3.4/scripts/addons/pcb2blender_importer/importer.py", line 297, in import_pcb3d
    obj.data.name = component.rsplit("/", 1)[1].rsplit(".", 1)[0]
    ^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'data'
Location: /usr/share/blender/scripts/modules/bpy/ops.py:113
Blender quit

I think this is more an issue of pcb2blender.

I didn't see that the kicad_debian image already installs blender@3.5.1
My Dockerfile installed blender@3.4 over it. I removed this line and now just install the pcb2blender plugin in the Dockerfile, which works now! It can now

Wouldn't it be great to integrate the pcb2blender-importer in the kicad7_auto_full image?
I have created a repo with the modified docker image here

Sorry for this ticket, I didn't see, that pcb2blender is already included