The python scripting API does not provide a class PCB_TARGET

Bug #1380096 reported by LordBlick
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
High
LordBlick

Bug Description

>>> brd=pcbnew
>>> for StrAttr in dir(brd):
... if StrAttr.startswith('PCB'):
... print(StrAttr)
...
PCB_IO
PCB_IO_swigregister
PCB_PLOT_PARAMS
PCB_PLOT_PARAMS_GetGerberDefaultPrecision
PCB_PLOT_PARAMS_PARSER
PCB_PLOT_PARAMS_PARSER_swigregister
PCB_PLOT_PARAMS_swigregister
Additionally, pcb enumeration method pcb.GetDrawings() returns None in this object case.
Open attachment and paste in python console (same commands without leading spaces, prompt '>>>' or '... '):
>>> brd=pcbnew
>>> pcb=brd.GetBoard()
>>> draws=list(pcb.GetDrawings())
>>> for n in range(len(draws)):
... print("Draw[%i]:%s" % (n, draws[n]))
...
Draw[0]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f9d8da2a1e0> >
Draw[1]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f9d8da2a270> >
Draw[2]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f9d8da2a1b0> >
Draw[3]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f9d8da2a2a0> >
Draw[4]:None
>>>

Application: pcbnew
Version: (2014-jul-16 BZR unknown)-BZR5173 Release build
wxWidgets: Version 3.0.0 (release,wchar_t,compiler with C++ ABI 1002,GCC 4.8.3,wx containers,compatible with 2.8)
Platform: Linux 3.16.3-1 x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.55.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=ON
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=OFF

Required source C++ class is from pcbnew/class_mire.cpp
47:PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) :

Revision history for this message
LordBlick (lordblick) wrote :

I don't know why, but initial message drops attachment.

LordBlick (lordblick)
description: updated
LordBlick (lordblick)
description: updated
description: updated
LordBlick (lordblick)
Changed in kicad:
importance: Undecided → High
Revision history for this message
LordBlick (lordblick) wrote :

After patching with attachment, solution is half-succeed - we have got required class, but pcb enumeration method pcb.GetDrawings() still gives None instead PCB_TARGET object.
pcb.GetDrawings() is buried wraper of:
DLIST<BOARD_ITEM> m_Drawings;
pcbnew/class_board.h:239

Revision history for this message
LordBlick (lordblick) wrote :

Some log for attached earlier file:
Welcome To PyCrust 0.9.8 - KiCAD Python Shell
Python 2.7.8 (default, Jul 18 2014, 10:11:56)
[GCC 4.8.3 20140522 (release)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Startup script executed: /home/users/LordBlick/.config/python/pystartup
>>> brd=pcbnew
>>> pcb=brd.GetBoard()
>>> for n, draw in enumerate(pcb.GetDrawings()):
... print("Draw[%i]:%s" % (n, draw))
...
Draw[0]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f22fb86e1b0> >
Draw[1]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f22fb86e210> >
Draw[2]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f22fb86e120> >
Draw[3]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f22fb86e1b0> >
Warning: Uncatched Cast() to EDA_ITEM
Draw[4]:None
>>>

Revision history for this message
LordBlick (lordblick) wrote :

OK, final patch…
>>> brd=pcbnew
>>> pcb=brd.GetBoard()
>>> for n, draw in enumerate(pcb.GetDrawings()):
... print("Draw[%i]:%s" % (n, draw))
...
Draw[0]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f8e478c51b0> >
Draw[1]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f8e478c5210> >
Draw[2]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f8e478c5120> >
Draw[3]:<pcbnew.DRAWSEGMENT; proxy of <Swig Object of type 'DRAWSEGMENT *' at 0x7f8e478c51b0> >
Draw[4]:<pcbnew.PCB_TARGET; proxy of <Swig Object of type 'PCB_TARGET *' at 0x7f8e478c5180> >
>>>

LordBlick (lordblick)
Changed in kicad:
status: New → Fix Committed
assignee: nobody → LordBlick (light-i)
Revision history for this message
LordBlick (lordblick) wrote :
Jon Neal (reportingsjr)
Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.