extract coordinates of all text object to file

edited November 2015 in General

I'd like to have a table of all of the text objects in my artwork with the text name (port name) and absolute x,y coordinates. The information is manually available in the object properties dialog. I'd like to know if anyone has written i script (or template I could start from?) for doing that or something similar?



  • edited November 2015

    There's a starting point here, scroll down to the 6th post.

    Feel free to contribute the end result to E4K! :-)

  • edited December 2015

    Thanks davidnhutch!

    Not really sure if this will format correctly, but I am not Markdown fluent.

    Here is what I ended up with, which works for me:

    module MyMacro
      include RBA
      ly = RBA::Application::instance.main_window.current_view.active_cellview.layout
      layer = 120
      datatype = 0
      topcell = "RET_SOI_B"
      input = ly.layer_indices.find { |li| lp = ly.get_info(li); lp.layer == layer && lp.datatype = datatype }
      input || raise("Input layer not found")
      si = ly.cell(ly.cell_by_name(topcell)).begin_shapes_rec(input)
      texts = 0
      # Otherwise, display its string and xy location
      while !si.at_end? 
        if si.shape.is_text? # If it's not a text then skip it
           bbox = si.shape.bbox.transformed(si.trans)
           string = si.shape.text_string
           texts += 1
           puts "#{texts}, #{topcell}, #{layer}\\#{datatype}, #{string}, #{'%.3f'%(bbox.center.x*ly.dbu)},#{'%.3f'%(bbox.center.y*ly.dbu)}"
  • edited December 2015

    Thanks jmhutchi, it's good. I added it to the latest E4K on sourceforge, with you noted as the author (though I made some minor changes).

Sign In or Register to comment.