Skip to main content

I am working on a workspace that receives a list of previously unknown attributes and their values. They come as a list of attributes: '_list{}.Property' and '_list{}.Value'. These sets need to become GeometryTraits on an FMENull geometry. Usually I would use a GeometryPropertySetter to create those traits, but since it is unknown upfront how many features these lists contain, I want to use a PythonCaller to loop through the list and set the traits.

 

 

I seem neither to be able to create an FMENull feature, nor to set it's geometry name or traits. Can anyone help me with a working code snippit?

Hi @lars_de_vries, hope this helps.

import fmeobjects
def processFeature(feature):
    geom = fmeobjects.FMENull()
    geom.setName('name')
    properties = feature.getAttribute('_list{}.Property')
    values = feature.getAttribute('_list{}.Value')
    for p, v in zip(properties, values):
        geom.setTrait(p, v)
    feature.setGeometry(geom)

http://docs.safe.com/fme/html/fmepython/api/fmeobjects/geometry/_general/fmeobjects.FMEGeometry.html#fmeobjects.FMEGeometry


Hi @lars_de_vries, hope this helps.

import fmeobjects
def processFeature(feature):
    geom = fmeobjects.FMENull()
    geom.setName('name')
    properties = feature.getAttribute('_list{}.Property')
    values = feature.getAttribute('_list{}.Value')
    for p, v in zip(properties, values):
        geom.setTrait(p, v)
    feature.setGeometry(geom)

http://docs.safe.com/fme/html/fmepython/api/fmeobjects/geometry/_general/fmeobjects.FMEGeometry.html#fmeobjects.FMEGeometry

Thank you @takashi for your wonderfull solution! 

I tried something similar, but couldn't get it figured out.

Reply