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.

DistanceParse Method (String, IFormatProvider)

Parses a distance from a string representation using the current unit type and the given culture.

Namespace:  Tekla.Structures.Datatype
Assembly:  Tekla.Structures.Datatype (in Tekla.Structures.Datatype.dll) Version: 2019.0.0.0 (2019.0.0.0)
public static Distance Parse(
	string text,
	IFormatProvider formatProvider


Type: SystemString
The text to parse.
Type: SystemIFormatProvider
The number format provider.

Return Value

Type: Distance
The representation of the specified distance.
Exception Condition
FormatException Thrown if the text does not represent a distance.
This example shows how to specify a format provider when parsing a Distance instance from a string.
using Tekla.Structures.Datatype;
using System.Globalization;

public class Example
       public void Example1()
           // Current unit type controls the default unit type used in parsing.
           // The default unit is millimeter.
           Distance.CurrentUnitType = Distance.UnitType.Millimeter;

           // Tekla Structures uses dot as the decimal separator in all locales.
           // This will be parsed as 30.2 millimeters.
           Distance distanceInMillimeters = Distance.Parse("30.2", CultureInfo.InvariantCulture);

           // If the distance contains the unit, the distance is converted automatically.
           // This will be parsed as 30.2 meters.
           Distance distanceInMeters = Distance.Parse("30.2m", CultureInfo.InvariantCulture);
See Also