How to search objects and work with them

edited February 2015 in General
Hello,

Thanks to the "Edit > Search and Replace > Find", I can get a list of cells that I am interested in. Furthermore, I can "select" items from this list with CTRL+LMB or SHIFT+LMB, and the items are highlighted on the drawing...

* But then, how can I work with my "selection"? how can I do a copy/paste, a layer change, or a size change? The problem is that the "selected" items in the list are only _highlighted_ on the drawing, they are not really _selected_. I can't manage to do anything with it... how to do?

Here are also two minor points:
* It would be nice to have this search feature in the KLayout viewer also (already mentioned in discussion #457).
* Why isn't it possible to select with CTRL+LMB or SHIFT+LMB in the list obtained with "Tools > Browse Shapes"? It seems to be a similar work.

Have a nice day.

Olivier

Comments

  • edited February 2015

    Hi Olivier,

    there is a simple answer to these kind of "why isn't it possible to ..." questions: it simply isn't implemented that way. The find feature was intended to point you to the place. Providing selections for editing was not part of the original design and there are some nasty interactions between queries and editing features. The same is true for the "Browse ..." features.

    It can be changed of course, but somebody has to do it and it's not a no-brainer.

    I'll be very frank. Look to your left: 16 Likes on Facebook? Any stupid kitten video that takes me five minutes to record gives me a million ones. If Likes are today's currency then this project is doing pretty bad. That is not really raising my mood to spend a lot of time in improvements.

    What do you think?

    Matthias

  • edited November -1
    It's 17 now. Using the button on the left did not work for me. I had to search klayout on facebook and like it there. That might explain the low number of likes.
  • edited February 2015

    Matthias,

    A stupid kitten video might give you a million likes, but it's not lasting. The next guy would film another kitten video tomorrow and get another million likes, and your kitten video would be forgotten in a matter of days or months. No offense to your cat though. :-)

    But you have created a tool that is truly lasting and I see myself using it for years to come. By now I've tried them all (well, all the big ones at least: "C", "L", "MGP") and seriously nothing beats the speed that I can lay out complicated layouts with KL. Mostly because almost everything I do needs to be scripted due to its complexity, and ruby is a beautiful 'gem' of a language. (I haven't gotten in to the Python yet. No need, for me at least, because I already have all the functionality with Ruby.)

    KL is the best software I have found in years and I use it daily. You've done everything properly, unlike large companies with hundreds of coders that are all getting tangled in each other's code and all at odds about how to design the user experience. In that regard I think having just one coder has been a huge boon for the simplicity of KL. I wish I was a true coder too so I could help with KL, but alas that's not my training and all I can do is write scripts in Ruby (which I learned exclusively for the purpose of KL coding, and having had a small amount of PHP experience but not much else). I will make more effort to answer posts on this forum though, to help make it more a community thing rather than just ask-Matthias-a-question... ;)

    Anyway I just wish the Facebook button was a better indicator of how great the tool is. I clicked it, but have to say I don't use facebook more than once a year. I know plenty of users that just use KL as a viewer and thus don't come on this website (because, they don't have problems to solve -- they just open and view layouts with it, and KL just "works"). Maybe a "Like" button in the software itself? A small icon in the "File/Edit/View/..." bar next to Help, or something. Also, an "Update to the latest version button" or a flag to show when a new stable release is available, since I've seen several people running very old versions who don't bother to upgrade because they use it as a viewer and it just "works" (but therefore they miss important new features in upgrades).

    Anyway just some thoughts, but don't get discouraged.

    David

  • edited November -1

    Thanks for cheering me up ... :-)

    I'm not taking the Facebook thing too seriously to be honest.

    The background was actually a different one: I don't have a real metrics about the impact of this project. I have some idea about the number of downloads (~4000/month), but not about the actual user community. Yes, there is some traffic here and some in my mailbox, but that does not tell a lot. The Facebook button looked like a good idea to get some idea, although I'm aware that not everybody will find this button and not everybody will push it. I'd be more enthusiastic if I knew about the number of people waiting for some feature.

    The vendors lead a simple life compared to me: they just count the money and if their revenue goes down they'll cut the project.

    I though about a "feedback" button in the software myself, but I know that admins, specifically in our domain, are scared about software trying to call home, because they suspect (and they may be right in some cases) the software transmitting a little more than just a ping ...

    Best regards,

    Matthias

  • edited November -1
    Hello,

    I managed to do what I wanted with a combination of KLayout and a text editor.
    Within KLayout, I used "Search and Replace" and exported the GDS in text
    format. I finished the work in a text editor with find/replace regexps.

    I now have another question:

    * How can I apply, say, a scaling factor to selected cells without moving each
    cell? If I use "Selection > Scale", the positions of the cells are changed. If
    I use "Properties", I have to click "next" to go through all the cells, there
    is no way to change the scaling factor for all cells at once. Could it be a
    good idea to have an option "Apply to all" in that window for example?

    > Providing selections for editing was not part of the original design and there
    > are some nasty interactions between queries and editing features (...) It can
    > be changed of course, but somebody has to do it and it's not a no-brainer.

    I appreciate the high quality of KLayout. I understand that it is created by a
    high level software engineer with a mastery of many fields of software
    engineering and micro-technology. I also understand that delving into the C++
    code would be an enormous task for me. That's why I'm only asking questions or
    mentioning suggestions.

    I'm a stranger to the Facebook world and more generally to the new
    social internet world.

    I work for a big European R&D center. We work with Mentor Graphics (Calibre),
    Cadence, and Clewin among other things. In the past years, we also used
    LayoutEditor, which was open source until 2008 and we stayed with that version
    when it became proprietary software. We started to use KLayout about two years
    ago for viewing and were impressed by the quality of the rendering and the
    speed. The availability for both Linux and Windows is also great. We now use
    KLayout increasingly for editing. Masks are still assembled with Cadence
    (Virtuoso) in a well established work flow (Design Kits, Design Rule Check with
    Calibre, etc.) but some cells are now created with KLayout.

    Dozens of people are using KLayout here daily (mostly for viewing, but
    increasingly for editing). Most of them are not accustomed to open source
    development and they do not show up on forums. We sometimes work with
    universities, and we see that are also using KLayout.

    Olivier
  • edited February 2015

    I like the idea of "Apply to all". This would of course imply "Apply to all similar", so if you have many things selected, change say a wire width, and click "Apply to all" then it would change all wire widths in the selection but keep selected cells, boxes, polygons, etc, unchanged. Or conversely if a property is added to a wire then that property is added to all wires AND cells and boxes and polygons etc (i.e. to anything that can hold a property).

    This is the behavior just of the "Apply" button in some other tools such as in LEdit, but I think a separate "Apply" and "Apply to all" button makes even more sense.

    In the meantime though it can be done via script. For example to change all wire widths as in my example:

    mw = RBA::Application.instance.main_window
    lv = mw.current_view
    layout = lv.active_cellview.layout
    
    lv.each_object_selected { |obj|
    
      next if (obj.is_cell_inst? || !obj.shape.is_path?) # Skip it if it's a cell or not a path
      path = obj.shape.path_width = 2 / layout.dbu # New width in microns
    
    }
    

    To change all cell magnifications as in your question is a little mor tricky as you have to know what translation the cell already has so you can translate to zero, scale, then translate back to its original location:

    mw = RBA::Application.instance.main_window
    lv = mw.current_view
    layout = lv.active_cellview.layout
    
    # The magnification factor. This must be a floating point number (i.e. 2.0 not 2)
    scaling_trans = RBA::CplxTrans.new(2.0)
    
    lv.each_object_selected { |obj|
    
      next if (!obj.is_cell_inst?) # Skip it if it's a not a cell
    
      orig_trans = obj.inst.cplx_trans
      zero_trans = RBA::CplxTrans.new(0,0)
      # Read the following line right to left: first move to zero, then do the scaling, then put back in original location
      obj.inst.cplx_trans = orig_trans * scaling_trans * zero_trans
    
    }
    

    Of course, while this works it presupposes familiarity with the API and with Ruby. An "Apply to all" button does not presuppose that, so would be a better solution I think.

    David

    P.S. For extra credit, add undo capability by wrapping the each_object_selected loop in this code:

    lv.transaction("Scale selected instances")
    begin
      # CODE
    ensure
      lv.commit
    end
    
  • edited November -1

    Hi David,

    I'm impressed. I'd like to suggest to finally clear the selection:

    begin
      ...
    ensure
      lv.cancel
      lv.commit
    end
    

    Otherwise there is a tiny risk of having shapes inside the selection which are no longer valid which may cause a crash of the application. The database core does not propagate changes to listeners such as the selection for performance reasons. I know this is somewhat tedious, but that is the most stable way right now.

    Another pitfall is that you may manipulate a shape twice, if it's selected two times via a different instantiation path. You can avoid this problem by choosing "select top level objects".

    Matthias

  • edited November -1

    Thanks Matthias for explaining that.

    I wonder, do you see possibility of including Apply To All button in proprrties window?

  • edited November -1

    Hi David,

    It's a nice suggestion but it's somewhat contrary to the architecture, where the selected objects are independent and they even do not need to share the same scope - for example, you can has rulers and shapes inside the same selection and those objects are entirely different.

    That won't be a simple enhancement. And as I mentioned, I don't have spare time currently.

    I'll note the request. It makes sense.

    Matthias

  • edited July 2015

    All,

    An "Apply to all" function was useful enough to me that I coded up one in Ruby. Download TRT v0.2.2 and look in Selection > Apply to all.

    (If you already downloaded 0.2.0, there are 13 new scripts and several improvements since that version, so I'd download it again. Just delete your 0.2.0 files and replace with 0.2.2 files to install it -- if you just merge the old with the new folder you may have issues since I changed some of the scripts' names or directories, so macros may show up twice in that case.)

    Using "Apply to all.lym", you can make multiple changes at once. For instance you can select multiple paths, boxes, polygons, and instances, and set path width, box left edges, the layer of selected polygons, and instance transformations, all in one click of "Apply". (Though you probably won't change more than 1-2 things at once, since it gets confusing.)

    A few notes:

    • If you've selected entirely or mostly paths, it automatically goes to the tab related to paths -- and so forth.
    • Since 'q' is mapped to properties, I mapped this macro to Shift+Q.
    • I know the UI is a beast and the code is a monster... I still think native "Apply to all" button would be preferable in the future, but perhaps this will help someone in the meantime.

    David

  • edited November -1

    Hi David,

    I hope you aren't disappointed, but by coincidence I am coding that right now ... :-)

    Matthias

  • edited November -1

    Not disappointed at all, that's great! It was a good coding exercise :)

  • Hello,
    I wanted to open a new topic, but I searched in the forum and I realized that I had already asked that question 3 years ago! This means that this is a need... at least in my view. So I wanted to put this "feature request" back on the table, in case someone had the time and power to implement it.

    Thanks to the "Edit > Search and Replace > Find", I can get a list of cells that I am interested in. Furthermore, I can "select" items from this list with CTRL+LMB or SHIFT+LMB, and the items are highlighted on the drawing...

    • But then, how can I work with my "selection"? how can I do a copy/paste, a layer change, or a size change? The problem is that the "selected" items in the list are only highlighted on the drawing, they are not really selected. I can't manage to do anything with it... how to do?

    -> Would it be possible to transfer the items selected in the "Find" list to the selection buffer?

    Olivier

    For information, here is the corresponding window in Cadence Virtuoso:

Sign In or Register to comment.