Tekla Open API

Detailed and full API reference helps you master Tekla Open API

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

ViewCamera Class

The ViewCamera class defines a camera which can be used together with a visible view. Always supply a properly orthogonalized camera up vector when rotating the camera.
Inheritance Hierarchy
SystemObject
  Tekla.Structures.Model.UIViewCamera

Namespace:  Tekla.Structures.Model.UI
Assembly:  Tekla.Structures.Model (in Tekla.Structures.Model.dll) Version: 2018.1.0.0 (2018.1.0.0)
Syntax
[SerializableAttribute]
public class ViewCamera

The ViewCamera type exposes the following members.

Constructors
  Name Description
Public method ViewCamera
Instantiates a new view camera instance with zero length vectors.
Top
Properties
  Name Description
Public property DirectionVector
The camera direction (controls the camera pan and tilt).
Public property FieldOfView
The camera field of view as an angle (degrees) in the perspective view.
Public property Location
The camera location in global coordinates (XYZ).
Public property UpVector
The camera up vector (controls the camera roll).
Public property View
The view where the camera belongs to.
Public property ZoomFactor
The camera zoom factor (meter/pixel) in the orthogonal view.
Top
Methods
  Name Description
Public method Modify
Updates the camera to the application view.
Public method Select
Updates the camera parameters from the application view.
Top
Examples
The following example shows how the ViewCamera class can be used:
using System;
using Tekla.Structures.Model.UI;
using Tekla.Structures.Geometry3d;

public class ViewCameraExample
{
    public void ViewCameraExample1()
    {
        ModelViewEnumerator ViewEnum = ViewHandler.GetVisibleViews();
        ViewEnum.MoveNext();
        View CurrentView = ViewEnum.Current;
        ViewCamera Camera = new ViewCamera();

        // Set the view to the camera
        Camera.View = CurrentView;
        if(CurrentView.IsVisible() && CurrentView.IsPerspectiveViewProjection())
        {
            // Query camera settings from the application
            Camera.Select();

            // Tilt the camera
            Vector DirectionVector = Camera.DirectionVector;
            Vector UpVector = Camera.UpVector;
            Vector CrossVector = DirectionVector.Cross(UpVector);
            Matrix RotationMatrix = new Matrix();
            RotationMatrix = MatrixFactory.Rotate(Math.PI/20.0, CrossVector);
            Tekla.Structures.Geometry3d.Point RotPoint = RotationMatrix * (Tekla.Structures.Geometry3d.Point)Camera.DirectionVector;
            DirectionVector = new Vector(RotPoint);
            DirectionVector.Normalize();
            Camera.DirectionVector = DirectionVector; 

            // Orthogonalize the camera UpVector
            UpVector = CrossVector.Cross(DirectionVector);
            UpVector.Normalize();
            Camera.UpVector = UpVector;

            // Modify the camera settings in the application
            Camera.Modify();
        }
    }
}
See Also