Draw line segment from python

I’m trying to draw a segment on B.SilkS, but can’t see anything when I execute the code below. What am I doing wrong?

(KiCAD 4.0.6; Windows 7)

            ds=pcbnew.DRAWSEGMENT(self._board)
            self._board.Add(ds)
            #ds.SetShape(pcbnew.S_SEGMENT)
            ds.SetStart(pcbnew.wxPoint(corners[i].x,corners[i].y))
            ds.SetEnd(pcbnew.wxPoint(corners[i+1].x,corners[i+1].y))
            ds.SetLayer(self._LayerNumByName["B.SilkS"])
            ds.SetWidth(int(0.15*pcbnew.IU_PER_MM))

Have you enabled the “B.SilkS” layer to be displayed? Does it use a color that is easily seen on your display?

Dale

Yes. I have other items on that layer that are visible. I continue to test, and sometimes the layer is not added, sometimes the properties aren’t set, and sometimes the python variable itself doesn’t seem to get a value. Very weird. When i’vd repeated the commands in the console, I can verify that the object appears in the GetDrawings() list, and gets the right properties. It simply never appears on the board.

Have you tried it in both Legacy and OpenGL modes?

I hadn’t tried different modes until your message. When I switch modes, the line appears. And then switch back (to OpenGL), it still is there.

So something about switching seems to enable the display of the new DRAWSEGMENT.

I haven’t tried all combinations (staying in legacy or cairo modes, or switching from/to all combinations).

Now at least there’s a successful path to display. There’s still a bug somewhere though…

I’ve also had this issue with the OpenGL display. Updating the board via python doesn’t update the OpenGL display. That includes moving adding objects, moving objects and deleting them. It does update in the legacy display.

If you figure out a way to refresh the OpenGL display, can you post it?

Will do. I have seen objects on which SetHighlight() is executed get updated on OpenGL (Windows) when the mouse enters the pcbnew window.

I’ve filed this as a KiCad bug. It still happens in nightly (as of July 31, 2017).