Can we output any message or information to VBA throught DOS or other way?

Hi sir ,
Background : I want to using excel /VBA to control Klayout to check GDS top cells name.
This is my simply code in Klyaout / DOS.

layoutView = RBA::Application::instance.main_window.current_view.active_cellview.layout
eachcells = layoutView.each_cell
topcells = layoutView.top_cells
outputdata=Array.new()
topcells.each do |xx|
outputdata << xx.name
puts xx.name
end

log_filename="GDS_filelog.txt"
aFile = File.new("#{log_filename}", "w+")
outputdata.each do |yy|
aFile.syswrite("#{yy}\n")
end
aFile.close

here is what the bat code .

@FOR %%C IN (*.gds) DO C:\Users\%username%\AppData\Roaming\KLayout\klayout_app -r C:\Users\%username%\KLayout\drc\drc_118.lydrc %%C

The Engineer in our team using excel (VBA) to list /sort /control a project.
so I want to make a way to let Excel co-work with Klayout as this simply case--just check what the top cells in what the GDS file.
Look like that is workable (the top cells been output to the text file), but do you have any smart way to make it ?

Comments

  • Hi,

    Do you like this output in an Excel spreadsheet?

    Kazzz-S

  • @sekigawa Yes , almost like this.
    But I want make it from VBA to control Klayout.

  • @jiunnweiyeh,

    I think KLayout with Ruby & Python is powerful enough. Besides, it's said that VBA will be deprecated.
    So why don't you switch entirely to Ruby and/or Python?
    The attached Excel spreadsheet is not handmade; it was generated directly from KLayout.
    If you are interested, I can provide the code.

    Kazzz-S

  • @sekigawa san
    Most people in our design team , he/she is not powerful for Ruby , they like using excel with simply VBA to do some of check .
    please kindly provide what the code do you have ,maybe I can base on that do modify and try to learn more function or coding.

  • edited December 2023

    Hi @jiunnweiyeh,

    In my experience, the learning curve for Ruby/Python is steep.
    I assume you are a team leader or manager.
    Spending time learning these new languages is a fruitful investment for the future.


    I have attached a sample code, Forum2442A.zip in Python.
    To run the code, you need the pandas and XlsxWriter packages.
    Ref. https://github.com/KLayout/klayout/issues/1494

    During testing, I found that XlsxWriter is not included in the Windows binary package (klayout-0.28.14-win64.zip).
    In the Windows environment, unpack the attached xlsxwriter.zip into the python3.11\site-packages\ directory, as shown below.

    On Linux and Mac, we can install the package with pip install XlsxWriter.

    Kazzz-S

  • Hi Kazzz-S san,
    Thanks a lot for your help.(a-ri-ga-tou)
    Our Klayout working in windows ,so I will check what your recommend.
    Maybe change the environment from windows to Linux is a good way cause hardware capbility.
    we have Linux server , but I don't know how to install klayout into Linux 8.
    anyway , Thanks your help.

  • edited December 2023

    @sekigawa Thanks for mentioning XlsWriter. There is this ticket (https://github.com/KLayout/klayout/issues/1494) and there are two requests, one from you :)

    I will try to include the XlsWriter package in the next release.

    I am generating Excel sheets myself using the XML version. That is very simple with any XML package, but you need some sample to get the structure. I am saving an Excel sheet as XML and use that as a skeleton for my writer.

    A also think that VBA is no longer state of the art. Python or Ruby are the way to go.

    Best regards,

    Matthias

Sign In or Register to comment.