bennymeg / Fabrication-Toolkit

An JLC PCB Fabrication Plugin for KiCad
Apache License 2.0
311 stars 53 forks source link

Use IsDNP() to get the DNP attribute in KiCAD v8 #128

Closed msalau closed 7 months ago

msalau commented 7 months ago

footprint_has_field(footprint, 'dnp') returns False for DNP components in KiCAD v8.

In KiCAD v8 the DNP flag is available via either the IsDNP() getter or the FP_DNP attribute.

The added getattr() call turns into footprint.IsDNP() in KiCAD v8 or bool() (which evaluates into False) in KiCAD v7 and earlier.

bennymeg commented 5 months ago

@msalau this addition seems to throw false positives. I'm thinking changing it to (footprint.GetAttributes() & pcbnew.FP_DNP)) What do you think?

msalau commented 5 months ago

@bennymeg Sure, the attribute bit-field should work too. The only trick is that pcbnew.FP_DNP is defined only since v8. Can you share a project that reproduces the issue?

bennymeg commented 5 months ago

I took the pi template project which has both SMD and THT components. many community members reported the same issue. I used v8.0.1, this might be the source of the issue.

Edit:

The only trick is that pcbnew.FP_DNP is defined only since v8.

You are right, so something like (footprint.GetAttributes() & getattr(pcbnew, 'FP_DNP', 0)) should work.

msalau commented 5 months ago

@bennymeg I wrote a comment in https://github.com/bennymeg/Fabrication-Toolkit/issues/148 It seems the issue has been introduced while refactoring the feature but not the feature itself.

bennymeg commented 5 months ago

Thank you for finding out the issue! I also missed the invocation parentheses =P