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, DistanceUnitType)

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

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

Parameters

text
Type: SystemString
The text to parse.
formatProvider
Type: SystemIFormatProvider
The number format provider.
unitType
Type: Tekla.Structures.DatatypeDistanceUnitType
The unit type of the distance to parse. Determines the parsing process.

Return Value

Type: Distance
The representation of the specified distance.
Exceptions
ExceptionCondition
FormatExceptionThrown if the text does not represent a distance.
ArgumentExceptionThrown if an invalid unit type is specified.
Examples
This example shows how to specify a format provider and a unit type when parsing a Distance instance from a string.
using Tekla.Structures.Datatype;
using System.Globalization;

public class Example
{
       public void Example1()
       {
           // We can override the current unit type to force the parsing to perform automatic unit conversion.
           // This will be parsed as 3.2 inches.
           Distance distanceInInches = Distance.Parse("3.2", CultureInfo.InvariantCulture, Distance.UnitType.Inch);

           // When using feet or inches as the distance unit, the fractional format is supported as well.
           // This will be parsed as 3/4 inches.
           Distance InchesInFractionalFormat = Distance.Parse("3/4", CultureInfo.InvariantCulture, Distance.UnitType.Inch);
       }
}
See Also