Skip to main content

OpenTD reference 2026 R1

Class UnitsData

Last update: 09.03.2026

Namespace: OpenTD
Assembly: OpenTD.dll

Describes a system of units. Can be inconsistent.

[DataContract]
public class UnitsData : IEquatable<UnitsData>

Inheritance

object ← UnitsData

Implements

IEquatable<UnitsData>

Inherited Members

object.ToString(), object.Equals(object), object.Equals(object, object), object.ReferenceEquals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone()

Constructors

UnitsData()

public UnitsData()

UnitsData(string)

Initializes a new instance of the class by parsing the supplied units expression string. Use with basic units (m, hr, Btu, etc.) or compound units expressions (Btu/hr/ft^2/F, kg/m-s, etc.). Recognizes strings in the same format output by TD. Accepted operators : ( ) / - ^ Exponents denoted with optional ^, e.g. m^3 and m3 are both valid W can be substituted for J/s 1 can be used, as in 1/m^3 Revolution can be used, as in Revolution/s Case-insensitive For overlapping model length and orbit length units (m and ft), assumes model length

public UnitsData(string unitsExpression)

Parameters

unitsExpression string

UnitsData(long, long)

Initializes a new instance of the class, using integers written to save files or CSR's by SINDA.

public UnitsData(long TdUnits, long TdUnits2)

Parameters

TdUnits long

TdUnits2 long

UnitsData(UnitsData)

Copy constructor.

public UnitsData(UnitsData source)

Parameters

source UnitsData

Properties

FlocadOutputUnits

[DataMember]
public UnitsData.FlocadOutputUnitsType FlocadOutputUnits { get; set; }

Property Value

UnitsData.FlocadOutputUnitsType

angle

[DataMember]
public UnitsData.Angle angle { get; set; }

Property Value

UnitsData.Angle

current

[DataMember]
public UnitsData.Current current { get; set; }

Property Value

UnitsData.Current

def

Use def to create arbitrary combinations of units (advanced).

[DataMember]
public UnitsDefData def { get; set; }

Property Value

UnitsDefData

energy

[DataMember]
public UnitsData.Energy energy { get; set; }

Property Value

UnitsData.Energy

force

[DataMember]
public UnitsData.Force force { get; set; }

Property Value

UnitsData.Force

mass

[DataMember]
public UnitsData.Mass mass { get; set; }

Property Value

UnitsData.Mass

modelLength

[DataMember]
public UnitsData.ModelLength modelLength { get; set; }

Property Value

UnitsData.ModelLength

orbitLength

[DataMember]
public UnitsData.OrbitLength orbitLength { get; set; }

Property Value

UnitsData.OrbitLength

pressure

[DataMember]
public UnitsData.Pressure pressure { get; set; }

Property Value

UnitsData.Pressure

temp

[DataMember]
public UnitsData.Temp temp { get; set; }

Property Value

UnitsData.Temp

time

[DataMember]
public UnitsData.Time time { get; set; }

Property Value

UnitsData.Time

voltage

[DataMember]
public UnitsData.Voltage voltage { get; set; }

Property Value

UnitsData.Voltage

Methods

Equals(UnitsData)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(UnitsData x)

Parameters

x UnitsData

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GetName(UnitsType)

public static string GetName(UnitsData.UnitsType type)

Parameters

type UnitsData.UnitsType

Returns

string

GetTitle(UnitsType)

public string GetTitle(UnitsData.UnitsType type)

Parameters

type UnitsData.UnitsType

Returns

string

GetUnitsName(UnitsType)

public string GetUnitsName(UnitsData.UnitsType type)

Parameters

type UnitsData.UnitsType

Returns

string

SetFrom(UnitsData)

public void SetFrom(UnitsData source)

Parameters

source UnitsData

SetFromDataset(long, long)

Set this units system based on 64-bit integers written to a save file or CSR by Sinda.

public void SetFromDataset(long TdUnits, long TdUnits2)

Parameters

TdUnits long

TdUnits2 long

Exceptions

OpenTDException

Problem decoding TdUnits. or Problem decoding TdUnits2.

SetFromUnitsExpression(string)

Sets this UnitsData using the supplied string. Use with basic units (m, hr, Btu, etc.) or compound units expressions (Btu/hr/ft^2/F, kg/m-s, etc.). For basic units, SetFromBasicUnit(string str) will be more efficient. Recognizes strings in the same format output by TD. Accepted operators : ( ) / - ^ Exponents denoted with optional ^, e.g. m^3 and m3 are both valid W can be substituted for J/s 1 can be used, as in 1/m^3 Revolution can be used, as in Revolution/s Case-insensitive For overlapping model length and orbit length units (m and ft), assumes model length

public bool SetFromUnitsExpression(string str)

Parameters

str string

Returns

bool

SetToEng()

public void SetToEng()

SetToSI()

public void SetToSI()

Text(OrbitLength)

public static string Text(UnitsData.OrbitLength units)

Parameters

units UnitsData.OrbitLength

Returns

string

Text(ModelLength)

public static string Text(UnitsData.ModelLength units)

Parameters

units UnitsData.ModelLength

Returns

string

Text(Time)

public static string Text(UnitsData.Time units)

Parameters

units UnitsData.Time

Returns

string

Text(Energy)

public static string Text(UnitsData.Energy units)

Parameters

units UnitsData.Energy

Returns

string

Text(Temp)

public static string Text(UnitsData.Temp units)

Parameters

units UnitsData.Temp

Returns

string

Text(Mass)

public static string Text(UnitsData.Mass units)

Parameters

units UnitsData.Mass

Returns

string

Text(Pressure)

public static string Text(UnitsData.Pressure units)

Parameters

units UnitsData.Pressure

Returns

string

Text(Angle)

public static string Text(UnitsData.Angle units)

Parameters

units UnitsData.Angle

Returns

string

Text(Force)

public static string Text(UnitsData.Force units)

Parameters

units UnitsData.Force

Returns

string

Text(Current)

public static string Text(UnitsData.Current units)

Parameters

units UnitsData.Current

Returns

string

Text(Voltage)

public static string Text(UnitsData.Voltage units)

Parameters

units UnitsData.Voltage

Returns

string

Text(Resistance)

public static string Text(UnitsData.Resistance units)

Parameters

units UnitsData.Resistance

Returns

string

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Operators

operator ==(UnitsData, UnitsData)

public static bool operator ==(UnitsData x1, UnitsData x2)

Parameters

x1 UnitsData

x2 UnitsData

Returns

bool

operator !=(UnitsData, UnitsData)

public static bool operator !=(UnitsData x1, UnitsData x2)

Parameters

x1 UnitsData

x2 UnitsData

Returns

bool

Connect with Ansys