Not signed in (Sign In)

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorjuras
    • CommentTimeApr 2nd 2018
     
    I am trying to access GDSII user properties through Python script. When I open gds file containing USERPROP and USERATTR records I can see in object properties that it has for example property #2 with some string. Unfortunatelly, when I try to read this property through Shape propetry() function, it returns None as if there was no such property.

    My call:
    for obj in selection:
    print(obj.shape.property(2))

    Also when I try to create new property with obj.shape.set_property(5, 'aaa') it creates the property as #l5 instead of #5 and it is not stored into GDS file upon save

    Is this a bug or just my misunderstanding?

    Thanks for any comments/suggestions

    Juras
    • CommentAuthorMatthias
    • CommentTimeApr 6th 2018
     

    Hi Juras,

    thanks for this report. Your approach is the right one, but there is an issue with 64bit Python 3. The reason is that properties are basically strongly typed (for OASIS) and there is a distinction between 32bit and 64 bit integer keys. Python 2 used to use 32 bit integers which made them compatible with GDS. Python 3 uses 64 bits by default and the key type is no longer compatible.

    I have created a ticket for this: https://github.com/klayoutmatthias/klayout/issues/109.

    The workaround is to use a different way to create the key:

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

    "Expression.eval" is slow, so you should avoid creating the key too often. Once is enough.

    I'll fix the issue in the next minor release.

    Thanks and best regards,

    Matthias