Sie sind auf Seite 1von 20

# 1 (20) B&C Services / Tero Kautto 6.9.

2005

## EXCEL SHEET DESIGN INCORPORATION WITH TEKLA STRUCTURES 1. Background

This document gives instructions how to link your own Excel sheet calculations to Tekla Structures. It is expected that you have Excel calculation sheet ready. 2. 2.1 Custom component Create custom component

Create a custom component in Tekla Structures (version 11.1 ->) which relates to similar situation as your Excel calculation sheet. In this example we will calculate in-situ beam to beam reinforcement. So first create custom component for this situation. Name the component according to the purpose, in this situation beamtobeam.

2.2

## Edit custom component

Edit the custom component as you usually would. Add the magnetic user planes to workpoints of the reinforcements and bind the planes to part faces, so the reinforcement reacts to change of the profile size.

## 2 (20) B&C Services / Tero Kautto 6.9.2005

Next add a new parameter and name it "use_externaldesign", change the value type to Yes/No and define formula 1 (1=Yes 0=No).

Then add other parameters you need for this component and for the calculations. Name parameters according to their purpose and then link the parameters to necessary places in component browser. In this example: Reinforcing bar diameter Number of reinforcing bars Cover thickness on plane Cover thickness from plane Shear force

## 3 (20) B&C Services / Tero Kautto 6.9.2005

Shear force is only used for calculation, so it isn't linked component browser.

Save the component and test that it works as expected. 3. 3.1 Excel sheet Preparations

In order to test and see how the Excel sheet functions make the following changes to Excel.vb (C:\TeklaStructures\11.1\nt\bin\plugins)
Const DEBUG As Boolean = True'False Const SHOW_EXCEL As Boolean = True'False

3.2

## Creation of Excel calculation sheet

Make a copy of component_template.xls (C:\TeklaStructures\11.1\environments\countryindependent\Exceldesign) to same folder. Rename the copy to "component_(your component name).xls", in this example: component_ beamtobeam.xls. (You can place Excel sheet under model folder as well. Create folder called Exceldesign for this purpose). Open your calculation sheet and component_*.xls sheet in Excel at the same time. Copy the calculation sheet to component Excel by right clicking on top of sheet name -> Move or Copy.

## 4 (20) B&C Services / Tero Kautto 6.9.2005

Select the component_*.xls (component_beamtobeam.xls) from the "To book:" drop down and check "create a copy". Click OK, this copies the calculation sheet to component Excel.

## 5 (20) B&C Services / Tero Kautto 6.9.2005

Close the old calculation sheet. Rename (right click -> rename) the copied sheet (sheet1) on component_*.xls (component_beamtobeam.xls) to calculation.

6 (20) B&C Services / Tero Kautto 3.3 Editing the component calculation sheet 6.9.2005

Quite often you might need (or want) the Excel calculation sheet to work differently with Tekla Structures as a stand alone Excel sheet. For instance in this case the original calculation defined on given values whether reinforcement ratio is under or above 1. When the calculations are connected to Tekla Structures it might be wise to edit the calculations so that it would then calculate the required reinforcement and pass the information back to component for execution. So I changed Excel sheet so that instead of calculation the ratio of given number of reinforcing bars, it now calculates the ratio of single rebar and if anchoring capacity isn't enough it adds another rebar and calculates ratio again and keeps on doing this until there is enough reinforcing bars to hold the shear force.

7 (20) B&C Services / Tero Kautto 3.4 Adding input and output fields 6.9.2005

Go to Inputs sheet and add the parameters which are required for the calculations from component. (parameter name and type, e.g. string, int etc)

Similar way, add the variables that you want to output back to component to Outputs sheet. In this example we only calculate number of required reinforcing bars, so only parameter outputted is number of reinforcing bars (parameter = Barnumber1)

Tip: You can check attribute names as well from component properties file (Save as on component dialog or open component.inp file with text editor). On system components "Save as" is the best way.

## Linking input, output and component fields to calculations

When ever component is modified the calculation needs to be rerun. In order this to happen automatically, we need to link the input and necessary component fields to calculation sheet, and from calculation sheet to Output sheet, which then brings the new values to component and updates it. Example 1: Link the shear force value from Inputs page to calculation page. Click shear force value field on calculations page and make equal mark (=), then go to Inputs page and select Value field for shear force and click enter.

## 2. Select shearforce field on Inputs page 3. Value linked to calculation page

Example 2: Link main beam width value from component page to calculations page. Same way as on example 1, create equal mark (=) to Width of main beam B value, go to component page and select the main part width field, click enter.

## 9 (20) B&C Services / Tero Kautto 6.9.2005

2. Select Width of Primary profile field on Component page (the value from model is brought here when component is created/modified.

## 10 (20) B&C Services / Tero Kautto 6.9.2005

Example 3: In similar fashion you can link for instance Component ID from component page to Calculation page. Example 4: Link all the necessary fields from Inputs and Components pages to Calculation page. Example 5: Finally you need to link the calculation results to Output page.

## 3. Value linked to Outputs page 3.6 Test Excel sheet

After linking all the necessary fields, test the functionality. Give or change values on Inputs page (and/or component page), and check that values are transferred correctly to calculations page and calculations are performed correctly. Check also that calculation results are transferred to Output page. Save and close Excel. 4. Test the incorporation of Excel sheet and Component

Fill in values to component dialog. Note that you have to leave the fields that are brought back from calculations to component empty, the default value is send to Excel.

## Hit modify. Compiler service will start in separate dos window.

Normally Excel is used without showing it to user (behind the scenes), but now we have debug option on and after a few seconds Excel sheet will appear with input values from component dialog. After the values have been set a small dialog opens telling you that, Input values are set. Hit OK to continue

Next you will see all the values on component page update. You will get another small dialog telling you that component data has been set. Click OK to continue.

13 (20) B&C Services / Tero Kautto Next the Output values will been set. 6.9.2005

Click OK. Note: Excel can loop a few times, in case you are working with custom component.

After Excel has gone through the calculation the values are transferred to component and the component is updated.

Congratulations! You have created Excel calculation for custom component. Note: Because calculation requires as well some value for parameter, which are just defaults on dialog/input page, there must be default value calculation in Excel sheet. E.g. number of reinforcement bars can be calculated in Excel sheet as well. It is important that all these calculated values are passed back to component on output page. This ensures that parameters used on calculations are the same which appear on the model.

## 14 (20) B&C Services / Tero Kautto 6.9.2005

Tip: Error code: You can add as well parameter called Error to output page. With this parameter you can indicate to user if connection design did pass or fail. You can use values: 1=green component symbol, 2=yellow component symbol or 3=red component symbol. 5. Saving results and other editing

There are a lot of nice features you can add Excel sheet. As an example below are instructions how to create a function that saves the results either in htm or xls format. 5.1 Defining result file and path

Field "ModelDirectory" on Component page will be automatically updated depending on location of component. Lets add there definition for results folder. Let use model folder as bases for results folder. Create field for results folder as: =C9 & "\" & "ExcelDesignResults" (C9= definition for model folder)

To get the file path and id also to saved calculation page, define similar cell to that page also. =Component!F10 & "\" & ComponentID & ".htm" (F10 = earlier defined result folder)

15 (20) B&C Services / Tero Kautto 5.2 Recording and editing an Excel macro 6.9.2005

Next we will create Excel Macro that publishes document as htm format. Start Excel macro recording Tools > Macro -> Record New Macro...

Define Macro name Click OK to start recording, then: File -> Save as Web Page Click Publish Select Item on Calculation Sheet "All contents of Calculations" Change the file name to Publish the results in model folder e.g. ExcelDesignResults folder

## Click Publish Stop recording

This records a macro, which always publishes calculation page. But this is still a "dumb" macro, which always uses the same file name and the same destination folder, so we need to edit the macro. Go to Tools -> Macro -> Macros Select SaveResults Click Edit opens the Visual Basic editor

## 16 (20) B&C Services / Tero Kautto 6.9.2005

Let's first add a script that automatically creates the results folder under model folder (if necessary).
' Save Results Sheet report_folder = Worksheets("component").Range("F10").Value Set fs = CreateObject("Scripting.FileSystemObject") new_folder = fs.FolderExists(report_folder) If new_folder = 0 Then fs.CreateFolder (report_folder) End If

Note that F10 should point to predefined cell on Component page that defines the results folder.

## 17 (20) B&C Services / Tero Kautto 6.9.2005

Next we will add a script which defines whether the file is saved in htm or xls format. If you select field F9 on component page, you will notice that field is also named SaveReport.

Add following script to Excel code so if the value on "SaveReport" cell is HTML then file is saved with component id number and htm extension.
If Names("SaveReport").RefersToRange.Value = "HTML" Then Sheets("Calculation").Select report_path = report_folder & "\" & Worksheets("component").Range("C2").Value & ".htm"

## 18 (20) B&C Services / Tero Kautto 6.9.2005

Since we have now added a few lines to code which tells where to save the results and the name of the file to be saved, we need to edit the original code little bit. Change code from:
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _ "C:\TeklaStructuresModels111\Excel_test\ExcelDesignResults\Page.mht", _ "Calculation", "", xlHtmlStatic, "component_beamtobeam_10588", "") .Publish (True) .AutoRepublish = False End With ChDir "C:\TeklaStructuresModels111\Excel_test\ExcelDesignResults"

To:
With ActiveWorkbook.PublishObjects("component_beamtobeam_10588") .HtmlType = xlHtmlStatic .Filename = _ report_path .Publish (False) .AutoRepublish = False End With

So just copy/paste the "component_name_number" value from original code to new code (in this example: "component_beamtobeam_10588"). We still need to define the option to save the file in xls format. So add following script to Excel code if the value on "SaveReport" cell is WorkBook then file is saved with component id number and xls extension.
ElseIf Names("SaveReport").RefersToRange.Value = "WorkBook" Then 'Save Workbook ActiveWorkbook.SaveAs Filename:=report_folder & "\" & Worksheets("component").Range("C2").Value & ".xls" End If

19 (20) B&C Services / Tero Kautto Save changes and close debugger. Let's test the macro: Go to Tools -> Macro -> Macros Select SaveResults Run Check that macro created the wanted folder underneath model folder and creates htm file in that folder. 6.9.2005

To make the SaveResults macro run automatically each time component is modified we still need to add a call function for it. Go to Tools -> Macro -> Macros Select StartCalculation Click Edit

## Add a call for SaveResults macro

Call SaveResults

Save changes and close debugger. Test component Delete the ExcelDesignResults folder from model folder Modify the component in Tekla Structures it should now automatically add the folder and the result file. Check also that content in htm file is correct.

6.

## Finalizing the creation of the component

Change the Excel calculations to work behind the scenes again. Change the Excel.vb back to original state. (C:\TeklaStructures\11.1\nt\bin\plugins)
Const DEBUG As Boolean = False'True Const SHOW_EXCEL As Boolean = False'True

Test the component again calculation should work and results should be saved as before, but Excel calculation shouldn't pop up.