API Reference

Detailed and full API reference helps you master Tekla development

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

ModelObject Class

The ModelObject class is an abstract base class for all model objects, such as parts, bolts, welds and reinforcements.
Inheritance Hierarchy
SystemObject
  Tekla.Structures.ModelObject
    Tekla.Structures.ModelModelObject
      More...

Namespace:  Tekla.Structures.Model
Assembly:  Tekla.Structures.Model (in Tekla.Structures.Model.dll) Version: 2019.0.0.0 (2019.0.0.0)
Syntax
[SerializableAttribute]
public abstract class ModelObject : Object, 
	IComparable, IEquatable<ModelObject>

The ModelObject type exposes the following members.

Properties
  Name Description
Public property Identifier
The identifier of the object.
(Inherited from Object.)
Public property IsUpToDate
Gets if the object does not have a modification which is not shared.
Public property ModificationTime
Gets latest time of the object was modified or created.
Top
Methods
  Name Description
Public method CompareTo
Compares Identifiers of model objects.
Public method Delete
Deletes the instance from the model database.
Public method Equals
Check if Identifiers of model objects are same.
Public methodCode example GetAllReportProperties
Retrieves all properties for the model object in one hashtable. Type for the returned value must be checked using type casting.
Public method GetAllUserProperties
Retrieves all properties for the model object in one hashtable. Type for the returned value must be checked using type casting.
Public method GetChildren
Returns an enumerator of all the children model objects.
Public method GetCoordinateSystem
Returns the coordinate system for the given model object.
Public method GetDoubleReportProperties
Retrieves multiple double report properties for the model object. It is faster to fetch multiple properties at once.
Public method GetDoubleUserProperties
Retrieves all double properties for the model object.
Public method GetDynamicStringProperty
Gets a dynamic string property from the model object.
Public method GetFatherComponent
Returns the father component of the model object.
Public method GetHierarchicObjects
Returns an enumerator of all the connected hierarchic objects.
Public method GetIntegerReportProperties
Retrieves multiple integer report properties for the model object. It is faster to fetch multiple properties at once.
Public method GetIntegerUserProperties
Retrieves all integer properties for the model object.
Public method GetPhase
Retrieves the phase of the model object (the phase number, the phase name, the phase comment and whether the phase is the current one or not).
Public method GetReportProperty(String, Double)
Retrieves a double property of the report for the model object.
Public method GetReportProperty(String, Int32)
Retrieves an integer property of the report for the model object.
Public method GetReportProperty(String, String)
Retrieves a string property of the report for the model object.
Public method GetStringReportProperties
Retrieves multiple string report properties for the model object. It is faster to fetch multiple properties at once.
Public method GetStringUserProperties
Retrieves all string properties for the model object.
Public method GetUserProperty(String, Double)
Retrieves a double property for the model object.
Public method GetUserProperty(String, Int32)
Retrieves an integer property for the model object.
Public method GetUserProperty(String, String)
Retrieves a string property for the model object.
Public method Insert
Inserts the model object instance into the model database.
Public method Modify
Modifies the model instance in the model database.
Public method Select
Selects the model object instance from the model database.
Public method SetDynamicStringProperty
Sets a dynamic string property for the model object.
Public method SetLabel
Sets a label for an object when a new instance is created. The label is used in plug-ins for identifying the changed object in modification.
Public method SetPhase
Sets the phase of the model object.
Public method SetUserProperty(String, Double)
Sets a double property for the model object.
Public method SetUserProperty(String, Int32)
Sets an integer property for the model object.
Public method SetUserProperty(String, String)
Sets a string property for the model object.
Top
Remarks
One way to find out the correct names of the report properties is to open the Template Editor. With the Template Editor you can see the listing of all the properties that can be added to report templates.
Examples
In the following example a connection to the Tekla Structures model has already been established and next the values of some user-defined attributes (UDAs) are going to be found out. The UDAs asked are the string value of CHECKED_BY, the double value of CHECKED_DATE, and the integer value of OBJECT_LOCKED.
using Tekla.Structures.Model;
using System;
using System.Windows.Forms;

public class Example
{
       public void Example1()
       {
           Model Model = new Model();

           ModelObjectEnumerator ObjectEnum = Model.GetModelObjectSelector().GetAllObjects();
           ObjectEnum.SelectInstances = false; // Set the "SelectInstances" to false to speed up the enquiry; possible because only report properties are asked.

           string Result = "CHECKED BY, CHECKED DATE, OBJECT LOCKED \n";
           while(ObjectEnum.MoveNext())
           {
               if(ObjectEnum.Current != null)
               {
                   Beam BeamObject = ObjectEnum.Current as Beam;
                   if(BeamObject != null)
                   {
                       string CheckedBy = "";
                       double DateCheckedValue = 0.0;
                       int LockedStatus = -1;

                       DateTime DateChecked = new System.DateTime(1970, 1, 1);

                       BeamObject.GetUserProperty("CHECKED_BY", ref CheckedBy);
                       BeamObject.GetUserProperty("CHECKED_DATE", ref DateCheckedValue);
                       BeamObject.GetUserProperty("OBJECT_LOCKED", ref LockedStatus);
                       if(CheckedBy.Length > 0 || DateCheckedValue > 0.0 ||
                           LockedStatus != -1)

                       DateChecked = DateChecked.AddSeconds(DateCheckedValue);
                       Result += CheckedBy;
                       Result += ", ";
                       Result += DateChecked.ToString("dd.MM.yyyy");
                       if(LockedStatus == 1)
                       {
                           Result += ", Locked\n";
                       }
                       else
                       {
                           Result += ", Not locked\n";
                       }
                   }
               }
           }
           MessageBox.Show(Result);
       }
}
See Also
Inheritance Hierarchy
SystemObject
  Tekla.Structures.ModelObject
    Tekla.Structures.ModelModelObject
      Tekla.Structures.ModelAssembly
      Tekla.Structures.ModelBaseComponent
      Tekla.Structures.ModelBaseRebarModifier
      Tekla.Structures.ModelBaseWeld
      Tekla.Structures.ModelBoltGroup
      Tekla.Structures.ModelBoolean
      Tekla.Structures.ModelControlArc
      Tekla.Structures.ModelControlCircle
      Tekla.Structures.ModelControlLine
      Tekla.Structures.ModelControlPlane
      Tekla.Structures.ModelControlPoint
      Tekla.Structures.ModelControlPolycurve
      Tekla.Structures.ModelGridBase
      Tekla.Structures.ModelGridSurface
      Tekla.Structures.ModelHierarchicDefinition
      Tekla.Structures.ModelHierarchicObject
      Tekla.Structures.ModelLoad
      Tekla.Structures.ModelLoadGroup
      Tekla.Structures.ModelPart
      Tekla.Structures.ModelPourBreak
      Tekla.Structures.ModelPourObject
      Tekla.Structures.ModelPourUnit
      Tekla.Structures.ModelRebarSet
      Tekla.Structures.ModelRebarSetAddition
      Tekla.Structures.ModelRebarSplice
      Tekla.Structures.ModelReferenceModel
      Tekla.Structures.ModelReferenceModelObject
      Tekla.Structures.ModelReinforcement
      Tekla.Structures.ModelSurfaceObject
      Tekla.Structures.ModelSurfaceTreatment
      Tekla.Structures.ModelTask
      Tekla.Structures.ModelTaskDependency
      Tekla.Structures.ModelTaskWorktype