Class: Scale

Core. Scale

A class that encapsulates measurement scale information for converting from and to different units.

new Scale(scaleRatio [, precision])

Parameters:
Name Type Argument Description
scaleRatio object | string | Array.<Array.<(number|string)>> Either an object, string or array containing the scale information. See examples for more detail.
scaleObject.pageScale object <optional>
The page scale of the document
Properties
Name Type Description
value number The number value of the page scale
unit string The unit of the page scale, e.g. cm
scaleObject.worldScale object <optional>
The world scale
Properties
Name Type Description
value number The number value of the world scale
unit string The unit of the world scale, e.g. cm
precision number <optional>
The precision of the scale
Example
const scale1 = new Core.Scale({pageScale: {value: 1, unit: 'in'}, worldScale: {value: 1, unit: 'ft'}}, 0.01);
const scale2 = new Core.Scale([[1, 'in'], [1, 'ft']], 0.01);
const scale2 = new Core.Scale('1 in = 1 ft', 0.01);
const scale2 = new Core.Scale({pageScale: {value: 1, unit: 'in'}, worldScale: {value: 1, unit: 'ft'}});

Methods


<static> getFormattedValue(measurementValue, unit, precision, useFractionalCharacters, showTrailingZero)

A static method that returns the formatted value and unit.
Parameters:
Name Type Description
measurementValue number A value to be formatted to be fractional value or decimal value based on precision.
unit string The unit of the measurement.
precision number The precision of the measurement.
useFractionalCharacters boolean Whether to use fractional characters, e.g. ΒΌ as opposed to 1/4
showTrailingZero boolean Whether to show trailing zeros for fractional values, e.g. show 10'-1 0" if true, and show 10'-1" if false.
Returns:
A formatted value which is either fractional when precision is '1/8, 1/16, 1/32 or 1/64', or a decimal value if not
Type
string

getScaleRatioAsArray()

Returns:
Returns the values and units of the page scale and world scale in an array. For example: [[1, 'in'],[1, 'in']].
Type
Array.<Array.<(number|string)>>

toString()

Returns:
Returns string format of scale
Type
string