AttributeError: module 'pcbnew' has no attribute 'DRAWSEGMENT'

kicad 6.0.9 python 3.914

AttributeError: ‘BOARD’ object has no attribute ‘GetModules’

AttributeError: module ‘pcbnew’ has no attribute ‘TEXTE_PCB’
AttributeError: ‘PCB_TEXT’ object has no attribute ‘SetThickness’

How can i get the full change log for kicad python api?

How to port old code to the latest ?

Current API is not a real api in conventional sense, it’s just kicad’s internals exposed via automatically generated python interface. So no change log other than git commit log.

File “C:\Program Files\KiCad\6.0\bin\Lib\site-packages\pcbnew.py”, line 13480, in GetShapeStr
return self.ShowShape(self.GetShape())
TypeError: ShowShape() takes 1 positional argument but 2 were given

    import pandas as pd
  File "C:\Program Files\KiCad\6.0\bin\Lib\site-packages\pandas\__init__.py", line 25, in <module>
    from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
  File "C:\Program Files\KiCad\6.0\bin\Lib\site-packages\pandas\_libs\__init__.py", line 13, in <module>
    from pandas._libs.interval import Interval
  File "pandas\_libs\interval.pyx", line 1, in init pandas._libs.interval
  File "C:\Program Files\KiCad\6.0\bin\Lib\site-packages\pandas\_libs\tslibs\__init__.py", line 37, in <module>
    from pandas._libs.tslibs.conversion import localize_pydatetime
  File "pandas\_libs\tslibs\conversion.pyx", line 77, in init pandas._libs.tslibs.conversion
  File "pandas\_libs\tslibs\parsing.pyx", line 1, in init pandas._libs.tslibs.parsing
  File "pandas\_libs\tslibs\offsets.pyx", line 1, in init pandas._libs.tslibs.offsets
  File "pandas\_libs\tslibs\timedeltas.pyx", line 77, in init pandas._libs.tslibs.timedeltas
  File "pandas\_libs\tslibs\fields.pyx", line 7, in init pandas._libs.tslibs.fields
  File "C:\Program Files\KiCad\6.0\bin\Lib\_strptime.py", line 268, in <module>
    _TimeRE_cache = TimeRE()
  File "C:\Program Files\KiCad\6.0\bin\Lib\_strptime.py", line 182, in __init__
    self.locale_time = LocaleTime()
  File "C:\Program Files\KiCad\6.0\bin\Lib\_strptime.py", line 69, in __init__
    self.lang = _getlang()
  File "C:\Program Files\KiCad\6.0\bin\Lib\_strptime.py", line 28, in _getlang
    return locale.getlocale(locale.LC_TIME)
  File "C:\Program Files\KiCad\6.0\bin\Lib\locale.py", line 593, in getlocale
    return _parse_localename(localename)
  File "C:\Program Files\KiCad\6.0\bin\Lib\locale.py", line 501, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: zh-CN

AttributeError: ‘BOARD’ object has no attribute ‘GetModules’

AttributeError: module ‘pcbnew’ has no attribute ‘MODULE’

    def add_pad(self, position, size, name='', pad_type='standard', shape='circle',
                drill=1.0, layers=None):
        """Create a pad on the module
        Args:
            position: pad position in mm
            size: pad size in mm, value if shape == 'circle', tuple otherwise
            name: pad name/number
            pad_type: One of 'standard', 'smd', 'conn', 'hole_not_plated'
            shape: One of 'circle', 'rect', 'oval', 'trapezoid'
            drill: drill size in mm, single value for round hole, or tuple for oblong hole.
            layers: None for default, or a list of layer definitions (for example: ['F.Cu', 'F.Mask'])
        """
        pad = Pad(pcbnew.D_PAD(self._module))

        pad.type = pad_type
        pad.shape = shape
        pad.size = size
        pad.name = name
        pad.position = position
        pad.layers = layers

        self._module.Add(pad._pad)
        return pad


D_PAD as PAD ## AttributeError: module ‘pcbnew’ has no attribute ‘D_PAD’

AttributeError: ‘BOARD’ object has no attribute ‘_module’

Take a look at the Replicate layout plugin in master and 5.99_test branch. This first one is a version that works in V5 while the second one is the version which works in V6. Looking at the diff you should get the idea what changed

When i set a new footprint in pcbnew,the footprint do not display instantly until I use mouse to click it. if i click other component. new footprint disappear again. what wrong with it?

	if not pcb:pcb = pcbnew.GetBoard()
	f='C:/test/x.kicad_mod'
	name='x.kicad_mod'
	sp  ='C:/test'
	plugin = pcbnew.IO_MGR.PluginFind(1)
	m=plugin.FootprintLoad(sp,name)
	if not m:
		return 0
	m.SetPosition(pcbnew.wxPoint(x,y))
	pcb.Add(m)

Maybe you shoud ‘pcbnew.refresh()’

How to do auto route in python

Easy, you hire a team of professional developers, pay them 5 digit salaries for a few months and at the end you’ll get something like freerouter.
Or you can just use freerouter.

More serious answer: kicad doesn’t have an auto router. There is some simple auto assisted routing in v7 but it’s not exposed in api.

2 Likes

File “”, line 1, in
AttributeError: module ‘pcbnew’ has no attribute ‘refresh’

“Kicad” python pcbnew how to create Non-plated hole

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