How to read data from a text file in Custom Components

Tekla Structures text file in Custom Component
Not version-specific
Tekla Structures
Environment
Not environment-specific

Description

When using custom components, sometimes you need to use information based on a single input parameter, usually the profile.
So when the profile changes the system automatically knows which values to use, for example, bolt size, bolt quantity, hole sizes, etc.

Steps

In this example we will create a simple cell beam. Based on the beam profile, the system will read the hole size and spacing automatically from a file.

 

 

 

Image
How to read data from a text file in Custom Components-1.png

 




1. Create a text file containing the required data. For versions older than Tekla Structures 2021 you need to make sure there is a space character at the end of each line. 

Image
How to read data from a text file in Custom Components-3.png



File search order
Tekla Structures searches for the files as system files in the following order:
• Model
• Project (set with XS_PROJECT)
• Firm (set with XS_FIRM)
• System (set with XS_SYSTEM)
• Environments/*your environment*/profil
• Environments/*your environment*/profil/cr

2. Create the custom part and add the needed variables.

 

Image
How to read data from a text file in Custom Components-4.png

 


The variable to read from a text file is "fVF(filename, key value of row, column number, separator)". The separator character is optional and it is left out in this example. Then space is used as a default separator. But if there are spaces in the values, you can use some other separator as well, for example backslash \ instead of space. Then the definition would be fVF("cell.dat", P3, 2, "\")  This additional separator character is possible since Tekla Structures 2021 version. For more information about this change, check Improvements in custom component handling in the release notes.

In this example " fVF("cell.dat", P3, 2)"
Cell.dat is the name of the text file.
P3 is the input variable for the beam profile.
2 is the column number of data to be read from the text file.

When the profile is changed now the cell diameter and spacing will automatically be read from the text file.

 

Czy to było pomocne?