Skip to main content
Question

Python: Create FMENull feature with Name and Traits

  • February 3, 2020
  • 2 replies
  • 31 views

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?
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

takashi
Celebrity
  • 7843 replies
  • 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
  • Author
  • 388 replies
  • February 4, 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

Thank you @takashi for your wonderfull solution! 

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