How do you run plugins in Kicad 5?

I have a script in Kicad/share/kicad/scripting/plugins. named ‘dail_indicator_wizard.py’
How do i run it in PCBNew??
Using WIN 7

Some versions of the windows installer did disable scripting. Make sure you install the latest version. (There are multiple builds for 5.0.1 out there. They have an additional number after the 1 to indicate this. I think it should be up to 3 or 4. For version 5.0.0 there was not even a number added at the end. The only difference was the compilation date and the file size.)

Version 5.0.1 doesn’t run on my PC only 5.00.

I fear there never was an official 5.0.0 release that supported scripting. There might be one on the testing server if you are lucky. http://downloads.kicad.org/windows/testing/

Currently downloading 5.0.1_4 well see what happens after install.

Ok 5.0.1_4 is installed.
i now have a Tools>>External Plugins menu, but no plugins are listed.
Iv’e tried ‘refresh’ but nothing happens, closed and reopen Kicad but nothing.

Plugins will only show up in that menu if the script has a class that extends ActionPlugin and somewhere in the script a register() method has to be called on an instance of that class.
You can read more about that here.
If you are not a developer and don’t understand the above, in simple terms, plugins need to declare themselves as pcbnew plugins in order to be picked up automatically by kicad and displayed in menu.

If you post contents of your plugin I may be able to help more.

1 Like

Here it is:

#  
#
# Authors: Bob Cousins
# Created : 2018-01-01

from __future__ import division

import sys
import math

import pcbnew
import FootprintWizardBase
import PadArray as PA

def rotate_about(center, p, theta):
    dx = p.x-center.x
    dy = p.y-center.y
    theta = math.radians(theta)
    x2 = dx * math.cos(theta) + dy * math.sin(theta)
    y2 = dx * math.sin(theta) + dy * math.cos(theta)

    return pcbnew.wxPoint(center.x+x2, center.y+y2)

class dial_indicator_wizard(FootprintWizardBase.FootprintWizard):

    def GetName(self):
        return "Dial indicator"

    def GetDescription(self):
        return "Indicator for rotary control"

    def GenerateParameterList(self):

        self.AddParam("Dial", "angle", self.uDegrees, 270, min_value=1, max_value=360)
        self.AddParam("Dial", "offset angle", self.uDegrees, 0, min_value=-180, max_value=180)
        self.AddParam("Dial", "radius", self.uMM, 6)
        self.AddParam("Dial", "inner arc", self.uBool, 1)
        self.AddParam("Dial", "outer arc", self.uBool, 0)

        self.AddParam("Ticks", "show ticks", self.uBool, 1)
        self.AddParam("Ticks", "number of divisions", self.uInteger, 10, min_value=1)
        self.AddParam("Ticks", "tick length", self.uMM, 1)

        self.AddParam("Labels", "show labels", self.uBool, 1)
        self.AddParam("Labels", "min", self.uInteger, 0)
        self.AddParam("Labels", "step", self.uInteger, 1)


    def CheckParameters(self):

        pass

    def GetValue(self):

        return "indicator"


    def BuildThisFootprint(self):

        dial_params = self.parameters['Dial']
        dial_angle = dial_params['angle']
        dial_offset_angle = dial_params['offset angle']
        dial_radius = dial_params['radius']
        dial_inner_arc = dial_params['inner arc']
        dial_outer_arc = dial_params['outer arc']

        tick_params = self.parameters ['Ticks']
        tick_show = tick_params['show ticks']
        tick_num_divisions = tick_params['number of divisions']
        tick_length = tick_params['tick length']

        label_params = self.parameters ['Labels']
        label_show = label_params['show labels']
        label_min = label_params['min']
        label_step = label_params['step']

        text_size = self.GetTextSize()  # IPC nominal
        thickness = self.GetTextThickness()
        # self.draw.GetLineTickness())
        textposy = self.GetTextSize()

        self.draw.Value( 0, textposy, text_size )
        self.draw.Reference( 0, -textposy, text_size )

        layer = pcbnew.F_SilkS
        center = pcbnew.wxPointMM(0,0)

        # inner arc
        if dial_inner_arc:
            start = pcbnew.wxPoint (center.x, center.y - dial_radius)
            start = rotate_about (center, start, dial_angle/2.0+ dial_offset_angle)

            self.draw.SetLayer(layer)
            self.draw.SetLineTickness(pcbnew.FromMM (0.15))
            self.draw.Arc (center.x, center.y, start.x, start.y, dial_angle*10)

        # outer arc
        if dial_outer_arc:
            start = pcbnew.wxPoint (center.x, center.y - dial_radius - tick_length)
            start = rotate_about (center, start, dial_angle/2.0+ dial_offset_angle)
            self.draw.SetLayer(layer)
            self.draw.SetLineTickness(pcbnew.FromMM (0.15))
            self.draw.Arc (center.x, center.y, start.x, start.y, dial_angle*10)

        # center cross
        self.draw.SetLayer(layer)
        self.draw.SetLineTickness(pcbnew.FromMM (0.15))
        start = pcbnew.wxPointMM(-2, 0)
        end = pcbnew.wxPointMM(2, 0)
        self.draw.Line (start.x, start.y, end.x, end.y)
        start = pcbnew.wxPointMM(0, -2)
        end = pcbnew.wxPointMM(0, 2)
        self.draw.Line (start.x, start.y, end.x, end.y)

        for j in range (0, tick_num_divisions+1):
            ang = j * dial_angle/tick_num_divisions - dial_angle/2.0 - dial_offset_angle
            ang = -ang

            start = pcbnew.wxPoint (center.x, center.y - dial_radius)
            end = pcbnew.wxPoint (center.x, center.y - dial_radius - tick_length)

            start = rotate_about (center, start, ang)
            end = rotate_about (center, end, ang)

            #
            if tick_show:
                self.draw.SetLayer(layer)
                self.draw.SetLineTickness(pcbnew.FromMM (0.15))
                self.draw.Line (start.x, start.y, end.x, end.y)

            if label_show and j * dial_angle/tick_num_divisions < 360:
                text_pos = pcbnew.wxPoint (center.x, center.y - dial_radius - tick_length - text_size*1.25)
                text_pos = rotate_about (center, text_pos, ang)

                #
                text = pcbnew.TEXTE_MODULE(self.module)

                text.SetPosition (text_pos)
                #text.SetOrientation (ang*10.0)
                text.SetThickness (pcbnew.FromMM (0.15))
                text.SetLayer(layer)
                text.SetText (str(label_min + j*label_step))

                self.module.Add (text)


dial_indicator_wizard().register()

Looks like a footprint wizard at first glance.

Open the footprint editor. Select new from wizard. In it open that script.

I’m getting an error:

Get newer version compatible with KiCad v5

https://raw.githubusercontent.com/bobc/kicad-utils/v5/scripts/footprint-wizards/dial_indicator_wizard.py

Update:
On second look the error appears to be in FootprintWizardBase.py which is part of kicad distribution. It looks like you have old version of that file which doesn’t work with new kicad. Try reinstalling or just grab it from here:
https://raw.githubusercontent.com/KiCad/kicad-source-mirror/5.0/pcbnew/python/plugins/FootprintWizardBase.py

1 Like

I went back to vers 5.0.0 and it’s working now.

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