Not signed in (Sign In) -
## Feeds
Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support. -
- CommentAuthornezrick
- CommentTimeJan 23rd 2018
Hi Klayout team, I'm working on a program in ruby which include the calculation of the density area (a macro I got on your site). The patterns must be selected before running this calculation. But in my program, I do not want any user intervention. So I tried to find a way to select the patterns in a specific layer but I did not find examples in the forum. Could you please give me a short example: - Select the layer on which the patterns are, - Select these patterns Thanks in advance for your help, and thanks for this forum which is of great help. Best regards Eric. -
- CommentAuthorMatthias
- CommentTimeJan 23rd 2018
Hi Eric, you mean to establish a selection of certain shapes? If you have the shapes, you can directly run the density on these shapes rather than first selecting them and then running the computation on selected shapes. The key to this is the `Region` class and it's`area` method. You feed your shapes into the region object and calculate the area using the area method.Matthias -
- CommentAuthornezrick
- CommentTimeJan 24th 2018
Hi Matthias, thanks a lot for your prompt reply. To answer your question, I want to select all polygons of a single layer to know his density area. It's the first time I use Ruby language and I do not know how to proceed. Here is the code I want to modify: active_area=31.200 rayon_active_area=(active_area/2) aire_active_area=(rayon_active_area*rayon_active_area)*3.14 $compute_total_area = MenuAction.new( "Compute total area of selected shapes", "" ) do app = RBA::Application.instance mw = app.main_window lv = mw.current_view if lv == nil raise "No view selected" end total_area = 0.0 lv.each_object_selected do |obj| shape = obj.shape layout = lv.cellview(obj.cv_index).layout if shape.is_polygon? || shape.is_box? || shape.is_path?
polygon = shape.polygon a = polygon.area m = obj.trans.mag * layout.dbu total_area += (a * m * m)/10000 end end RBA::MessageBox.info("Total area", "Transparent area is #{'%.2f' % (total_area/aire_active_area)}%", RBA::MessageBox.b_ok) end Could you please give me your input on how to adapt this code to my need ? Thanks again. Eric -
- CommentAuthorMatthias
- CommentTimeJan 24th 2018
Hi Eric, this code will take the selected shapes, right. But you mentioned you'd like to take the pattern (shapes?) from somewhere else. Where from? The whole layer? Including child cells? How do you know the layer the shapes are supposed to be taken from? How am I supposed to know what you need? I can't read thoughts. Matthias -
- CommentAuthornezrick
- CommentTimeJan 25th 2018
Hi Matthias, sorry, I was not clear enough: - I mentioned 'Pattern' but you can translate by shape (or polygon), - all shapes are merged in the layer 1 (after generating a mapping and flattening the instances), - the cell containing these shapes is named 'Active_area' - the calculation must be applied on the entire layer (layer 1). That will always be the case. - no child cells Let me know if you need further information. Thanks Eric. -
- CommentAuthorMatthias
- CommentTimeJan 26th 2018
Hi Eric, in the DRC feature, that's a two lines `cell("Active_area") # omit this line if you simply want to use "top cell" puts input(1, 0).area` The result will be printed to the console when you run the DRC script in the Macro IDE. Matthias -
- CommentAuthornezrick
- CommentTimeJan 30th 2018
Hi Matthias, thanks a lot. I have included it to my program. That's work perfectly. I have an another question on a different subject: I have a path composed of 3 points (like a 'L'). The size is random. In a loop, I duplicate it with an angle. Each time I duplicate this path, I want to keep the angle of 90° (of the 'L'). Currently, this is not the case with my program. Here is the part on the code: Random=rand(Range)
a = i.to_f * Math::PI * 2.0 / n x1 = (4500000 + Random) * Math.cos(a) y1 = (4500000 + Random) * Math.sin(a) x2 = (Random2+rad) * Math.cos(a) +x1 y2 = (Random2+rad) * Math.sin(a) +y1
path = RBA::Path::new([RBA::Point::new(x1, y1), RBA::Point::new(x2, y2), RBA::Point::new(x2+60000, y2)] , width) cell.shapes(li).insert(path) I know I have to include a calculation for the third point but I did not find it yet. Could please help me on this subject ?* Thanks in advance. Eric -
- CommentAuthorMatthias
- CommentTimeJan 31st 2018
Hi Eric, how about `RBA::Point::new(x1+(y2-y1), y1-(x2-x1))` for the third point? Matthias -
- CommentAuthornezrick
- CommentTimeFeb 2nd 2018
Hi Matthias, with you help, I found the solution: RBA::Point::new(x1 - (50 * Math.sin(a)), y1 + (50 * Math.cos(a))) Thanks a lot. Eric.
1 to 9 of 9 |