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.

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: 2023.0.1
Syntax
public static Distance Parse(
	string text,
	IFormatProvider formatProvider
)

Parameters

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

Return Value

Type: Distance
The representation of the specified distance.
Exceptions
ExceptionCondition
FormatExceptionThrown if the text does not represent a distance.
Examples
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
Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.