ce.getAttribute returns wrong street width

05-13-2013 02:56 PM
New Contributor
If I use ce.getAttribute to get a street width, it will return a wrong value under these circumstances:

1. Select a street
2. Change the default street width value to something else in the inspector (i.e. 8 to 20 or whatever)
3. Change the street width back to "default value" in the inspector
4. if I use ce.getAttribute after this, it *always* pulls the street width value that I entered as a user value, no matter what the default is. For example, if my default street width is 8, and I changed it as a user value to 16, then selected "use default value" in the inspector (so back to 8), the streetWidth attribute is still reported to me as "16" if I use ce.getAttribute( shape, '/ce/street/streetWidth' ). It does this even after closing and reopening CE!

Any thoughts?

Tags (3)
0 Kudos
5 Replies
Frequent Contributor II

My last post here : http://forums.arcgis.com/threads/82684-Graph-object-export-scripts

answers your question in a slightly different contect.

Ok ?
0 Kudos
New Contributor
Thanks, I read that thread and it did make things more clear.


Is there a way to delete the user attr after it is set then? That is, to restore the attribute to its state before the user changed it? Or is the answer to just be careful when using python to pull streetWidth (or other attribute values), in the sense that if a user, in the gui, makes a user attribute and then selects "use default" in the inspector, you are just going to have to live with wrong values? I could definitely see problems down the line with that, especially in a multi-user environment (say you have a person manually adjusting streetWidths, then switching back and forth from default to user).

I suppose one way to handle the issue is to tell users to never set a something back to default!
0 Kudos
Frequent Contributor II
Hi !

There's no way to get rid of that created attribute any more.

The only way to handle this is to create a heuristic which checks the attr SOURCE first.

Means you have to handle the case where the user may have set something once ( thus that value is stored as an attr ), though then goes back to the SOURCE = DEFAULT.


if ce.getAttributeSource(..) == "DEFAULT" :
    return 8 ( or whatever the default is ), return this as hardcoded value
if ce.getAttributeSource(..) == "USER" :
    return value of getObjectAttr(..)

Ok ?

0 Kudos
New Contributor
That seems like a sensible solution, though how do I actually use the result of getAttributeSource to check for Default or
User? Unlike most of the other "get" functions that return a STR type that I can easily check, this seems to return a var
of type: <type 'com.procedural.ceattribute.ScriptInterfaceAttributes$AttributeSource'>

So when I use "DEFAULT" as the string to check against in the IF statement, it never resolves to true.

Yet, when I call print ce.getAttributeSource(...), the correct string DEFAULT or USER prints to the log?

Thanks again for your help on this, Matthias. For now, we're just making sure that street segments aren't switched back to default
from user, but it would be good to have a working failsafe in place.

0 Kudos
New Contributor II

You need to convert it to a string first using 'str'


Souce_Type = ce.getAttributeSource(..)

if str(Souce_Type) == 'DEFAULT' :

        return 8

if str(Souce_Type) == "USER" :

     return value of getObjectAttr(..)

0 Kudos