AttributeService
Canonical path: NemAll_Python_BaseElements.AttributeService
Service for reading existing attributes definitions and creating new user-defined attributes
Classes:
-
AttributeControlType–Attribute control types
-
AttributeSelectionDialogType–Type of the attribute selection dialog
-
AttributeType–Attribute types
Methods:
-
AddUserAttribute–Add a user attribute
-
GetAllAttributeNames–Get all attribute names
-
GetAttributeControlType–Get the control type of the attribute
-
GetAttributeGuid–Get the attribute GUID by the attribute ID
-
GetAttributeID–Get the attribute ID by attribute name
-
GetAttributeIDByGuid–Get the attribute ID by the attribute GUID
-
GetAttributeName–Get the attribute name
-
GetAttributeType–Get the attribute type
-
GetAttributeUnit–Get the attribute unit
-
GetCurrentAttributeNames–Get the current attribute names from the current document(s)
-
GetDefaultValue–Get the default value of an attribute
-
GetEnumIDFromValueString–Get the enumeration ID from the value string
-
GetEnumValueStringFromID–Get the enumeration value string from the enumeration ID
-
GetEnumValues–Get the enum attribute values
-
GetGroupAttributeIDs–Get the attribute IDs and the name of the attribute groups
-
GetInputListValues–Get the input list values
-
GetUserAttributeFolders–Get the user attribute folders
-
OpenAttributeSelectionDialog–Open the attribute selection dialog
AttributeControlType
Canonical path: NemAll_Python_BaseElements.AttributeService.AttributeControlType
Bases: Enum
Attribute control types
Methods:
-
__getitem__–get the item for a key
__getitem__
__getitem__(key: str | int | float) -> AttributeControlType
get the item for a key
Parameters:
-
key(str | int | float) –value key
Returns:
-
AttributeControlType–value for the key
AttributeSelectionDialogType
Canonical path: NemAll_Python_BaseElements.AttributeService.AttributeSelectionDialogType
Bases: Enum
Type of the attribute selection dialog
eAllAttributes : eInsertAttributes : eProjectAttributes:
Methods:
-
__getitem__–get the item for a key
__getitem__
__getitem__(key: str | int | float) -> AttributeSelectionDialogType
get the item for a key
Parameters:
-
key(str | int | float) –value key
Returns:
-
AttributeSelectionDialogType–value for the key
AttributeType
Canonical path: NemAll_Python_BaseElements.AttributeService.AttributeType
Bases: Enum
Attribute types
Methods:
-
__getitem__–get the item for a key
__getitem__
__getitem__(key: str | int | float) -> AttributeType
get the item for a key
Parameters:
-
key(str | int | float) –value key
Returns:
-
AttributeType–value for the key
AddUserAttribute
staticmethod
AddUserAttribute(
doc: DocumentAdapter,
attributeType: AttributeType,
attributeName: str,
attributeDefaultValue: str,
attributeMinValue: float,
attributeMaxValue: float,
attributeDimension: str,
attributeCtrlType: AttributeControlType,
attributeListValues: VecStringList,
comment: str = "",
maxTextLen: int = 60,
userAttributeFolder: str = "",
modifiable: bool = True,
visible: bool = True,
attributeGuid: str = "",
) -> int
Add a user attribute
Parameters:
-
doc(DocumentAdapter) –Document
-
attributeType(AttributeType) –Type
-
attributeName(str) –Name
-
attributeDefaultValue(str) –Default value or formula (if control type is ATTR_CT_CALCULATE)
-
attributeMinValue(float) –Minimal value
-
attributeMaxValue(float) –Maximal value
-
attributeDimension(str) –Dimension
-
attributeCtrlType(AttributeControlType) –Control type
-
attributeListValues(VecStringList) –List with the allowed attribute values
-
comment(str, default:'') –Comment
-
maxTextLen(int, default:60) –Max text length of a text attribute
-
userAttributeFolder(str, default:'') –User attribute folder
-
modifiable(bool, default:True) –Modify state of the attribute
-
visible(bool, default:True) –Visible state of the attribute
-
attributeGuid(str, default:'') –Attribute GUID
Returns:
-
int–ID of the added user attribute, -1 = not possible to add
GetAllAttributeNames
staticmethod
GetAllAttributeNames(doc: DocumentAdapter) -> list[str]
Get all attribute names
Parameters:
-
doc(DocumentAdapter) –Document
Returns:
-
list[str]–All attribute names
GetAttributeControlType
staticmethod
GetAttributeControlType(
doc: DocumentAdapter, attributeID: int
) -> AttributeControlType
Get the control type of the attribute
Parameters:
-
doc(DocumentAdapter) –Document
-
attributeID(int) –Attribute ID
Returns:
-
AttributeControlType–Control type of the attribute
GetAttributeGuid
staticmethod
GetAttributeGuid(doc: DocumentAdapter, attributeID: int) -> GUID
Get the attribute GUID by the attribute ID
Parameters:
-
doc(DocumentAdapter) –Document
-
attributeID(int) –Attribute ID
Returns:
-
GUID–Attribute GUID
GetAttributeID
staticmethod
GetAttributeID(doc: DocumentAdapter, attributeName: str) -> int
Get the attribute ID by attribute name
Parameters:
-
doc(DocumentAdapter) –Document
-
attributeName(str) –Attribute name
Returns:
-
int–Attribute ID
GetAttributeIDByGuid
staticmethod
Get the attribute ID by the attribute GUID
Parameters:
-
attributeGuid(str) –Attribute GUID as string
Returns:
-
int–Attribute ID
GetAttributeName
staticmethod
GetAttributeName(doc: DocumentAdapter, attributeID: int) -> str
Get the attribute name
Parameters:
-
doc(DocumentAdapter) –Document
-
attributeID(int) –Attribute ID
Returns:
-
str–Attribute name
GetAttributeType
staticmethod
GetAttributeType(doc: DocumentAdapter, attributeID: int) -> AttributeType
Get the attribute type
Parameters:
-
doc(DocumentAdapter) –Document
-
attributeID(int) –Attribute ID
Returns:
-
AttributeType–Attribute type
GetAttributeUnit
staticmethod
GetAttributeUnit(doc: DocumentAdapter, attributeID: int) -> str
Get the attribute unit
Parameters:
-
doc(DocumentAdapter) –Document
-
attributeID(int) –Attribute ID
Returns:
-
str–Attribute unit
GetCurrentAttributeNames
staticmethod
GetCurrentAttributeNames(doc: DocumentAdapter) -> list[str]
Get the current attribute names from the current document(s)
Parameters:
-
doc(DocumentAdapter) –Document
Returns:
-
list[str]–Current attribute names from the current document(s)
GetDefaultValue
staticmethod
GetDefaultValue(doc: DocumentAdapter, attributeID: int) -> int | float | str
Get the default value of an attribute
Parameters:
-
doc(DocumentAdapter) –Document
-
attributeID(int) –Attribute ID
Returns:
-
int | float | str–Default value of the attribute
GetEnumIDFromValueString
staticmethod
Get the enumeration ID from the value string
Parameters:
-
attributeID(int) –Attribute ID
-
valueString(str) –Value string
Returns:
-
int–Enumeration ID
GetEnumValueStringFromID
staticmethod
Get the enumeration value string from the enumeration ID
Parameters:
-
attributeID(int) –Attribute ID
-
enumID(int) –Enumeration ID
Returns:
-
str–Enumeration value string
GetEnumValues
staticmethod
GetEnumValues(doc: DocumentAdapter, attributeID: int) -> list[str]
Get the enum attribute values
Parameters:
-
doc(DocumentAdapter) –Document
-
attributeID(int) –Attribute ID
Returns:
-
list[str]–Default attribute value
GetGroupAttributeIDs
staticmethod
GetGroupAttributeIDs(
ele: BaseElementAdapter,
attributes: list[tuple[int, int | float | str]],
excludeHidden: bool,
) -> list[tuple[str, list[int]]]
Get the attribute IDs and the name of the attribute groups
Parameters:
-
ele(BaseElementAdapter) –Element for the attributes
-
attributes(list[tuple[int, int | float | str]]) –Attributes of the element
-
excludeHidden(bool) –Exclude the hidden attributes
Returns:
-
list[tuple[str, list[int]]]–Group name, group IDs
GetInputListValues
staticmethod
GetInputListValues(doc: DocumentAdapter, attributeID: int) -> list[str]
Get the input list values
Parameters:
-
doc(DocumentAdapter) –Document
-
attributeID(int) –Attribute ID
Returns:
-
list[str]–Attribute input list values
GetUserAttributeFolders
staticmethod
Get the user attribute folders
Returns:
-
list[str]–User attribute folders
OpenAttributeSelectionDialog
staticmethod
OpenAttributeSelectionDialog(
doc: DocumentAdapter, dialogType: AttributeSelectionDialogType
) -> int
Open the attribute selection dialog
Parameters:
-
doc(DocumentAdapter) –Document
-
dialogType(AttributeSelectionDialogType) –Dialog type
Returns:
-
int–Attribute ID