Getting Attribute Values
- Last UpdatedJan 28, 2025
- 3 minute read
Basic Mechanism
The attributes available on for a DbElement will depend on its type, for example: a site will have different attributes to a branch. For this reason attributes are accessed through generic methods rather than specific methods. These generic methods pass in the identity of the attribute being queried (a DbAttribute object). There are separate methods for each attribute type (int, double etc), plus separate methods for single values or arrays.
for example:
using ATT=Aveva.Core.Database.DbAttributeInstance;
double length=myEle.GetDouble(ATT.XLEN);
This call returns the value of attribute XLEN. If 'myEle' is not a BOX then an exception will be raised.
If there is any doubt as to whether 'myEle' is a BOX or not, then there are a set of methods that return false if the attribute does not exists.
for example:
using ATT=Aveva.Core.Database.DbAttributeInstance;
double length;
if (!myEle.GetValidDouble(ATT_XLEN,length)) {
// handle error in some way
}
In addition there is a IsAttributeValid() method that can be used to test if an attribute is valid or not.
The basic mechanism works for all attributes including UDAs and pseudo attributes.
The attribute types supported are:
|
int, int[] |
|
double, double[] |
|
bool, bool[] |
|
string, string[] |
|
DbElement, DbElement[] |
|
DbElementType, DbElementType[] |
|
DbAttribute, DbAttribute[] |
|
Position |
|
Direction |
|
Orientation |
|
Expression |
Note:
The methods that are called GetAttribute, GetAttributeArray are the 'getattribute' methods that return DbAttributes. Similarly the GetElement, GetElementArray methods are the 'getattribute' methods that return DbElements. This is confusing since GetElement is also the name of the method to return a DbElement given a name. We may change the names of these in the future.
List of Valid Attributes
There are two lists of valid attributes:
-
The list of system attributes. Typically these attributes can be queried and set. These can be queried using the GetAttributes() method.
-
There is a list of pseudo attributes that may be queried. Typically this list is large, running into the hundreds. This list can be obtained via the PSATTS attribute. N.B. querying PSATTS can be slow.
Related pseudo attributes are:
|
Attribute Name |
Data Type |
Description |
|
ATTLIST |
DbElementType[] |
List of all visible attributes for element |
|
ATTRAW |
DbElementType[] |
List of raw attributes |
|
PSATTS |
DbElementType[] |
List of pseudo attributes |
|
RLIS |
DbElementType[] |
List of rules set |
|
UDALIS |
DbElementType[] |
List of UDAs |
|
UDASET |
DbElementType[] |
List of UDAs set |
Qualifier
Many attributes take a qualifier. The qualifier is the extra information to make the query. Examples of where a qualifier is used are:
-
Querying a ppoint position (PPOS) requires the ppoint number
-
The ATTMOD attribute can be used to query when an attribute was modified but it needs to be given the identity of the attribute.
-
A direction/position may be queried with respect to another element
The definition of what pseudo attributes take what qualifier is described. Refer to Pseudo Attributes for further information.
The DbQualifier class represents the qualifier. This can hold any type of qualifier, i.e. int, double,string, DbElementType, Attribute, position, direction, orientation. It can hold multiple qualifier values, although few current attributes require multiple valued qualifiers. There is a separate method to set the WRT element.
There is a set of query routines that take a qualifier as an extra argument.
for example: to query the bore of ppoint 1:
DbQualifier qual=new DbQualifier();
qual.Add(1);
double bore=myele.GetDouble(ATT.PPBO, qual);
Getting an Attribute as a Formatted String
If the attribute value is to go onto a form then the value must be formatted correctly. The correct formatting is not always obvious or available. Therefore there are special methods to return any attribute as a formatted string. This will format the attribute into the form that would appear at the command line. For example if the attribute is a position and we are working in finch unit, then something like 'W 39'4.7/16 N 59'0.85/128 U 4'0.31/128' might be returned.
The method to do this is GetAsString().
Note:
There is no generalized method for setting an attribute from a string.