Share

UnitFormatUtils.TryParse(Units, ForgeTypeId, String, ValueParsingOptions, Double) Method

Parses a formatted string into a number with units if possible.


Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 26.2.0.0 (26.2.0.0)

Syntax

C#

public static bool TryParse(
	Units units,
	ForgeTypeId specTypeId,
	string stringToParse,
	ValueParsingOptions valueParsingOptions,
	out double value
)

Parameters

units  Units
The units formatting settings, typically obtained from Document.GetUnits().
specTypeId  ForgeTypeId
Identifier of the target spec for the value.
stringToParse  String
The string to parse.
valueParsingOptions  ValueParsingOptions
Additional parsing options.
value  Double%
The parsed value. Ignore this value if the function returns false.

Return Value

Boolean
True if the string can be parsed, false otherwise.

Exceptions

ExceptionCondition
ArgumentException specTypeId is not a measurable spec identifier. See UnitUtils.IsMeasurableSpec(ForgeTypeId). -or- The unit in the FormatOptions in valueParsingOptions is not a valid unit for specTypeId. See UnitUtils.IsValidUnit(ForgeTypeId, ForgeTypeId) and UnitUtils.GetValidUnits(ForgeTypeId).
ArgumentNullException A non-optional argument was null

See Also

Reference

Was this information helpful?