четверг, 3 января 2019 г.

PseudoAttributes (simplified process)

Hi, my dear readers.
Today I want to write to you about pseudo attributes in Aveva E3D/PDMS.

If we look at the help, these are following intro: 

In addition to the attributes stored on the database, there are a large number of pseudo attributes. The value of pseudo attributes is calculated at the time of making the query.
For example, the CUTLENGTH attribute on SCTN elements is a pseudo attribute calculated at the point of doing the query.
There is a lot of functionality presented via pseudo attributes. Currently there are over 1200 pseudo attributes.
Since the value of a pseudo attribute is calculated from other attributes, it is not generally possible to set their value directly. 
Ok. But how create your own pseudo-attributes?
You can read here http://smfd.ru/blog/aveva-pseudo-attributes and in help 
section -> .NET Customisation -> Database Interface -> Events -> Adding Pseudo Attribute Code

After reading all this, it turns out that for each pseudo-attribute you must write separately C# code. Sad end ;)

To make the task easier  let's create more universal tool.

And step by step.

Creating a pseudoattribute

You need to create a UWRL world for storing the UDA and the UDA itself. The attribute is called, for example, C-CStandard

 









 

When creating a UDA, you must set the Pseudo Attribute field to True.

Placement of configuration files.

In the folder where the program is installed exist the archive Samples, in which you can find an example of creating PA (pseudo attribute) - ExamplePseudoAttribute.cs. However, in this case, it is necessary to correct the source code each time when you need add new PA.
The following setting performs the above task based on the setup xml file.

Setup order:
1. Register the settings in the DesignAddins.xml file, which is locally in the program folder, or in the network folder at the address of the variable CAF_ADDINS_PATH.



2. The attached PseudoAtt.dll file must be placed (copied) in the folder with the installed program. This can be done by performing a copy manually or copying from the network folder when the network shortcut is launched.
3. In the project dflts directory (for example, for the SAM project the folder will be called samdflts) you need to place the configuration file PseudoUdaSettings.xml, an example of which is attached. Write in it the necessary PA and expressions to calculate them. Bellow is an example.


4. Some attribute values require additional calculations, i.e. cannot be described by a simple expression. For such cases, you must use the following syntax for the description of expression.
 
That means there is a function that returns a string value on the passed string of the reference number (REFNO) of the element, for example



Thus, a value will be written to the required attribute, which will be returned by the ConnectionDescGetStringByRef function. If you need to use this approach, then the name of the function must contain a StringByRef that determines the return type and that the refno element is passed to the function.
5. Mandatory conditions: file location, file name, internal file structure (presence of Name, Expression fields).
This setting works for UDA types TEXT (STRING), REAL, BOOL





Variants of errors that may occur when working with settings:
1. The configuration file may contain incorrect data - more often typos.
2. The specified attribute is missing in the project.
3. Attribute is not PA (example: Uda attribute ":UdaNotPseudo" in picture is not PseudoAttribute. Check attribute in Lexicon module.).
4. During operation, if an incorrect expression was specified (for example, propreal of cwei, the expression propreal cwei is correct), then the following notification will be displayed on the command line like:
CP: Syntax error in expression: "propreal of cwei" to calculate attribute: UdaReal

 And please: PseudoAtt

Комментариев нет:

Отправить комментарий

comments?