mvnmgrx / kiutils

Simple and SCM-friendly KiCad file parser based on Python dataclasses for KiCad 6.0 and up.
GNU General Public License v3.0
84 stars 27 forks source link

Creating a design rule only for inner/outer layers is not possible #116

Open chfriedrich opened 5 months ago

chfriedrich commented 5 months ago

When I create a custom Rule in KiCad, I can use the syntax

(rule "HV to HV (IL)"
    (layer inner)
    (constraint clearance (min 2.4mm))
    (condition "..."))

to limit its scope to all inner layers.

This is not possible with kiutils, because the layers member is a string, which gets parsed to

(rule "HV to HV (IL)"
    (layer "inner")
    (constraint clearance (min 2.4mm))
    (condition "..."))

with the word inner in appostrophs, which is not understood by kicad.

chfriedrich commented 5 months ago

I fixed this temporarily now by changing the if condition in line 187 of dru.py to

        if self.layer is not None:
            if self.layer == 'inner' or self.layer == 'outer':
                expression += f'{indents}  (layer {dequote(self.layer)})\n'
            else:
                expression += f'{indents}  (layer "{dequote(self.layer)}")\n'