Kicad StepUp: The Sketcher for Getting to Blinky

@Rene_Poschl
I forgot to tell you I added F.Fab anf F.CrtYd beside F.Silks to footprint loading in FreeCAD as per your needs as Librarian :wink:
Maurice

1 Like

Wow thanks. (and a few more words to have 20 chars)

I still have a problem. After “export to kicad”, in Freecad my Transparency value is erased and return to 0.

If you mean that when exporting i.e. a cube with 50% of transparency to wrl and step you will get a wrl with transparency, a step without transparency (not supported in STEP format) and your cube in FC will be changed to lose transparency, that is correct. The tools are aimed to export FC models to STEP and WRL, so the FC MCAD model will lose the transparency as it will lose the STEP model because of STEP format. If you want to preserve your model transparency in FC, just make a simple copy of it before exporting.

1 Like

needed to make a pretty funky PCB shape, so I decided to give Sketcher a spin :slight_smile:
took a few hours to understand how to use the sketcher properly, but it works very nice :slight_smile:
Thanks for the great job as always @maui keep the good stuff coming :slight_smile:
Im wondering if some of the construction data could be stored in comment.user layer or something, since you lose almost all your constraints etc when going freecad -> Kicad -> Freecad

1 Like

Hi Frank,

fortunately there is a trick to keep all the constraints… :wink:
It is a hidden feature that I’m happy to disclosure :smiley:

The ECAD/MCAD collaboration works in that way:

  1. Start your board in KiCad designing a very basic pcb edge (a simple square or even a circle) and add a Grid Origin to the board
  2. Pull (load) the board (even without an edge or with a ‘proto’ square edge) in FC
  3. Design your pcb Edge in FC using all FC Sketcher facilities (included Ellipses or BSplines)
  4. Save your design with the Sketch as FC file
  5. Push your Edge to a KiCad pcb file
  6. Design your tracks and place your modules and 3D parts in KiCad
  7. In case of some Edge modification, Pull the board in FC (that will load the pcb Edge loosing your previous assigned constraints) loading the new position of parts
    Here comes the tricky part:
  8. Load the previous release of your KiCad board as FC file
  9. Copy the Sketch of your previous release to the new one (Copy/Paste the Sketch between the two FC files)
  10. Delete the unconstrained Sketch
  11. Make the Edge changes to the previous release Sketch
  12. Push back the Sketch to your KiCad board.
  13. Save the new release of your pcb Edge as FC file.

This is a Push-Pull procedure with a sort of versioning of your Edge and PCB tracks.
One important note:
You need to assign into your KiCad pcb file a static design reference since the beginning.
The reference is:
a) Grid Origin (suggested)
http://docs.kicad.org/stable/en/pcbnew.html#_setting_coordinates_origin
or
b) Drill and Place offset (this will affect also Drill output of your gerbers)
and configure also StepUp to use Grid Origin (as suggested in the Cheatsheet)…
in ‘ksu-config.ini’ set:

[Placement]
placement = usegridorigin
;; placement options
;placement options: useauxorigin, usebaseorigin, usebasepoint;x;y, usedefault, +autoadjust

Following this versioning procedure you can keep your Sketcher always up to date with your board, and keep also the original geometries and constraints that will be lost in KiCad.

M

4 Likes

I am making very good use of StepUp these days in my current project. Thanks so much maui for providing these great utilities. As I understand from the above, what you want to do to update the PCB edge is to re-import the board into FreeCad with StepUp, and replace the sketch in that imported file with the original saved one with the constraints. However when I do that I am getting an offset in the position of the PCB edge. I am not sure I understand the last point, which could be my problem: Were in KiCad are one to set a PCB file static design reference to the preferred choice Grid Origin? Does that differ from the default setting?
[edit: to make it clear, the offset already appears in FreeCad after replacing the new sketch without constraints with the old one with the constraints].

What has worked for me without producing an offset is a manual procedure: Rename/make backup of the edited Pcbnew file. Let KiCad create a new blank pcbnew file. Import that into FreeCad and copy the sketch of the saved FreeCad file that has the board outline with the constraints to replace the original blank sketch and edit it to your liking. Save it and push the edge back to the blank PCBnew file. Edit the PCBnew file that now has the updated edge with a text editor and replace everything except the PCB edge with the information from the original renamed PCBnew file. (I found the board edge is conveniently placed at the very end of the PCBnew file so it is very easy to do these edits in a text editor).

1 Like

http://docs.kicad.org/stable/en/pcbnew.html#_setting_coordinates_origin

If you start designing with that assigned, everything will be kept aligned.
I forgot one information above: you need to configure also StepUp to use Grid Origin (as suggested in the Cheatsheet)…
in ‘ksu-config.ini’ set:

[Placement]
placement = usegridorigin
;; placement options
;placement options: useauxorigin, usebaseorigin, usebasepoint;x;y, usedefault, +autoadjust

I edited/placed this info also above now.

Thanks for the explanation maui. I tried doing as instructed, however it seems to be sensitive to where grid origin is placed. In the first attempt I centered the grid origin in Pcbnew. That lead to a 1.6 mm offset in both x and y plane after the exchange back and forth. Then I tried grid origin in the upper left corner, but got a large offset. Third attempt with a centered grid origin again gave a medium large offset. In ksuconfig.ini I have placement = usegridorigin.

It seems to me that instead of re-importing the whole board into FreeCad for edit of board edge, one could have just had some code that would push the original constrained sketch to the pcbnew file, by essentially doing the same edit as I did with my text editor. This would avoid any problems with grid origins, as it would just be a repeat of the initial export of pcb edge to the board.

Application: kicad
Version: (2017-11-03 revision 08a9dc01c)-makepkg, release build
Libraries:
wxWidgets 3.0.3
libcurl/7.54.1 OpenSSL/1.0.2l zlib/1.2.11 libssh2/1.8.0 nghttp2/1.23.1 librtmp/2.3
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8)
Boost: 1.60.0
Curl: 7.54.1
Compiler: GCC 7.1.0 with C++ ABI 1011

Build settings:
USE_WX_GRAPHICS_CONTEXT=OFF
USE_WX_OVERLAY=OFF
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_ACTION_MENU=ON
BUILD_GITHUB_PLUGIN=ON
KICAD_USE_OCE=ON
KICAD_SPICE=ON

No, it shouldn’t…

this would break the connection between the Sketch and the mechanical design, for example when checking for enclosure collisions…
The most straight way is to follow the suggested sequence…
What is normally done is to place the grid origin to a drill center (i.e. the pin #1 of a connector), then all your measures will be referenced to that origin, both in KiCad and in FreeCAD.

I attached a test-board self containing project…
test-board.zip (356.4 KB)
I placed the Grid Origin to pin#1 of the pin-headers connector
Could you please have a try in push and pull with this board to see if in your configuration is it working with this board?

1 Like

Thanks for the the followup, maui. I can confirm that the attached test board worked pushing the version with the rounded edge back to the pcbnew file without creating an offset. Apparently I am doing something incorrectly with my own boards in KiCad. I assume the grid origin in FreeCad is read from the KiCad pcbnew file and does not have to be defined separately in FreeCad?

I will experiment some more. I am pretty inexperienced with using the grids in FreeCad, but I found out I could display the 3d grid and confirm the location of the grid origin in the file you supplied, so that gives me something to work on with my own boards.

BTW I am using development versions of both FreeCad and KiCad, both only a few days old.
(KiCad version in my last post).
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12539 (Git)
Build type: Release
Branch: master
Hash: adc24f8c8ffb81ce5b85af9ac6ed67054ae0030d
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: English/UnitedStates (en_US)

After some more experimentation, it could look like my problem was that I started out with a completely blank board, with just the grid origin defined (or no grid origin before I became aware of that), no edges or components on the board. Perhaps that prevented the grid origin to be saved. With a simplified board as a starting point with defined grid origin, the interchange back and forth works now (several times) without creating any offset.

2 Likes

Hi @otoien
thank you for testing this latest implemented feature…

I see if I can attach the grid origin to the sketcher also when the board is without a basic starter edge.

For the moment I updated the description as for your workflow.

Maurice

Hi @otoien
now it should work also with empty boards… the only requirement is to place the grid origin since the beginning.
(update ksu from FC tools)

I just noticed that placing grid origin will not trig any changing to pcbnew, so the Save button will not be enabled…
This is a bug that I would file to launchpad.


(done)
Thanks again for testing
M

Hi @maui
Thanks for looking further into this. The bug could help explain my initial problems. Good to be aware of this so that one can make some other changes to the board that will enable the save.

1 Like

Hi, @maui.

I have some questions:

  1. Say I have come up with a sketch to be used as board edges, but the sketch is in another FreeCAD file, e.g. the pcb is mounted on a flange, whose 3d model was used to define the edge of the pcb. How can I push that sketch into my pcb? Perhaps importing it using your assembly2 workbench (another superb contribution to FreeCAD)? If I try to push the sketch into a pcb, either nothing happens or FC tells me I should import the pcbnew file first (in which case it opens a second sheet for it). In either case, a mysterious “Shape” object appears directly under the root of the original mechanical document. Something weird happens because I get errors in the FC report window (‘Sketch004’ is the name of the sketch I am trying to push):

pcb edge does not exist, aligning sketch to Grid Origin
Sketch004
Traceback (most recent call last):
File “/home/cf/.FreeCAD/Mod/kicadStepUpMod/kicadStepUptools.py”, line 13195, in onPushPCB
PushPullPCB()
File “/home/cf/.FreeCAD/Mod/kicadStepUpMod/kicadStepUptools.py”, line 13531, in PushPullPCB
export_pcb(name)
File “/home/cf/.FreeCAD/Mod/kicadStepUpMod/kicadStepUptools.py”, line 16222, in export_pcb
ns=Discretize(s)
File “/home/cf/.FreeCAD/Mod/kicadStepUpMod/kicadStepUptools.py”, line 15754, in Discretize
sketch = Draft.makeSketch(FreeCAD.ActiveDocument.getObject(newShapeList[0]),autoconstraints=True)
IndexError: list index out of range

  1. Does the board origin have to coincide with the layer alignment target?

  2. What exactly is the status of the zero-origin bug in the stable version of KiCAD? I was not able to make much sense from that thread.

  3. Pertaining to the above (somewhat), I find it weird that KiCAD does not allow a save if it thinks nothing has changed. Why? I may just want to force a save regardless of changes, perhaps for my own bookkeeping based on time stamps.

I have the latest stable version 4.0.7 version of KiCAD for Ubuntu (KiCAD does not provide a means to copy its version info to the clipboard, unlike FC, and says “© 1992-2015” despite the fact that the latest version came out either this year or late last year). And here is the info about FreeCAD, the latest version I updated with today:

OS: Ubuntu 16.04.4 LTS [Note: For some reason, KiCAD reads it as 16.04.1]
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13325 (Git)
Build type: None
Branch: master
Hash: 77c1fc59e4732d52e04a2846f83fb01a839bc589
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: English/UnitedStates (en_US)

StepUp allows to push a Sketch to a PCB in these cases:

  1. the kicad board file is empty or doesn’t contain already a pcb edge…
  2. the sketch is inside a stepup imported board
    If your skecth is in a different FC file, just copy and paste it into the FC file generated while importing your kicad_pcb

to be pushed to a kicad board, the sketch must have a contiguous outline and there must be no overlapping or doubled edges
Could you share your sketch? or send it by PM?

no, you need to configure ksu to use grid origin

[Placement]
placement = usegridorigin

Having the Save button disabled until nothing has changed is useful to know if you have or not changed anything to your board (similarly to what you have in a text editor)… If you want to save the board regardless of changes, just use ‘save as’ menu and use the same name…

1 Like

@maui: OK, I will pm you the a file with the 3D model of the flange (which is not a solid, as defined in FC, but the sketcher, somehow, agreed to bind to flat surface on that flange!) with the sketch on it. Ironically, the sketch was also used to build a 3-D model of the pcb itself, which, unfortunately cannot be pushed to KiCAD because KiCAD does not understand 3D, and neither is it required to.

One more thing: I did declare a grid origin in pcbnew, pcbnew clearly displays it, but when I bring the cursor very close to, if not on top of, the grid origin, the coordinates I read are way different than (0,0).

What is that ‘Shape’ object that appears directly under the document root when I try to push the sketch into KiCAD? It makes no difference if I make ‘Shape’ visible or invisible—I see nothing.

thx I will have a look at :slight_smile:

this means the script run into an error in converting the sketch to a pcb edge…
which is your report panel output?

from the manual
http://docs.kicad.org/4.0.7/en/pcbnew.html#_right_hand_side_toolbar
“3.11. Right-hand side toolbar”

Grid origin. (grid offset). Useful mainly for editing and placement of footprints. Can also be set in Dimensions/Grid menu.

it will help in placing footprints at a right snap… it is an internal reference I used for having an absolute reference when exchanging data between FC and kicad

Thanks for the file…
I’ve found the issue… it is related to Points in the sketch… I normally place them in construction geometry, but I should have dropped them anyway… I’ve patched the ksu to let you keep them safe :wink:
Please update it through FC tools menu.
Patched release “7.1.7.9”