end_segments() and start_segments() function related

edited April 2021 in Python scripting

Hello, Matthias & sirs

I found the end_segments() and start_segments() functions might re-build the sequence for the " edges object " in an edge set?

for example: ( part of the script as below)

target = pya.Region( layout.top_cell().begin_shapes_rec(metal)).with_angle(0, 45 , False)
(I get an edgepair set, totally 233 pairs)

edge_1 = target.first_edges().end_segments(1000,0.0)
(then I try to gain every end part the first_edge with 1 um length)

  • then I found target.first_edges[x] is exactly equal to the first part of target[x] for all 233 object )
  • but the edges sequence might be changed in edge_1, in my case, the dedicated target[101] moved to edge_1[157], it seems random
  • result: target[101] = (930972 , 1809672 ; 930972 , 557960)
  • result: edge_1[157] = (930972 , 558960 ; 930972 , 557960)

Not sure it is normal situation, or due to edges too many ?
Sorry, I am not used to this typing interface , hope my explanation is ok to read... thanks all

Deal patterns with Klayout Python function is funny ;)

Comments

  • @Vincent Lin The order of first_edges is not defined. It's an edge "set" which means it's a non-ordered collection. This is specifically true for hierarchical mode, when there isn't even a linear set of edges.

    If you want to keep the order, you'll have to iterate over the edge pairs with Python and extract the first edge in Python. This will be slower than the "first_edges" method.

    Matthias

  • @ Matthias
    Thanks for your explanation :)

Sign In or Register to comment.