Tekla Open API

Detailed and full API reference helps you master Tekla Open API

This is the most recent version of Tekla Open API.
For older versions, please visit Tekla Warehouse.

OperationCreateReportFromAll Method

Creates a report from all the objects using the given template name and filename.

If a path is not given in the filename, the file is created to the folder defined with the advanced option XS_REPORT_OUTPUT_DIRECTORY.

If the given folder does not exist, the report creation fails.

Internally, this method is asynchronous, and because of that the output file cannot be immediately available.

See Tekla Structures Help for more information about reports.

Namespace:  Tekla.Structures.Model.Operations
Assembly:  Tekla.Structures.Model (in Tekla.Structures.Model.dll) Version: 2018.1.0.0 (2018.1.0.0)
Syntax
public static bool CreateReportFromAll(
	string TemplateName,
	string FileName,
	string Title1,
	string Title2,
	string Title3
)

Parameters

TemplateName
Type: SystemString
The name of the report template to be used in report creation. The name must contain more than three characters.
FileName
Type: SystemString
The name of the created report. The name must contain more than three characters.
Title1
Type: SystemString
The first title for the created report.
Title2
Type: SystemString
The second title for the created report.
Title3
Type: SystemString
The third title for the created report.

Return Value

Type: Boolean
True if the report is created.
Exceptions
Exception Condition
ArgumentNullException Thrown when the TemplateName or FileName is null.
ArgumentException Thrown when the TemplateName or FileName is too short.
Examples
The following example creates a report and then displays it. It is taken into account that the created file might not be immediately available.
using System.IO;
using System.Threading;
using Tekla.Structures.Model.Operations;

public class Example
{
       public bool IfLockedWait(string FileName)
       {
           // try 10 times
           int RetryNumber = 10;
           while (true)
           {
               try
               {
                   using(FileStream FileStream = new FileStream(
                   FileName, FileMode.Open,
                   FileAccess.ReadWrite, FileShare.ReadWrite))
                   {
                       byte[] ReadText = new byte[FileStream.Length];
                       FileStream.Seek(0, SeekOrigin.Begin);
                       FileStream.Read(ReadText, 0, (int)FileStream.Length);
                   }
                   return true;
               }
               catch (IOException)
               {
                   // wait one second
                   Thread.Sleep(1000);
                   RetryNumber--;
                   if(RetryNumber == 0)
                       return false;
               }
           }
       }

       public void Example1()
       {
           Operation.CreateReportFromAll("Assembly_list", "Assembly_list.xsr", "MyTitle", "", "");

           if(File.Exists("Assembly_list.xsr"))
           {
               // wait until Tekla Structures has unlocked the file, or timeout
               if(IfLockedWait("Assembly_list.xsr"))
               {
                   // display the report
                   Operation.DisplayReport("Assembly_list.xsr");
               }
           }
       }
}
See Also