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 measurementValuenumber A value to be formatted as a fractional value or decimal value based on precision unitstring The unit of the measurement precisionnumber The precision of the measurement useFractionalCharactersboolean <optional>
true Whether to use fractional characters (e.g. ΒΌ) instead of fractions (e.g. 1/4) showTrailingZeroboolean <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