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.

Mark Class

The Mark class represents a mark object that contains a single mark. Several mark objects can be merged into one mark set.
Inheritance Hierarchy

Namespace:  Tekla.Structures.Drawing
Assembly:  Tekla.Structures.Drawing (in Tekla.Structures.Drawing.dll) Version: 2022.0.13611
Syntax
[SerializableAttribute]
public class Mark : MarkBase

The Mark type exposes the following members.

Constructors
  NameDescription
Public methodMark
Constructs a Mark that will be attached to the specified ModelObject upon Insert.
Top
Properties
  NameDescription
Public propertyAttributes
Gets or sets the mark attributes.
Public propertyHideable
Accesses the information if this object is hidden or not or if it should be.
(Inherited from MarkBase.)
Public propertyInsertionPoint
The insertion point of the mark.
(Inherited from MarkBase.)
Public propertyIsAssociativeNote
Gets a value indicating whether the mark is an associative note.
(Inherited from MarkBase.)
Public propertyPlacing
The current placing of the object. See the placing types for different placing options.
(Inherited from MarkBase.)
Public propertyQueryReturnValue
Status information about the latest database operation (select, insert, modify, delete).
(Inherited from DatabaseObject.)
Top
Methods
  NameDescription
Public methodDelete
Calls the system to delete the mark attached to a model object. After this operation, only associative notes can be attached to that model object.
(Overrides DatabaseObjectDelete.)
Public methodGetAxisAlignedBoundingBox
Returns the axis aligned bounding box of the text (rectangle format).
(Inherited from MarkBase.)
Public methodGetDoubleUserProperties(DictionaryString, Double)
Retrieves all double user properties for the object with the given list of names.
(Inherited from DatabaseObject.)
Public methodGetDoubleUserProperties(ListString, DictionaryString, Double)
Retrieves all double user properties for the object with the given list of names.
(Inherited from DatabaseObject.)
Public methodGetDrawing
Gets the drawing where the drawing object is.
(Inherited from DrawingObject.)
Public methodGetIntegerUserProperties(DictionaryString, Int32)
Retrieves all integer user properties for the object with the given list of names.
(Inherited from DatabaseObject.)
Public methodGetIntegerUserProperties(ListString, DictionaryString, Int32)
Retrieves all integer user properties for the object with the given list of names.
(Inherited from DatabaseObject.)
Public methodGetObjectAlignedBoundingBox
Returns the object aligned bounding box of the text (rectangle format).
(Inherited from MarkBase.)
Public methodGetObjects
Gets the children objects of the current object.
(Inherited from MarkBase.)
Public methodGetObjects(Type)
Gets the children objects of the current object that are of certain types.
(Inherited from MarkBase.)
Public methodGetRelatedObjects
Gets the related objects of the current object.
(Inherited from DrawingObject.)
Public methodGetRelatedObjects(Type)
Gets the related objects of the current object that are of certain types.
(Inherited from DrawingObject.)
Public methodGetStringUserProperties(DictionaryString, String)
Retrieves all string user properties for the object with the given list of names.
(Inherited from DatabaseObject.)
Public methodGetStringUserProperties(ListString, DictionaryString, String)
Retrieves all string user properties for the object with the given list of names.
(Inherited from DatabaseObject.)
Public methodGetUserProperty(String, Double)
Gets a double property from the drawing object. The object has to be in a drawing before the method can be used.
(Inherited from DatabaseObject.)
Public methodGetUserProperty(String, Int32)
Gets an integer property from the drawing object. The object has to be in a drawing before the method can be used.
(Inherited from DatabaseObject.)
Public methodGetUserProperty(String, String)
Gets a string property from the drawing object. The object has to be in a drawing before the method can be used.
(Inherited from DatabaseObject.)
Public methodGetView
Gets the view where the drawing object is.
(Inherited from DrawingObject.)
Public methodInsert
Calls the system to insert the new object.
(Overrides DatabaseObjectInsert.)
Public methodIsEqual
Compares the current object with an object of the same type.
(Overrides DrawingObjectIsEqual(Object).)
Public methodIsSameDatabaseObject
Returns true if the current object and the given object are referencing the same database object.
(Inherited from DatabaseObject.)
Public methodModify
Calls the system to update/modify the object.
(Overrides DatabaseObjectModify.)
Public methodMoveObjectRelative
Moves the object using the move vector.
(Inherited from MarkBase.)
Public methodSelect
Calls the system to select and retrieve the object.
(Overrides DatabaseObjectSelect.)
Public methodSetUserProperty(String, Double)
Sets a double property for the drawing object. The object has to be in a drawing before the method can be used.
(Inherited from DatabaseObject.)
Public methodSetUserProperty(String, Int32)
Sets an integer property for the drawing object. The object has to be in a drawing before the method can be used.
(Inherited from DatabaseObject.)
Public methodSetUserProperty(String, String)
Sets a string property for the drawing object. The object has to be in a drawing before the method can be used.
(Inherited from DatabaseObject.)
Public methodToString
Changes the string presentation of the drawing object.
(Inherited from DrawingObject.)
Top
Examples
The following example enumerates through all parts in all views and inserts marks for all those parts, the marks are placed in the middle of the part.
using Tekla.Structures.Geometry3d;
using Tekla.Structures.Drawing;
using TSM = Tekla.Structures.Model;

class Example
{
    public void InsertMarksForAllPartsInDrawing()
    {
        TSM.Model MyModel = new TSM.Model();
        DrawingHandler MyDrawingHandler = new DrawingHandler();
        if(MyModel.GetConnectionStatus())
        {
            if(MyDrawingHandler.GetConnectionStatus())
            {
                DrawingHandler.SetMessageExecutionStatus(DrawingHandler.MessageExecutionModeEnum.INSTANT);
                Drawing CurrentDrawing = MyDrawingHandler.GetActiveDrawing();
                DrawingObjectEnumerator allParts = CurrentDrawing.GetSheet().GetAllObjects(typeof(Part));
                while(allParts.MoveNext())
                {
                    ModelObject modelObject = (ModelObject)allParts.Current;

                    Point PartMiddleStart = null, PartMiddleEnd = null, PartCenterPoint = null;
                    GetPartPoints(MyModel, modelObject.GetView(), modelObject, out PartMiddleStart, out PartMiddleEnd, out PartCenterPoint);

                    Mark Mark = new Mark(modelObject);
                    Mark.Attributes.Content.Clear();
                    Mark.Attributes.Content.Add(new TextElement("My Mark"));
                    Mark.Placing = new AlongLinePlacing(PartMiddleStart, PartMiddleEnd);
                    Mark.InsertionPoint = PartCenterPoint;
                    Mark.Insert();
                }
            }
        }
    }

    private void GetPartPoints(TSM.Model MyModel, ViewBase PartView, ModelObject modelObject, out Point PartMiddleStart, out Point PartMiddleEnd, out Point PartCenterPoint)
    {
        TSM.ModelObject modelPart = GetModelObjectFromDrawingModelObject(MyModel, modelObject);
        GetModelObjectStartAndEndPoint(modelPart, (View)PartView, out PartMiddleStart, out PartMiddleEnd);
        PartCenterPoint = GetInsertionPoint(PartMiddleStart, PartMiddleEnd);
    }

    private TSM.ModelObject GetModelObjectFromDrawingModelObject(TSM.Model MyModel, ModelObject PartOfMark)
    {
        TSM.ModelObject modelObject = MyModel.SelectModelObject(PartOfMark.ModelIdentifier);

        TSM.Part modelPart = (TSM.Part)modelObject;

        return modelPart;
    }

    private void GetModelObjectStartAndEndPoint(TSM.ModelObject modelObject, View PartView, out Point PartStartPoint, out Point PartEndPoint)
    {
        TSM.Part modelPart = (TSM.Part)modelObject;

        PartStartPoint = modelPart.GetSolid().MinimumPoint;
        PartEndPoint = modelPart.GetSolid().MaximumPoint;

        Matrix convMatrix = MatrixFactory.ToCoordinateSystem(PartView.DisplayCoordinateSystem);
        PartStartPoint = convMatrix.Transform(PartStartPoint);
        PartEndPoint = convMatrix.Transform(PartEndPoint);
    }

    private Point GetInsertionPoint(Point PartStartPoint, Point PartEndPoint)
    {
        Point MinPoint = PartStartPoint;
        Point MaxPoint = PartEndPoint;
        Point InsertionPoint = new Point((MaxPoint.X + MinPoint.X) * 0.5, (MaxPoint.Y + MinPoint.Y) * 0.5, (MaxPoint.Z + MinPoint.Z) * 0.5);
        InsertionPoint.Z = 0;
        return InsertionPoint;
    }
}
See Also