How to add rules to individual objects - unable to group a single object

I use different kinds of mounting holes and need to add clearance for bolt heads/washers. The mounting holes can be the stock KiCAD mounting holes or simple shapes like circles or more complex shapes like elongated holes of various radii.

I group the holes together so the custom rules take effect. This works in general for mounting holes of more than one and for complex shapes. It fails for single mounting holes and simple shapes because they only contain a single object and cannot be grouped. Example:

The MountingHole_4.3mm_M4 does not have the correct clearance applied because the following rule does not work:

(rule "Clearance to mounting hole-M4"
  (condition "A.memberOf('mountinghole-M4') || A.Library_link == 'MountingHole:MountingHole_4.3mm_M4'")
  (constraint hole_clearance (min 2.7mm))
  (constraint edge_clearance (min 2.7mm))
  (constraint clearance (min 2.7mm)))

I don’t know what’s wrong with the rule. The other issue is that I cannot create a named group “mountinghole-misc” for the circle in the centre. So the rule is not picked up. How to solve this?

The ability to group single objects would solve all the issues, but apparently KiCAD doesn’t allow for that.

  1. How to fix the rule, so the single M4 mounting hole rule works as expected?
  2. What to do with single objects, like the circle in the centre?
Version: 7.0.10+1, release build

mountingholes01.zip (16.1 KB)

1 Like

A simple workaround for grouping one object only is to group two first and then remove one. Context menu → Enter group, select only one object in the group, context menu → Grouping → Remove items.

Thanks for the quick reply. That works, indeed. I didn’t try it because ostensibly KiCAD doesn’t allow groups of single objects and I assumed it would just remove the group after deleting the 2nd object.

Is it a bug (that should be reported) that KiCAD doesn’t allow creating single item groups then? This behaviour seems inconsistent; either single item groups are allowed or not. However, I’m fine with the workaround if that’s how it’s designed to work and can be relied upon in upcoming versions.

This has been noticed earlier, that’s why I remembered it, but I don’t remember if any of the developers said anything about it. I don’t find an issue for this with a simple search.

Condition A.Parent == 'MH1' seems to work (MH1 is an example reference designator).

It does. Still, I’m curious what’s wrong with

A.Library_link == 'MountingHole:MountingHole_4.3mm_M4'

#16586 - Single item groups cannot be created directly

1 Like

Creating one item group directly works now in the latest pre-v8 version (8.0.0.rc1.91 in Downloads | KiCad EDA).

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