Skip to main content
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

 

 

That's of couse "igds_tag_names{}" 🙂
Hi,

 

 

did you look at the ListSearcher?

 

 

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

 

 

David
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
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
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
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
Hi Takashi,

 

 

Great, thanks.

 

 

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

 

 

Cheers

 

Lars I

Reply