Insert comments in kicad_pcb file

I would like to insert comments in my .kicad_pcb files.
Been looking in the specifications (link) but could not find the keyword / character for comments :frowning:

Perhaps someone knows, if it exist?

Page settings.
Second icon from the left. Top toolbar.

What I mean is Iā€™m editing the pcb files in a text editor and want to remark some lines out :stuck_out_tongue:
Sorry for not being clear

Normally you can prefix a line with # or // etc.

You might want to head over to the mailing list or bugtracker for infos like this. To be honest i doubt that there is a way to do what you want but i might be wrong.

1 Like

There is no support for comments in the s-expression format.

4 Likes

Even if there existed a possibility to have comments in kicad s-expr files, editing and saving a file in pcbnew would erase all of them.

Cheers,
Tom

1 Like

There is no comment char, but if you deleted matching-brace blocks, with care, that is usually tolerated.
Use an editor with undo-across-save like Notepad++, in case you miss-brace-delete.

Other pathways, for your original question of ā€˜Insert comments in kicad_pcb fileā€™
KiCad will tolerate user comments after the last ), & those import with no errors, but are discarded on save
Can be useful for tagging automated generated files.

You can add comments as free text, in a minimal form as

  (gr_text "Text based comment " (at 0 0) (layer Dwgs.User)
  )

and that imports then saves as this (note has applied a default font size)

  (gr_text "Text based comment " (at 0 0) (layer Dwgs.User)
    (effects (font (size 1.27 1.27)))
  )

Also valid is \n for multi line comments

  (gr_text "Text\nbased\ncomment " (at 0 0) (layer Dwgs.User)
    (effects (font (size 1.27 1.27)))
  )
2 Likes

Not necessarily, KiCad could be written to retain them, if that was the specification.

Hehe, but then the use case for this would need to be evaluated by the devs to find out if thatā€™s worth their time.
I actually expected one of you guys to find out/ask what the use case is for this?

@MrBW , what do you use this for? Iā€™m curious :slight_smile:

I import DXF files with hole positions. And I need to place the pads and other objects exactly accordingly to those holesā€¦And as Pcbnew doesnā€™t have snap to objects ( :disappointed_relieved: ) I have to insert the pads manually with the correct center x,y which is rather easy in e.g. Notepad++ (I never open the ā€œmasterā€ file I modify manually in pcbnew, just a copy. Comments would be nice: 1: To make header-sections in the file and other remarks 2: To remark object- lines out temporary.

Editing the file manually (or by script) can be better for some thingsā€¦the pcbnew editor is rather restrictive and and limited in some way.

Can you paste here an example of a kicad_pcb file with such imported DXF? We may be able to find a way to snap or move without hassle.

I suspect that the ā€œtildeā€ character ("~") has been used by the developers to aid in troubleshooting; and it might work for what you want. I certainly donā€™t know the full syntax requirements.

There might be something better available:

1 Like

Notepad++ is a good choice, as it allows undo across save (for when you make an oops)

pcbnew snap is not great, but if you import circles in DXF, you can use Select + Crtl-R (Position relative to),

In that menu, is a choice for Select Anchor position, and that allows you to
Select part, then
Select DXF Circle

Then part centriod, is placed on DXF circle centre.

If you have cross hairs, thatā€™s not so easy as there is no intersection ability.

Strangely SMD parts work well as origin is usually centroid, but headers place not the part move origin, but the centroid. That means another (eg +50 mil) step fix is needed

Or, you can query any circle and copy the X,Y one at a time into the part X,Y.

2 Likes

Wauā€¦nice trick! I had to play around to get it right, but I eventually got it :slight_smile:
It also work for Arcs (I believe thatā€™s what polyline-circles in my DXF is converted to).

Now I donā€™t have to convert those polyline-circles to circles in AutoCAD before exporting to DXF.

My rewrite:

  1. Select KiCad object, e.g. pad or footprint
  2. Pres M to move
  3. Press CTRL+R (to open Position Relative dialog)
  4. Push ā€œSelect Anchor Positionā€
  5. Select circle/arc
  6. Pusk ā€œOKā€ button (Enter will not do it).

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