It looks like you're new here. If you want to get involved, click one of these buttons!
So I am adding new shapes to the layout
is there a way by ruby too keep track of these new added shapes.
Or just in general get the new added shapes.
Maybe you can assign the current time (Time.now) to a user property using the set_property method of the Shape class??? Never used properties but should be feasible...
Well, you can simply keep the new shapes (Shape objects) in a Ruby array or other object ...
Are you going to manipulate them or what's the plan?
Idea is to get the newly created shapes , selected then process further in Ruby
I am following the example in this thread
Here is my current code for testing purposes based on the above thread
the lv.object_selection = [ p ] deletes the shape, not select
app = Application.instance
# Get a handle on the main window and the current view
mw = app.main_window
lv = mw.current_view
if lv == nil
raise "No view selected. Choose File > New layout, and run this again."
# Get a handle on the layout
ly = lv.active_cellview.layout
dbu = ly.dbu
cell = lv.active_cellview.cell
# Define the coordinates
wdt = 25
pt1 = 0 #x1
pt2 = 0 #y1
pt3 = 500 #x2
pt4 = 0 #y2
pts = [RBA::Point.new(pt1/dbu,pt2/dbu),RBA::Point.new(pt3/dbu,pt4/dbu)]
layer_info = LayerInfo.new(9,0)
layer_index = ly.layer(layer_info)
path = Path.new(pts,wdt/dbu)
new_path = cell.shapes(layer_index).insert(path)
p = RBA::ObjectInstPath::new
p.layer = layer_index
p.shape = new_path
p.top = cell.cell_index
p.cv_index = 0
x = lv.object_selection
lv.object_selection = [ p ] #this actually deletes the shape not select
I am wondering whether in the GDS data, shapes'
sequence of creation has any relation to their position
in the local data structure? One might imagine so.
Of course this is not a real "timestamp". But maybe
you could read from the bottom up in the present
structure and get the "last N"?
If I knew the "new shapes" were and were to remain
related, I'd work with a new call, edit-in-place style,
at the present level. You can flatten it later.
Well kick me in the a** Code does work just had too add it to my personal menu
Hmm ... possibilities
Well, no. I'm sorry. The shape sequence is not related to the order of creation. The shape container is not an ordered one.
The shapes are sorted internally for quick region lookup and this order my even change during the lifetime of the shape container. Even if small shape sets show a certain ordered behaviour, the same is not guaranteed for larger shape sets. Properties are one way to add a time stamp (or just an integer for some "generation index"), but these properties will show up in files if you save the layout. I'm not sure if you can create special property keys which are not saved. I need to check this.
BTW: I just tried your code, but to me it works. Maybe you can check if the layer 9/0 has been created but is not shown yet. You can try adding "lv.add_missing_layers" to the end of the "addpath" function.
thanks for the tip adding the lv.add_missing_layers worked.