simetrix.Property

class simetrix.Property

Bases: object

Data structure representing a property used by Schematic and Element objects.

For graph properties see GraphProperty

A property is a combination of a name and a value, where property values are represented as strings. Property objects are used with schematic Element objects and with Schematic objects.

Property objects store their data by value and do not reference the SIMetrix object that holds the property. So for example if a value of a property object is changed, the SIMetrix object that holds that property will not change. However, it is possible to call the Element.setPropertyObject() method to update an actual Element property with the values stored in the Property object.

The Property class has a number of properties itself. That is Python-language properties. Some of these properties have both “getters” and “setters”, in other words they can be assigned as well as read.

Examples

In the following example, we list all the properties on a single instance, ‘Q6’.

import simetrix as sx

schem_file = "%DOCSPATH%/SIMetrix/Examples-93/SIMetrix/General/AMP.sxsch"
schem = sx.openSchematic(schem_file)

# Get instances with Reference designator 'Q6'. (There would ordinarily be only one)
refs = schem.instances('Ref', 'Q6')

# Iterate through instances
for ref in refs :
   # Get all properties owned by instance
   props = ref.properties()
   for prop in props :
       # print name, value and whether or not visible
       print(prop.name, prop.value, "visible=", "YES" if prop.visible else "NO")

In this example we change a value property to ‘q2n2222’ and copy attribute flags from the Ref property. This will position the value property on the same side of the symbol as the Ref property. Note this is a complicated way to change a property value. Usually you would use the Element.setProperty() method to edit a property value directly. The example below demonstrates how to manipulate properties using the Property class.

import simetrix as sx

schem_file = "%DOCSPATH%/SIMetrix/Examples-93/SIMetrix/General/AMP.sxsch"
schem = sx.openSchematic(schem_file)

inst = schem.instances('REF', 'Q2')

# Change value property to 'q2n2222' and copy attribute flags from
# Ref property

if len(inst)>0 :
    # Get reference and value property
    propref = inst[0].prop('REF')
    prop = inst[0].prop('value')

    # Check properties are valid
    if propref.valid and prop.valid :

        # Get value
        prop = inst[0].prop('value')
        # Change value
        prop.value = 'q2n2222'
        # copy flags from Ref property
        prop.flags = propref.flags()

        # set new property value and attributes
        inst[0].setPropertyObject(prop)
    else :
        print("Instance doesn't have that property")

else :
    print("Cannot find instance REF:Q2")

Methods

Attributes

fixedPosition

Read-only; True, property position is fixed, False, the property position is variable set according to Property.normpos and Property.rotpos values

flags

Read-write; Integer flags value of the property.

name

Read-only; the name of the property.

normpos

Read-write; Property position for normal orientation.

protected

Read-only; True if the property is protected.

rotpos

Read-write; Property position for rotated orientation.

valid

Read-only ; True if property is valid, that is if it exists.

value

Read-write; the value of the property as a string.

visible

Read-write; True if property is visible.

xpos

Read-only; The x-position of the property.

ypos

Read-only; The y-position of the property.

property fixedPosition: bool

Read-only; True, property position is fixed, False, the property position is variable set according to Property.normpos and Property.rotpos values

property flags: int

Read-write; Integer flags value of the property. Flags hold the various attributes of the property such as visibity and position options. For full details, see Prop command.

property name: str

Read-only; the name of the property.

property normpos: int

Read-write; Property position for normal orientation. 0,Left, 1,Top, 2,Right, 3,Bottom. Ignored if Property.fixedPosition() is True.

property protected: bool

Read-only; True if the property is protected. This means the property is defined in the symbol and cannot be changed in the schematic.

property rotpos: int

Read-write; Property position for rotated orientation. 0,Left, 1,Top, 2,Right, 3,Bottom. Ignored if Property.fixedPosition() is True

property valid: bool

Read-only ; True if property is valid, that is if it exists. Otherwise False.

property value: str

Read-write; the value of the property as a string. Can also be set to a new value:

prop.value = "my new value"

As noted above, setting the value changes the value stored in the local Python object; it does not affect the SIMetrix object that owns the property. Use Element.setPropertyObject() to update the SIMetrix object.

property visible: bool

Read-write; True if property is visible.

property xpos: int

Read-only; The x-position of the property. Only valid if Property.fixedPosition() is True.

property ypos: int

Read-only; The y-position of the property. Only valid if Property.fixedPosition() is True.