Skip to main content
Question

How to read DGN tags intelligently ?


Forum|alt.badge.img
Hi,

 

 

Most of the docs on DGN tags are unfortunately about writing them. But I need to read them intelligently.

 

 

Tags are exposed as the list variable tag_names{}, which either contains the tag key names, or the tag values, dependent on the "Output Tags As Text" setting in the DGN reader.

 

 

And the values in the tag_names{} list is accessed used a numeric index, not the key names.

 

 

If one needs to build some logic to handle the situation, where individual objects has vastly individual tag assignments, both name wise and index wise, how does one go about that ?

 

 

Intuitively I would loop thru and test the key names, and assign the corresponding value to a variable of my choice. But as I see it, this is not possible in FME 2014 !?

 

 

Any experiences and thoughts and suggestions on - or alternatives to - this issue ?

 

 

Cheers

 

Lars I

 

 

Forum|alt.badge.img
That's of couse "igds_tag_names{}" :-)

david_r
Evangelist
  • August 29, 2014
Hi,

 

 

did you look at the ListSearcher?

 

 

If that doesn't suffice, handling this with a PythonCaller can be pretty efficient.

 

 

David

Forum|alt.badge.img
Hi David,

 

 

Are there any examples available showing how to use Python to read DGN tags ?

 

 

I'm not familiar with Python, it's still on my "to-do", so I need an intro :-)

 

 

Cheers

 

Lars I

david_r
Evangelist
  • August 29, 2014
Hi,

 

 

the tags are represented as lists in FME. So you can read them into a Python list object and print them out like this:

 

 

tag_list = feature.getAttributes('igds_tag_names{}')

 

for n, tag in enumerate(tag_list):

 

    print 'Tag number %d has value %s' % (n, tag)

 

 

This is a good staring point for how to use FME and Python together: http://fmepedia.safe.com/articles/How_To/Python-and-FME-Basics

 

 

David

Forum|alt.badge.img
Hi David,

 

 

This example illustrates precisely my hang-up, unfortunately.

 

 

Tags are defined as name/value pairs, not an anonymous list. So the index number is of no value.

 

 

Do the entries of the list in question contain both the tag name and the tag value by any chance ? I.e. can I do this:

 

 

tag_list = feature.getAttributes('igds_tag_names{}')

 

for name, tag in enumerate(tag_list):

 

    print 'Tag named %s has value %s' % (name, tag)

 

 

Cheers

 

Lars I

takashi
Contributor
Forum|alt.badge.img+17
  • Contributor
  • August 29, 2014
Hi,

 

 

If the list consists of iteration of name and value pairs - such as {name1, value1, name2, value2, name3, value3,...}, this is a possible way.

 

-----

 

tag_list = feature.getAttributes('igds_tag_names{}')

 

for name, value in zip(tag_list[0::2], tag_list[1::2]):

 

    print 'Tag named %s has value %s' % (name, value)

 

-----

 

 

Takashi

Forum|alt.badge.img
Hi Takashi,

 

 

Great, thanks.

 

 

I'll see if I can determine whether this is the case.

 

 

Cheers

 

Lars I

Reply


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