Annotations questions

edited July 2015 in General

Matthias,

Two questions.

(1)

I wonder if there is a way to save a layout with its annotations (rulers)?

I know (at least, I think) annotations are not allowed in GDS/OAS spec, so I think the answer is no. But often you surprise me with some clever solution that already exists.. :-) so I thought it worth asking.

(2)

I would like to make labeled arrows pointing to things. For instance imagine two arrows pointing to two boxes, that label the arrows with the text "1st box" and "2nd box". The labels are on the arrows themselves, and the arrows point to the boxes.

To do this, some options:

A. create two new rulers, arrow type, and set the text to "1st box" and "2nd box" respectively. But this is unweildy to create a whole ruler just to store one label text.

B. create one custom ruler, arrow type, and set the text to "1st box". Place the arrow. Change the settings for that same ruler to "2nd box". Place the second arrow (fortunately, the first annotation doesn't change from what it was when you placed it). But this too is unweildy.

C. create one custom ruler, arrow type, and create a script that asks for a string and then does Application.instance.set_config("ruler-templates",foo), where foo is the string. So you keep changing the config setting for that ruler. But then you have to read in ALL the rulers before you start, and carefully just change the one you want before writing all the rulers back to the config file.

C is doable, and the best option above, but perhaps there is a better way?

Thanks,
David

Comments

  • edited November -1

    Hi David,

    Regarding 1.): you can't save them to GDS or the other layout formats, but the "sessions" are supposed to handle that. Sessions keep all the setup, including rulers, images, views, layer properties and so forth. All except the layouts itself. It's scriptable too (see MainWindow#save_session and MainWindow#restore_session)

    For 2.): the C approach is not quite bad, but the "ruler-templates" config keeps all templates and there is certain risk to damage the setup. Rulers are individual objects, so basically you can modify them. LayoutView#each_annotation_selected gives you the selected rulers. But modification is difficult: right now you can only clear and rebuild the annotations using LayoutView#insert_annotation:

    lv = RBA::LayoutView::current
    
    annot = []
    lv.each_annotation do |a|
      adup = a.dup
      annot << adup
      found = nil
      lv.each_annotation_selected { |s| found ||= s == a }
      if found
        adup.fmt = "Selected one"
      end
    end
    
    lv.clear_annotations
    annot.each { |a| lv.insert_annotation(a) }
    

    But this is quite ugly and as a negative side effect, all rulers are unselected.

    Matthias

  • edited November -1

    Huh, I didn't realize annotations were saved in the session. Thanks.

    Also the code works great, thanks! Yes a tad ugly, but functional. I'm sure RBA can handle this with some syntactic sugar in some future version...

Sign In or Register to comment.