Text object properties

edited December 2009 in KLayout Support
Hi Matthias,

It seems that the Orientation and Text size functions in Object Properties window didn't work.

I tried to modify these two functions in editor mode and apply the change, however nothing happened in the main window, could you please help to confirm it?

My environment: klayout v0.19.2 on MDK 9.2 amd64 with qt4 v4.3.1


Is it possible to add an info to display the [current number/total selected] in Object Properties window if selected more than two objects?

For example: If two objects are selected, when the properties window is opened, it shows [1/2], after pressed Next button, it switchs to next object and shows [2/2].

Best Regards,
--
chi-hsiang-hung

Comments

  • edited November -1

    Hi,

    In order to make the text objects show up in the given orientation and size you need to select a vector font and check the "Apply text scaling and orientation" check box on the "Display" page in the "Setup" dialog. By default, text objects show up in a fixed orientation and size. That is probably why you don't see any effect.

    Best regards,

    Matthias

  • edited December 2009
    Hi Matthias,

    Yes, I followed the steps to change the display font from Default to others(Sans serif or Gothic) in Setup window, and the text modified to the one I specified.

    Another issue which is not so important, when we select several text objects and try to change the properties, is there a function like "apply modified to all selected"? so we can change the Text Size and Orientation at one time and would not effect the Text and Position.

    Best Regards,
    --
    chi-hsiang-hung
  • edited January 2010

    Hi,

    applying one change to multiple objects in the selection is not straightforward unfortunately for internal reasons. That is something to go into some "search & replace" functionality.

    For your use case however as usual there is a script to do this:

    class MenuAction < RBA::Action
      def initialize( title, shortcut, &action ) 
        self.title = title
        self.shortcut = shortcut
        @action = action
      end
      def triggered 
        @action.call( self ) 
      end
    private
      @action
    end
    
    $change_texts = MenuAction.new( "Change Texts", "" ) do 
    
      app = RBA::Application.instance
      mw = app.main_window
    
      lv = mw.current_view
      if lv == nil
        raise "No view selected"
      end
    
      # Begin a transaction for undo/redo
      lv.transaction("Change text properties");
    
      # An array holding the new texts (shape container/text pairs)
      new_texts = []
    
      # First, create the new texts and delete the existing ones
      lv.each_object_selected do |sel|
    
        if !sel.is_cell_inst? 
    
          shapes = lv.cellview(sel.cv_index).layout.cell(sel.cell_index).shapes(sel.layer)
          if shapes.is_valid?(sel.shape) && sel.shape.is_text?
    
            # get and erase the current object
            text = sel.shape.text
            shapes.erase(sel.shape)
    
            # change the text orientation to r0 (trans.disp defines the
            # text position and must be maintained)
            text.trans = RBA::Trans.new(RBA::Trans::r0, text.trans.disp) 
    
            # change the text size to 1000DBU
            text.size = 1000
    
            # change the text string (appending a "*")
            text.string = text.string + "*"
    
            # store the new object together with a reference to the shape container
            new_texts.push([shapes, text])
    
          end
    
        end
    
      end
    
      # Insert the new shapes (doing that in a second step avoids problems 
      # when multiple instances of the same shape are selected)
      new_texts.each do |p|
        p[0].insert(p[1])
      end
    
      # After that we must cancel all operations since the selection
      # is no longer valid.
      lv.cancel
    
      # Commit the operation 
      lv.commit
    
    end
    
    app = RBA::Application.instance
    mw = app.main_window
    
    menu = mw.menu
    menu.insert_separator("tools_menu.end", "name")
    menu.insert_item("tools_menu.end", "change_texts", $change_texts)
    

    This sample resets the text orientation to r0 and the text size to 1 micron. For demonstration, this script also adds a "*" to the string. For the actual application, this script should be adjusted accordingly.

    Best regards,

    Matthias

  • edited January 2010
    Hi Matthias,

    I tried to run this code with some modification, and the program is crashed on the line "lv.cellview(sel.cv_index).cell.shapes(sel.layer).replace(sel.shape, text)", even I almost remark all the lines.

    The error message is "Segmentation fault", and I have no idea how to fix it, could you please give me a hint to solve this issue?

    The test platform is klayout v0.19.2, ruby 1.8.6

    BTW, is it possible to popup an interactive window that we could input the orientation/size/text in it and apply the input value in the change_texts code?
    maybe it would be better for operation.

    Best Regards,
    --
    chi-hsiang-hung
  • edited November -1

    Hi,

    the segmentation fault was probably a bug: when a text was selected in a child cell, the script did not work properly. I changed the code above accordingly.

    Currently there is not a good method to provide user interfaces with ruby scripts. Therefore this script does not provide a dialog right now.

    Best regards,

    Matthias

Sign In or Register to comment.