PCell computation


I realize recently that PCell computation change with KLayout > 0.27 (or at least with Klayout 0.27.5 in windows 10 compared to version 0.26.12). Indeed before, the PCell geometry was computed only when the apply (or ok) button was pressed and now, the geometry is computed for every change in parameter.

This can be a problem when you are generating complex geometry (I am using it to generate transmission line with a lot of polygons in several layers) as the software can lag each time you are changing a parameter. Moreover, in that case I observe some glitch on the input field after changing the value, the field disappears and then reappears when I bring the mouse over them.

Could it be possible to have an option to bring back the old comportment or does another solution exist?

Thanks for this incredible software!


  • @Romain Thanks for bringing this up

    Actually, all input fields (all shape or instance property fields) have been changed to have a direct effect. This is in accordance with some commercial tools and in many ways this is quite useful. Restoring the original behaviour - even optionally - isn't trivial, so I cannot provide a quick solution here.

    A potential fix is to introduce some new way of configuring the PCell so it can request a geometry production callback only upon finalization. So some kind of "update frequency" parameter which cam ne "always" or "finally only".

    The glitch is probably due to a missing Paint event which is a typical problem when the application becomes busy with other tasks rather than serving the user interface.


  • Thanks for the information. I thought too about adding a check box at the end of the PCell (do geometry computation), just a bit annoying as it is easy to forget it when filling the PCell where the Apply/Ok was mandatory.

    Could be nice to have this kind of change in the release note (if I did not miss it .-) ), because it takes me a bit of time to realize why the software was working differently.


  • Well, it was in the release notes of 0.27, although among many other changes:

    But I'll check what is a good way to enable the old way of doing it. Here is one proposal which also is backward compatible: if the PCell implementation provides a method called "wants_lazy_evaluation" which returns true, then KLayout will postpone the evaluation until the parameters are committed.

    For example (Ruby):

    class MyPCell < PCellDeclarationHelper
      def wants_lazy_evaluation


  • When you point it out, the change seems obvious. I just did not make the link between object and PCell... Sorry.

    The solution seems to me like a good solution but I don't know enough of the code base to truly judge.

    Another option can be to put some option to the init of the parent class but that very different to the logic currently used.

    Thanks for this follow up answer and idea.

  • Very good.

    I'm going to release the "wants_lazy_evaluation" extension in 0.27.6. You can then try that and give feedback what you think about this feature.

    Kind regards,


  • It seems that the current implementation makes klayout crash when I tried to create a layout. Other reports are there: https://github.com/KLayout/klayout/issues/969

    On windows, I did not really find how to get the log but it is extremely likely the same problem than under CentOS7.

  • Yes, you're right. I have fixed this - the latest version (0.27.7) should work. Sorry for this glitch.


  • Just test it this morning and it works great!

    Thanks a lot for this new functionality and the very fast correction.


  • Glad to hear! You're welcome :)


Sign In or Register to comment.