# Cross-Model Updating and Adjusting Structural Data Using COM Interface

## Technical Article on the Topic Structural Analysis Using Dlubal Software

### Technical Article

For some structures, it is necessary to design them in different configurations. It may be that an aerial work platform must be analyzed in its position on the ground as well as in the middle and in the extended position. Since such tasks require the creation of several models, which are almost identical, updating all models with just one mouse click is a considerable relief.

In the following, it is assumed that you have a basic knowledge of the COM interface. The links provide articles about the basics of programming.

The program should automatically adjust any structural data such as nodes, lines, members, etc. by clicking a certain button. For example, the coordinates of node 1 should be transferred from a main model to various secondary models and variants. However, not all values should be transferred, but only those which were previously defined freely by the user.

#### Model Example

As an example for the described program's function, a simple aerial work platform was modeled. The following model is considered as the main model.

This platform is not parameterized and is available with three types: fully extended, on the ground, and in a middle position. The fully extended type is defined as the main model, the middle one as type 1 and the one on the ground as type 2.

#### Considerations

In order to achieve the task, either a kind of configuration file is required or a graphical user interface to define which models must be compared with each other.

For defining the free or variable coordinates of a node, the comment function of the respective element should be used. The program looks for a specific string in the comment and, if found, modifies or leaves the corresponding coordinates. In addition, it would be useful if new elements were automatically created in all sub-models. So, the structure should be made in such a way that the user activates the desired model in RFEM (edited in the foreground) and the program then opens the required models, comparing them with the main model.

#### Graphical User Interface

The following simple design was selected for the graphical user interface.

The user can type a path in the text box or insert it by copy & paste. With "Add New Model" it can be added to the list of models to be adjusted. Use the "Remove Selected Model" button to remove a model selected in the list. The "Modify Models" button starts the program then.

#### Basic Program Flow

At the beginning, the program only has the paths of the secondary models and variants and needs the connection to RFEM first. If the connection to RFEM is established, then a loop should run over the secondary models. Since the program should also create elements, the hierarchy must be observed. Therefore, nodes are compared first, then lines, materials, cross-sections, and finally members. Nodes represent an exception, because here the directions x, y, and z should be adopted, if necessary, or left as they are. All other elements are either taken over completely or left as they are. However, it should be the same for all elements that new ones are created.

#### Basic Structure of Program

The method executed when clicking the "Modify Models" button has the following basic structure.

private void button_mod_click(object sender, EventArgs e){ // RFEM //############################## Dlubal.RFEM5.IModel3 iModel_org = null; Dlubal.RFEM5.IApplication iApp = null; try {   // get interface to application and open model  iApp = Marshal.GetActiveObject("RFEM5.Application") as Dlubal.RFEM5.IApplication;  iApp.LockLicense();  iModel_org = iApp.GetActiveModel() as Dlubal.RFEM5.IModel3;    // loop over found models  Dlubal.RFEM5.IModel iModel_cpy = null;    for (int i = 0; i < listBox_models.Items.Count; ++i)  {   // open model   iModel_cpy = iApp.OpenModel(listBox_models.Items[i].ToString());      // get structural data   Dlubal.RFEM5.IModelData2 iModData_org    = iModel_org.GetModelData() as Dlubal.RFEM5.IModelData2;   Dlubal.RFEM5.IModelData2 iModData_cpy    = iModel_cpy.GetModelData() as Dlubal.RFEM5.IModelData2;      //  compare/change nodes   //  compare/change lines   //  compare/change materials   //  compare/change cross sections   //  compare/change members  }   } catch (Exception ex) {  MessageBox.Show(ex.Message, ex.Source); } finally {  if (iApp != null)  {   iApp.UnlockLicense();      // Releases COM object - not needed anymore   // Marshal.ReleaseComObject(iApp);   iApp = null;  }    iModel_org = null;    // Cleans Garbage Collector for releasing all COM interfaces and objects.  System.GC.Collect();  System.GC.WaitForPendingFinalizers(); }}

As already described, the connection to RFEM is established first via GetActiveObject ("RFEM5.Application"). Then, a connection to the active model is established via GetActiveModel(). In order to be able to carry out the comparison, the sub-models and their structural data are opened one after the other in a loop via the entries in the list box (GetModelData() ). At this point in time, all geometric data is available and can be compared.

If there is a problem, for example, a model cannot be opened, the error is caught by the try-catch block, displayed and the program will be unlocked.

#### Nodal Comparison

Comparing nodes between main and secondary model goes as follows.

First, all nodes of the main model are taken and a loop is started over these nodes. In this loop, the system first tries to get the data of the node with the same number in the secondary model. If this fails because the node does not exist, the error is caught with another try-catch block and in the secondary model the node is created with the data from the main model.

If the node exists, the comment is read and disassembled by means of the separator ";". If there are less than three parts then, the data will be taken from the main model. If there are three parts or more, they will be evaluated. An "f" stands for a fixed value that should not be overwritten. If it is not an "f", the value is overwritten by the value from the main model.

A short example is the string "f;;f1;kkl" in a node's comment. Once disassembled, the strings "f", "", "f1" and "kkl" result. Thus, the value x is left for the node and the values y and z are overwritten, since there is an empty string for y and not exactly "f" but "f1" for z.

//  compare/change nodesDlubal.RFEM5.Node[] nodes_org = iModData_org.GetNodes();for(int j=0; j < nodes_org.Length; ++j){ try {  Dlubal.RFEM5.INode iNode = iModData_cpy.GetNode(nodes_org[j].No, Dlubal.RFEM5.ItemAt.AtNo);  Dlubal.RFEM5.Node node = new Dlubal.RFEM5.Node();  node = iNode.GetData();    // check, if there are fixed components  List<string> defs = (node.Comment).Split(';').ToList<string>();    if (defs.Count >= 3)  {   if (defs[0] != "f")    node.X = nodes_org[j].X;      if (defs[1] != "f")    node.Y = nodes_org[j].Y;       if (defs[2] != "f")    node.Z = nodes_org[j].Z;  }  else  {   node.X = nodes_org[j].X;   node.Y = nodes_org[j].Y;   node.Z = nodes_org[j].Z;  }    // set node  iModData_cpy.PrepareModification();  iNode.SetData(node);  iModData_cpy.FinishModification();   } catch (Exception ex) {  // if nodes doesn't exist, create it;  iModData_cpy.PrepareModification();  iModData_cpy.SetNode(nodes_org[j]);  iModData_cpy.FinishModification(); } }

#### Lines, Materials and Other Comparisons

The other elements are slightly different to the node comparison but identical among each other.

//  compare/change linesDlubal.RFEM5.Line[] lines_org = iModData_org.GetLines();for (int j = 0; j < lines_org.Length; ++j){ try {  Dlubal.RFEM5.ILine iLine = iModData_cpy.GetLine(lines_org[j].No, Dlubal.RFEM5.ItemAt.AtNo);  Dlubal.RFEM5.Line line = new Dlubal.RFEM5.Line();  line = iLine.GetData();    // check, if the line is fixed  List<string> defs = (line.Comment).Split(';').ToList<string>();    if (defs[0] != "f")  {   line = lines_org[j];  }    // set line  iModData_cpy.PrepareModification();  iLine.SetData(line);  iModData_cpy.FinishModification();   } catch (Exception ex) {  // if nodes doesn't exist, create it;  iModData_cpy.PrepareModification();  iModData_cpy.SetLine(lines_org[j]);  iModData_cpy.FinishModification(); } }

The difference to the node comparison is that the element is completely overwritten if no "f" is found in the disassembled comment (disassembled by ";"). The other elements are created and compared in exactly the same way. See the source code in the attached Visual Studio project.

#### Evaluation

The program is able to implement the desired changes in the secondary models. How it works is shown in the video for the article. The biggest problem is currently that incorrect entries are not or only slightly intercepted.

#### Summary and Outlook

The program presented here is able to update secondary models based on a main model. Modifications on nodes and other elements up to members are transferred correctly.

What is missing are routines for intercepting incorrect entries, which could still be added. Further optimizations would be, for example, the optional closing of secondary models, which may lead to processing in the background. Adding further structural data, loads and combinations can also be useful.

#### Dipl.-Ing. Thomas Günthel

Customer Support

Mr. Günthel provides technical support for our customers.

#### Keywords

Write Comment...

Write Comment...

• Views 991x
• Updated 7 April 2021

Do you have questions or need advice?
Contact our free e-mail, chat, or forum support or find various suggested solutions and useful tips on our FAQ page.

RFEM for Students | Part 2

Online Training 17 May 2021 2:00 PM - 4:30 PM CEST

Eurocode 5 | Timber structures according to DIN EN 1995-1-1

Online Training 20 May 2021 8:30 AM - 12:30 PM CEST

RFEM | Structural dynamics and earthquake design according to EC 8

Online Training 2 June 2021 8:30 AM - 12:30 PM CEST

Glass Design with Dlubal Software

Webinar 8 June 2021 2:00 PM - 2:45 PM CEST

RFEM for Students | Part 3

Online Training 15 June 2021 2:00 PM - 4:30 PM CEST

RFEM | Basics | USA

Online Training 17 June 2021 9:00 AM - 1:00 PM EDT

Blast Time History Analysis in RFEM

Webinar 13 May 2021 2:00 PM - 3:00 PM EDT

Timber Beam and Surface Structures | Part 2: Design

Webinar 11 May 2021 2:00 PM - 3:00 PM CEST

Plate and Shell Buckling Utilizing Dlubal Software

Webinar 30 March 2021 2:00 PM - 2:45 PM CEST

Webinar 10 March 2021 2:00 PM - 3:00 PM EDT

The Most Common User Errors With RFEM and RSTAB

Webinar 4 February 2021 2:00 PM - 3:00 PM BST

Webinar 19 January 2021 2:00 PM - 3:00 PM EDT

Dlubal Info Day Online | 15 December 2020

Webinar 15 December 2020 9:00 AM - 4:00 PM BST

Webinar 1 December 2020 2:00 PM - 2:45 PM BST

FEA Troubleshooting and Optimization in RFEM

Webinar 11 November 2020 2:00 PM - 3:00 PM EDT

Soil-Structure Interaction in RFEM

Webinar 27 October 2020 2:00 PM - 2:45 PM BST

NBC 2015 Modal Response Spectrum Analysis in RFEM

Webinar 30 September 2020 2:00 PM - 3:00 PM EDT

Documenting Results in the RFEM Printout Report

Webinar 25 August 2020 2:00 PM - 2:45 PM CEST

Webinar 20 August 2020 2:00 PM - 3:00 PM EDT

How to Be More Productive Using RFEM

Webinar 7 July 2020 3:00 PM - 4:00 PM CEST

Introduction to Solid Modeling in RFEM

Webinar 30 June 2020 2:00 PM - 3:00 PM EDT

Modeling with Solids in RFEM

Webinar 9 June 2020 3:00 PM - 3:45 PM CEST

Webinar 14 May 2020 2:00 PM - 3:00 PM EDT

Length min

Length 0:50 min

Length 1:29 min

Length 0:19 min

Length 1:25 min

Length 0:10 min

Length 0:45 min

Length 2:24 min

Length 0:21 min

Length 1:26 min

Length min

Length 5:01 min

Length 8:40 min

Length 0:27 min

Length 1:08:16 min

Length 0:21 min

Length 1:22 min

Length 1:09:55 min