Skip to main content
Question

Python: Create FMENull feature with Name and Traits


lars_de_vries
Forum|alt.badge.img+10

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?

2 replies

takashi
Influencer
  • February 3, 2020

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


lars_de_vries
Forum|alt.badge.img+10
takashi wrote:

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.

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings