Enum Attribute Index not correct [Gelöst]

Schlagworte:
  • Bug
  • Attribute
  • Attributeservice

I want to copy the attribute from one object to another, this does work for all Enum types but for this one not. For this, I readout the attribute list of object 1 and set the attr_list for object 2 like:

attr_list.add_attribute(attr_id, attr_value) # 209, "Straßen, Wege, Plätze"

This will not work and leave the attribute unset in the attribute UI.

Reading out the index of this Enum like:

value_list = AllplanBaseElements.AttributeService.GetEnumValues(doc, attr_id)
index = value_list.index(attr_value)
will give me "68".
This is strage because the AttributeManager say it should be "80".
and if I set
attr_list.add_attribute(attr_id, attr_enum_index) # 209, 80
This works! The Attribute is set correct in the UI....
What I am missing, or what could cause this problem?

Anhänge (1)

Typ: image/png
23-mal heruntergeladen
Größe: 34,05 KiB

Lösung anzeigen Lösung verbergen

Hi!

The reason why

>>> value_list = AllplanBaseEle.AttributeService.GetEnumValues(doc, 209)
>>> value_list.index('Streets, paths, squares')
63
Returns what it returns, is because the enums of attribute @209@ are not numbered consecutively! For example, enum with the number 48 is not present. To obtain the index of a certain value inside an enum attribute, use:
>>> AllplanBaseEle.AttributeService.GetEnumIDFromValueString(209, 'Streets, paths, squares')
80

Best,
Bart

Hi!

The reason why

>>> value_list = AllplanBaseEle.AttributeService.GetEnumValues(doc, 209)
>>> value_list.index('Streets, paths, squares')
63
Returns what it returns, is because the enums of attribute @209@ are not numbered consecutively! For example, enum with the number 48 is not present. To obtain the index of a certain value inside an enum attribute, use:
>>> AllplanBaseEle.AttributeService.GetEnumIDFromValueString(209, 'Streets, paths, squares')
80

Best,
Bart