Salta al contenuto principale

Copyfield gives me an incorrect value and should be "0"

Tekla Structures - Not version-specific
Not version-specific
Tekla Structures
Environment
Not environment-specific
Attachments

Question:
CopyField copies values that are out of the row hierarchy, is this correct?
 

Example: 

Image
EX_WRONG_A.png

The value "Contains Sub-Parts" for assembly row B/2 should be empty, but it copied the value of Assembly row B/1. This is incorrect.

Answer: 
This works as intended and was fixed in Tekla Structures version 2018.

The function CopyField uses the value fields in rows, it searches for the value field values in different locations depending on where the source field is. Below are the cases of how CopyField works to find the relevant values in sequential order.

Case

Scenario

1

CopyField searches for the source field in the same row.

2

CopyField searches for the source field in the same row hierarchy above where it has been placed (that is, from child row to parent row).

3

CopyField searches for the source field in the same row hierarchy below where it has been placed (that is, from parent row to child row).

4

CopyField searches for the source field outside of the hierarchy in the rows below where CopyField has been placed.

5

CopyField searches for the source field outside of the row hierarchy in the rows above where CopyField has been placed.

This table can be found in the F1 help dialog box inside of the Template Editor, Tab: CopyField reference cases.

Scenario 4 & 5 will copy a value when there is no field in the hierarchy of the row. Meaning that when you want to fetch a value of - for example - a sub-part but there are no sub-parts in the assembly, there is no row to copy the value from. When this happens, Tekla Structures will search for the field outside of the hierarchy. The output is 0 / empty when there is no existing field at all.


How to fix this in your template:

A good workaround is to:
  1. Add a Summary row in the hierarchy. 
  2. In the Summary-row make a field with the following condition:
    if ( count("Field name from Part-row")!= 0 )
    then
        CopyField("Field name from Part-row")
    else
        "NO or 0"
    endif
  3. In the Assembly-row you can now point the CopyField to the Summary-row field.

 
By creating the Summary-row that counts the Part-rows and only outputs the value if there is a Part-row, allows the CopyField function in the Assembly-row to always fetch a value within the hierarchy.
 
IncorrectCorrect
Image
Hierarchy_B.png
Image
Hierarchy_C.png


Attached is an example report template.

 

 

Invia

Table of Contents