Problem Summary
Can’t set pcbnew.VECTOR_FP_3DMODEL().m_Scale through the python interface with KiCad v7.0.0. Want to understand why and be pointed toward possible fixes.
Problem Details
I’m in the process of updating a set of python libraries/scripts I have for automating tasks to KiCad 7.0.0.
Right now I’m updating an abstract class for auto-generating footprints with KLC compliant parameters. I’ve been using the ‘pcbnew.py’ swig interface but have encountered an issue with setting parameters for the footprints 3D model.
The issue seems to be that there is a class that hasn’t been ported through swig called VECTOR3D. This appears to have been exported in the interface for some 6.x releases (as pcbnew.VECTOR3D) and used to be exported as pcbnew.MODULE_3D_SETTINGS_VECTOR3D in 5.x. I’ve included some snippets to demonstrate what I mean more clearly at the bottom.
There is a class in pcbnew.py called VECTOR_FP_3DMODEL which logically seems like it might be taking the place of VECTOR3D but setting parameters of an instance of pcbnew.VECTOR_FP_3DMODEL to this causes a type error with swig.
I’m not sure if I’m misunderstanding how the interface has now been setup or if the VECTOR3D class was forgotten when updating the swig interface and should be added back in. I’ve not got any experience with generating the swig interface and haven’t been compiling my KiCad installation but if someone could hand-hold me through getting started on that, I would be interested in contributing to the source for changes such as this if that seems like the best solution.
Python Console Demo
>>> import pcbnew
>>> pcbnew.Version()
'7.0.0'
>>> model_settings = pcbnew.FP_3DMODEL()
>>> scale = pcbnew.VECTOR_FP_3DMODEL()
>>> model_settings.m_Scale = scale
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: in method 'FP_3DMODEL_m_Scale_set', argument 2 of type 'VECTOR3D'
>>> pcbnew.VECTOR3D
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'pcbnew' has no attribute 'VECTOR3D'
>>> [entry for entry in dir(pcbnew) if "VECTOR3D" in entry]
[]