icon

Support Forum

[Frage] Create attributes


Hi,
I am trying to create attributes with the Python Api. At the moment I am failing because the required inputs are not documented.
This is my code:

attr_list.append(attr_service.AddUserAttribute(
doc,
attributeType= attr_type,
attributeName= attributeName,
attributeDefaultValue= "",
attributeMinValue= "0",
attributeMaxValue= 255,
attributeDimension= "",
attributeCtrlType= attr_control_type,
attributeListValues= attr_value
))

This works for a string attribute.
However, it does not work as desired for integers or doubles. I want to achieve that there is no preset for the min and max value and no default value is set.
For a string attribute, no default value is set for attributeDefaultValue= “”. For an integer or double, the value is 1.
Does anyone have a suggestion on how to create the attributes cleanly?

Greetings
Jan

Brücken und Ingenieurbau
VIC Planen und Beraten GmbH

https://www.vic-gmbh.de/

Hi Jan,

I tried your code and for me it seems there is a bug in creating an attribute, at least I could reproduce it for a double attribute, but not for an integer.

I tried this

    attr_id = AllplanBaseElements.AttributeService.AddUserAttribute(
        doc                   = doc,
        attributeType         = AllplanBaseElements.AttributeService.AttributeType.Integer,
        attributeName         = "MyCustomIntegerAttribute",
        attributeDefaultValue = "",
        attributeMinValue     = 0.0,
        attributeMaxValue     = 0.0,
        attributeDimension    = "",
        attributeCtrlType     = AllplanBaseElements.AttributeService.AttributeControlType.Edit,
        attributeListValues   = AllplanUtility.VecStringList(),
    )

Note, that the default value must be a string, but min and max values are doubles.

For a floating point number, the call would be similar, but the min value is always set to 1.0 and max to 9999.0. We need to fix it.

Best,
Bart