Generate SOFiSTiK PDF Reports with Chapters and Subchapters for a better Report Navigation

Written by: Audun Mathias Øvstebø, COWI AS Trondheim

The procedure described in this article automatically generates a SOFiSTiK report as a pdf file with bookmarks for chapters and subchapters to improve report navigation.

And as an automatic process, it is essential to create a stable setup that is easy to maintain and use by everyone with a few instructions.

As quite some thoughts went into this workflow, it is not possible to discuss everything in detail. However, this article aims to inspire you to look under the hood and see the potential in workflow automation in SOFiSTiK.

Let’s take a closer look into the significant stages of the process.

The three major steps are executed according to the following two flowcharts. Step 1 is a manual step where the report setup is selected. Steps 2 and 3 print and combine pdf files automatically whenever the script runs. The commands used for steps 1 and 2 are based on the standard CADINP syntax of SOFiSTiK and can be used by anyone, while step 3 is software specific and will not be described in-depth in this article.

COWI Automated PDF Report - Scheme

#1 Create subchapter PLB files and generate URS files for every chapter

You can start Report Browser from CMD by using the +sys ursula command, as described in the SOFiSTiK Basics manual chapter 12.1.9. One of the possible input options combines selected .plb files and stores the settings for the output in a separate .urs file for every set of combined .plb files.

The teddy command below opens the .plb files 024, 023 and 025 as a combined report (AutoRep_024.plb) in Report Browser, allowing to select the modules to include and add items such as a table of content. This is the only command required to perform steps 1.a to 1.c in the flowchart above.

Generate SOFiSTiK PDF Reports 001

Once Report Browser is closed, a .urs file will be stored automatically. This file contains the settings of modules and additional items to be included when the subchapter is printed afterwards.

#2 Print compiled PLB files based on previously defined URS files as PDF

Some additional options need to be added to the command to print the combined report (AutoRep_024.plb). This command corresponds to step 2.a and 2.c in the flowchart.

Generate SOFiSTiK PDF Reports 002

By running similar commands to the one above, the different subchapters of your SOFiSTiK report get automatically created with the previously stored settings. It is also possible to disable lines corresponding to subchapters that don’t need to be updated to reduce the calculation time.

The previous example line creates a .pdf file with the name AutoRep_024.pdf stored in the project folder. The following code is used to copy the file to a different folder and a new name, as suggested by step 2.d in the flowchart.

Generate SOFiSTiK PDF Reports 003

For each new subchapter, the report heading gets updated by writing a new sofistik.def file with the new name of the subchapter included in the page numbering.

The sofistik.def file is created with the CADINP command <TEXT,FILE=filename.extension> that writes the content of the text block into a file. The used code is shown below and corresponds to step 2.b of the flowchart.

Generate SOFiSTiK PDF Reports 004

#3 Combine PDF’s to a Final Report File with a VB Script and Bluebeam Revu

The program Stapler.exe (from Bluebeam Revu) is used to combine a list of pdf files to automate the process that creates the bookmarks for the final report. This program requires an input file defining both the pdfs to combine and the file path to the resulting pdf file. Creating this input file using CADINP commands turned out to be difficult. As an alternative, a VBScript was executed from Teddy (by using CMD commands) to create this input file, as shown in the following code.

This code is used in step 3.a and 3.b of the flowchart. The first file path is the script’s name, while the second is an input argument to the VBScript.

Generate SOFiSTiK PDF Reports 005

This VBS file is placed in a similar folder to the pdf files (subchapters or chapters). It combines the .pdf files in the folder in alphabetic order (according to the file name), using the file names as bookmarks.

The resulting file is stored in the parent folder of the folder the script runs, and the .pdf file name is set to this folder name. When combining subchapters, the resulting file will be named according to the chapter name. The general VBScript is created using the <TEXT> command in SOFiSTiK and copied to every location to be used with the +SYS COPY command.

To create the entire example report, the following code is used:

Generate SOFiSTiK PDF Reports 006

Syntax simplifications

As shown, this file contains a lot of repetition. Since only a three-digit number separates the .plb names at the end, it is hard to remember the content. The notation is also sensitive to syntax errors.

A setup of Teddy blocks, VBScripts and <TEXT> blocks that automatically generate the above file was developed to reduce repetition and the risk of syntax errors while improving readability. Additionally, this setup allows comments and compress the input file. The defined blocks and VBScripts are standard and do not need to be modified. The Teddy code to generate the report has the following format:

Generate SOFiSTiK PDF Reports

The simplified format works by executing the following steps

#A: Create a VBScript from Teddy by using standard blocks and variables defined within the text block that creates the script.

#B: Run the VBScript from Teddy. This script creates a .dat file with all the required Teddy commands to create the report.

#C: Run the .dat file that was just created.

The “print”, “view”, “genFileCode”, and “BlueBeamComb” are blocks that never need to be changed and are defined in a separate Teddy file.

This video shows how input lines can be disabled by commenting them out. Furthermore, replacing “#include print” with “#include view” allows you to switch from running step 2.a, 2.b and 2c to running step 1.a. At the latter, the user can manually include and add a table of contents for future .pdf generation. This way, the same file is used for report setup and report generation.

I hope you found this article and the developments we do at COWI inspiring and that you learned one or two things about the automation capabilities in SOFiSTiK.

More on report generation: How to generate a DOCX file in SOFiSTiK