pub struct Scale {
pub handle: Handle,
pub owner_handle: Handle,
pub name: String,
pub paper_units: f64,
pub drawing_units: f64,
pub is_unit_scale: bool,
pub is_temporary: bool,
}Expand description
Scale object.
Defines a named scale for dimension annotations and viewport scaling. Scales are stored in the ACAD_SCALELIST dictionary.
§DXF Information
- Object type: SCALE
- Subclass marker: AcDbScale
- DXF codes:
- 300: Scale name
- 140: Paper units value
- 141: Drawing units value
- 290: Is unit scale flag
§Example
use acadrust::objects::Scale;
let scale = Scale::new("1:50", 1.0, 50.0);
assert!((scale.factor() - 0.02).abs() < 1e-10);Fields§
§handle: HandleObject handle.
owner_handle: HandleOwner handle (SCALELIST dictionary).
name: StringScale name. DXF code: 300
paper_units: f64Paper units value. The number of paper units for this scale. DXF code: 140
drawing_units: f64Drawing units value. The number of drawing units for this scale. DXF code: 141
is_unit_scale: boolWhether this is a unit scale (1:1). DXF code: 290
is_temporary: boolWhether this scale is temporary (internal use).
Implementations§
Source§impl Scale
impl Scale
Sourcepub const OBJECT_NAME: &'static str = "SCALE"
pub const OBJECT_NAME: &'static str = "SCALE"
Object type name.
Sourcepub const SUBCLASS_MARKER: &'static str = "AcDbScale"
pub const SUBCLASS_MARKER: &'static str = "AcDbScale"
Subclass marker.
Sourcepub fn new(name: &str, paper_units: f64, drawing_units: f64) -> Self
pub fn new(name: &str, paper_units: f64, drawing_units: f64) -> Self
Creates a new Scale with the given name and values.
Sourcepub fn unit_scale() -> Self
pub fn unit_scale() -> Self
Creates a unit scale (1:1).
Sourcepub fn from_ratio(name: &str, paper: i32, drawing: i32) -> Self
pub fn from_ratio(name: &str, paper: i32, drawing: i32) -> Self
Creates a scale from a ratio (paper:drawing).
For example, from_ratio("1:50", 1, 50) creates a 1:50 scale.
Sourcepub fn factor(&self) -> f64
pub fn factor(&self) -> f64
Calculates the scale factor (paper_units / drawing_units).
For a 1:50 scale, the factor is 0.02 (1/50). For a 2:1 scale (enlargement), the factor is 2.0.
Sourcepub fn inverse_factor(&self) -> f64
pub fn inverse_factor(&self) -> f64
Calculates the inverse scale factor (drawing_units / paper_units).
For a 1:50 scale, the inverse factor is 50. For a 2:1 scale (enlargement), the inverse factor is 0.5.
Sourcepub fn is_reduction(&self) -> bool
pub fn is_reduction(&self) -> bool
Returns true if this is a reduction scale (factor < 1).
Sourcepub fn is_enlargement(&self) -> bool
pub fn is_enlargement(&self) -> bool
Returns true if this is an enlargement scale (factor > 1).
Sourcepub fn ratio_string(&self) -> String
pub fn ratio_string(&self) -> String
Returns the ratio as a string (e.g., “1:50” or “2:1”).
Sourcepub fn scale_1_10() -> Self
pub fn scale_1_10() -> Self
1:10 scale.
Sourcepub fn scale_1_16() -> Self
pub fn scale_1_16() -> Self
1:16 scale.
Sourcepub fn scale_1_20() -> Self
pub fn scale_1_20() -> Self
1:20 scale.
Sourcepub fn scale_1_30() -> Self
pub fn scale_1_30() -> Self
1:30 scale.
Sourcepub fn scale_1_40() -> Self
pub fn scale_1_40() -> Self
1:40 scale.
Sourcepub fn scale_1_50() -> Self
pub fn scale_1_50() -> Self
1:50 scale.
Sourcepub fn scale_1_100() -> Self
pub fn scale_1_100() -> Self
1:100 scale.
Sourcepub fn scale_1_128() -> Self
pub fn scale_1_128() -> Self
1:128 scale.
Sourcepub fn scale_10_1() -> Self
pub fn scale_10_1() -> Self
10:1 scale (enlarged).
Sourcepub fn scale_100_1() -> Self
pub fn scale_100_1() -> Self
100:1 scale (enlarged).
Sourcepub fn scale_1in_1ft() -> Self
pub fn scale_1in_1ft() -> Self
1“ = 1’ scale (1:12).
Sourcepub fn scale_half_in_1ft() -> Self
pub fn scale_half_in_1ft() -> Self
1/2“ = 1’ scale (1:24).
Sourcepub fn scale_quarter_in_1ft() -> Self
pub fn scale_quarter_in_1ft() -> Self
1/4“ = 1’ scale (1:48).
Sourcepub fn scale_eighth_in_1ft() -> Self
pub fn scale_eighth_in_1ft() -> Self
1/8“ = 1’ scale (1:96).
Sourcepub fn scale_3_4in_1ft() -> Self
pub fn scale_3_4in_1ft() -> Self
3/4“ = 1’ scale (1:16).
Sourcepub fn scale_3_8in_1ft() -> Self
pub fn scale_3_8in_1ft() -> Self
3/8“ = 1’ scale (1:32).
Sourcepub fn scale_3_16in_1ft() -> Self
pub fn scale_3_16in_1ft() -> Self
3/16“ = 1’ scale (1:64).
Sourcepub fn scale_3_32in_1ft() -> Self
pub fn scale_3_32in_1ft() -> Self
3/32“ = 1’ scale (1:128).
Sourcepub fn scale_1_5in_1ft() -> Self
pub fn scale_1_5in_1ft() -> Self
1 1/2“ = 1’ scale (1:8).
Sourcepub fn scale_3in_1ft() -> Self
pub fn scale_3in_1ft() -> Self
3“ = 1’ scale (1:4).
Sourcepub fn scale_6in_1ft() -> Self
pub fn scale_6in_1ft() -> Self
6“ = 1’ scale (1:2, half size).
Sourcepub fn standard_metric_scales() -> Vec<Scale>
pub fn standard_metric_scales() -> Vec<Scale>
Returns all standard metric scales.
Sourcepub fn standard_imperial_scales() -> Vec<Scale>
pub fn standard_imperial_scales() -> Vec<Scale>
Returns all standard imperial/architectural scales.