Skip to content

Python 3 and GDS shape properties #109

@klayoutmatthias

Description

@klayoutmatthias

This bug refers to https://www.klayout.de/forum/comments.php?DiscussionID=1048.

The following code won't retrieve the shape property with key 2 on the attached layout with Python 3.

lv = pya.LayoutView.current()
for obj in lv.each_object_selected():
  print(repr(obj.shape.property(2)))

Reason: the strongly typed keys changed to 64 bit in Python 3 on Windows. On Linux, 32 and 64bit are equivalent (the internal type is long which is == long long). Still the problem exists because of the Windows-induced strong typing.

This is a (slow) workaround:

# Don't do this too often:
key = pya.Expression.eval("2")

lv = pya.LayoutView.current()
for obj in lv.each_object_selected():
  print(repr(obj.shape.property(key)))

p2.gds.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions