In a schematic I set some components as “do not populate” and “exclude from bom”.
I’m able to restore those flags editing the properties of each component.
Is there a way to reset the flags for all the components at once?
It’s always helpful to write which version do you use.
This helps also future readers to contextualize the answer in relation to the different kicad version.
Kicad v8:
You could try the symbol fields table. Be sure to have “Scope==entire project” selected. From the Presets (bottom left corner) choose the “Attributes” Preset.
You have to experiment a bit with the selection behaviour, that needs a bit improvement.
First select one attribute-cell, change that cell to the desired state, copy that cell with"CTRL+C".
Then select the complete column, and paste the copied state to all these cells.
Kicad v9:
use the approach above
or utilize the new selection filter (this method works only for one schematic sheet page at a time, so maybe not so comfortable for schematics with hundreds of subsheets):
open one schematic sheet
enable the properties manager (View–>Show properties manager)
together with the properties manager a selection filter is displayed → enable only symbols
select all (hotkey “CTRL+A”) on the sheet → due to the selction filter all symbols on the sheet are selected
look in the properties manager panel - at the bottom you have 4 rows with the attributes (DNP/exclude)
First make sure you have ${DNP} and ${EXCLUDE_FROM_BOM} fields. Use the Attributes preset as mf_ibfeew said. (I have edited the Label cells.)
Now use the Group By checkbox: clear all other Group By checkboxes and tick only the Exclude from BOM box. Now you will have at most two rows in the Fields Table: those which have “Exclude from BOM” selected and those which don’t.
You can now just click the tickbox at right, and all will get either selected or deselected.
Do the same with DNP.
With a little bit of creativity you can even create rudimentary schematic variants: create a new field called DNPVariant. Give some components a numerical value for it. Now you can group by the DNPVariant field only, and make for example all components with Variant 1 to be DNP with one click and Variant 2 to be not-DNP with one click.