Klayout in command line

edited September 2012 in General
Hi everyone!
(Sorry for my english)
I'm trying to convert GDS|DXF|CIF in image (BMP, JPEG,...) OR GDS|CIF in DXF.I'd like to convert it through a script (no interface), under windows 7.
I have not succesful use Klayout in command line under windows ...
From what I've read a previous post, I should use Ruby for my conversion. So I download RubyInstaller for windows and tried some script (from the binary klayout-0.22\testdata\ruby).

Every time I'm trying to compile one of these script, I have the error "uninitialized constant RBA (NameError)"
I'm relatively new to Ruby, please help! Any suggestion?

Thanks!

Comments

  • edited September 2012

    Hallo,

    you don't need a separate Ruby installation. KLayout comes with a built-in Ruby interpreter. To convert an format to CIF you can use the script described in http://klayout.de/forum/comments.php?DiscussionID=195&page=1#Comment_802. There you'll also find the correct way to call KLayout's command line in order to execute the script. No separate installation is required.

    Best regards,

    Matthias

  • edited November -1
    Hello Matthias,

    Thanks for your answer! Really appreciate :)
    If I understand correctly, I need to compile the code in Visual Studio to access the script needed for converting the files. Right? Because when I enter "klayout" in cmd, I get " 'klayout' is not recognized as an internal or external command, ..."
    Si I tried to compile the Klayout under my VS 2010, QT 4.8.0 and download ruby1.9.1-p430.zip. I configure the environment variables in the system properties and I reboot my computer. But when I tried to compile I have many errors. Like "error C2411: 'void rbs::RubyInterpreter::eval_string(const char *)': overloaded member function not found in 'rba::RubyInterpreter'. Or " error: C2039: 'install_console':is not a class memeber of 'rba::RubyInterpreter' "

    What I'm doing wrong in here?

    Thanks!
  • edited September 2012

    Hi

    I guess you misunderstanding Matthias' words..

    For klayout Windows version, it comes with a built-in ruby interpreter, you don't have to compile any source code for ruby script.

    Because ruby is text script, you should edit a file maybe named "convert.rb" with content

    layout = RBA::Layout.new
    layout.read($input)
    layout.write($output)
    

    and call klayout to read the script with the command:

    klayout -rd input=input.cif -rd output=output.gds -r convert.rb
    

    If get "klayout is not an internal command", please change your working directory to the klayout installation directory(with klayout.exe) and try again.

    Best Regards,

    chhung

  • edited September 2012
    Hi,

    Thanks for your answer!
    I tried it either. But when I'm doing this, the interface is open up and I have "Ruby error. Unable to open file: test.gds (errno=13)"
    So I thought it was normal since I did not compile Klayout.

    Best regards,
    seijuro2347
  • edited November -1

    Hi e.bourque,

    that's apparently because for some reason it can't find test.gds. If you use the correct input file path, does it work then?

    Best regards,

    Matthias

  • edited September 2012
    Hello,

    Finaly, I just reinstall Klayout 64 bits (instead of 32 bits) and now it's working! Sorry about all this ^_^
    But, I think it's has a bug in the software. When I'm opening a dxf or gds in klayout, everything works fine! But if I'm tring to open a CIF,I just get a big box with "Entities" in the middle. BUT if I'm opening a gds or dxf FIRST, after I "Open in the same panel" a cif. The cif opens correctly ... I don't know if I'm clear ... And I have the same problem with dxf/gds if they come from a conversion from a cif.

    Other small question. Is there a way to convert a dxf/gds/cif to image (bmp, jpeg ...) with a script?

    And wow, seriously guys, thanks alot for all your help!

    Best regards,
    seijuro2347
  • edited November -1

    Hi,

    When you get a box with "Entities" that basically says you have a cell called "Entities" and you don't have enabled enough levels of hierarchy to have the contents displayed. Did you choose a large enough number of hierarchy levels so the content of this cell is displayed (i.e. by pressing the "*" key)?

    Maybe you can send some screenshots to illustrate the problem.

    To convert a layout to an image, use a script like this:

    mw = RBA::Application::instance.main_window   
    mw.load_layout($input, 0)
    # to load a layer properties file:
    # mw.current_view.load_layer_props(lyp_filename)
    mw.current_view.max_hier
    mw.current_view.save_image($output, 1000, 1000)   
    

    It is used the same way than the previous one was used, but this time the output is a image file. The resolution is set in the "save_image" method and was choosen to be 1000x1000 pixels in this example.

    Best regards,

    Matthias

  • edited September 2012
    Nice! The * solve the problem!
    And the script is working like a charm!
    Thank you so much!

    Best regards,
    Seijuro2347
  • edited November -1
    Hi Mathias,

    I have some others questions for you!
    When I'm converting a CIF to DXF, I get a "Entities" box. As you say, I just press * for solving the problem (in Klayout interface). But if I convert a cif to dxf to bmp, I get a gray image. How can I insert the * issue in my ruby script? In my case, converting cif to dxf before converting to bmp it's important.

    I'm trying to disable the open/close GUI when I run the scrypt. From the doc (http://klayout.de/command_args.html), it's say -z it's for Non-GUI mode. But nothing happens when I run this option o_0'. Is there a way to avoid the "pop-up" interface?

    Last question, is there a way to disable the grid and the color? In the image it's have some line at the back. I'm trying to figure it out with documentation, but it's not evident.

    Thanks you so much!

    Best regards,
    Seijuro2347
  • edited October 2012

    Hallo,

    the "gray image problem" of the DXF must be something else. The "mw.current_view.max_hier" command does exactly what the star key does, so that cannot be the reason. I am suspecting that either the DXF export is not working well, or the script is using some other cell. You're saying that if you load the DXF manually and press the star key the image is fine while it is not when you use the image converter script above? That is strange, because the code is basically the same.

    Maybe you can send me the "gray" image to the mail address listed on the "Contact" page. This would help me understand the problem.

    Regarding the "non-popup" mode: that is a know issue. In version 0.22, -z was modified to be a real "displayless" mode without any windows. In this mode, KLayout can be run as a script interpreter without a display on Linux servers. But the converter script won't run in that mode because there is no MainWindow object. I'll fix that in the next minor release (see http://www.klayout.de/issues.html#0.22).

    And finally regarding the last question: you can use a configuration parameter to achieve this:

    mw = RBA::Application::instance.main_window
    mw.load_layout($input, 0)
    # to load a layer properties file:
    # mw.current_view.load_layer_props(lyp_filename)
    mw.current_view.max_hier
    mw.current_view.set_config("grid-visible", "false")
    mw.current_view.set_config("background-color", "#ffffff")
    mw.current_view.save_image($output, 1000, 1000)
    

    The "set_config" method allows to set a specific configuration parameter. There are numerous of them and you find them listed in the "klayoutrc" file in you application data folder (i.e. "c:/users/your_name/klayout/klayoutrc"). "grid-visible" turns the grid on or off and "background-color" specifies the color of the background in HTML "#rrggbb" notation.

    Best regards,

    Matthias

  • edited November -1
    Hello Mathias,

    Thanks again for your answer.

    Humm, now, when I'm trying, I'm not able to reproduce the issue ... Is it possible that this is due to the accents in the comments at the beginning of the file (é, à, è, ...)? Next time I have this issue I'll send it to you!

    Great! Thanks about this clear answer! So I just need to wait for the next release. Do you have an idea when that will be?

    And about the configuration, this is perfect, thanks you so much. It's amazing the amount of configuration you can do!

    Best regards,
    Seijuro2347
  • edited November -1

    Hallo,

    regarding the next release, I am collecting feedback currently.

    I want to establish a minor release cycle of a month or so, so taking that seriously there should be new minor release in a few weeks.

    So if you have any feedback don't hestiate to hand it over. This applies to ALL reading this :-)

    Best regards,

    Matthias

Sign In or Register to comment.