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 ScaleRatio Either an object, string or array containing the scale information. See examples for more detail. The object form uses pageScale/worldScale with {value, unit}; the array form is [[pageValue, pageUnit], [worldValue, worldUnit]].
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 Argument Default Description
measurementValue number A value to be formatted as a fractional value or decimal value based on precision
unit string The unit of the measurement
precision number The precision of the measurement
useFractionalCharacters boolean <optional>
true Whether to use fractional characters (e.g. ΒΌ) instead of fractions (e.g. 1/4)
showTrailingZero boolean <optional>
false Whether to show trailing zeros for fractional values (e.g. 10'-1 0" vs 10'-1")
Returns:
A formatted value which is fractional when precision is 1/8, 1/16, 1/32 or 1/64, or a decimal value otherwise
Type
string

getScaleRatioAsArray()

Gets the scale ratio as an array containing the page and world scale values and units
Returns:
The scale ratio as a nested array, e.g. [[1, 'in'], [1, 'ft']]
Type
Array.<Array.<(number|string)>>

toString()

Converts the scale to a string representation in the format "pageValue pageUnit = worldValue worldUnit"
Returns:
String representation of the scale (e.g. "1 in = 1 ft")
Type
string