Skip to main content

Scale

Struct Scale 

Source
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: Handle

Object handle.

§owner_handle: Handle

Owner handle (SCALELIST dictionary).

§name: String

Scale name. DXF code: 300

§paper_units: f64

Paper units value. The number of paper units for this scale. DXF code: 140

§drawing_units: f64

Drawing units value. The number of drawing units for this scale. DXF code: 141

§is_unit_scale: bool

Whether this is a unit scale (1:1). DXF code: 290

§is_temporary: bool

Whether this scale is temporary (internal use).

Implementations§

Source§

impl Scale

Source

pub const OBJECT_NAME: &'static str = "SCALE"

Object type name.

Source

pub const SUBCLASS_MARKER: &'static str = "AcDbScale"

Subclass marker.

Source

pub fn new(name: &str, paper_units: f64, drawing_units: f64) -> Self

Creates a new Scale with the given name and values.

Source

pub fn unit_scale() -> Self

Creates a unit scale (1:1).

Source

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.

Source

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.

Source

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.

Source

pub fn is_reduction(&self) -> bool

Returns true if this is a reduction scale (factor < 1).

Source

pub fn is_enlargement(&self) -> bool

Returns true if this is an enlargement scale (factor > 1).

Source

pub fn ratio_string(&self) -> String

Returns the ratio as a string (e.g., “1:50” or “2:1”).

Source

pub fn scale_1_1() -> Self

1:1 scale (full size).

Source

pub fn scale_1_2() -> Self

1:2 scale (half size).

Source

pub fn scale_1_4() -> Self

1:4 scale.

Source

pub fn scale_1_5() -> Self

1:5 scale.

Source

pub fn scale_1_8() -> Self

1:8 scale.

Source

pub fn scale_1_10() -> Self

1:10 scale.

Source

pub fn scale_1_16() -> Self

1:16 scale.

Source

pub fn scale_1_20() -> Self

1:20 scale.

Source

pub fn scale_1_30() -> Self

1:30 scale.

Source

pub fn scale_1_40() -> Self

1:40 scale.

Source

pub fn scale_1_50() -> Self

1:50 scale.

Source

pub fn scale_1_100() -> Self

1:100 scale.

Source

pub fn scale_1_128() -> Self

1:128 scale.

Source

pub fn scale_2_1() -> Self

2:1 scale (enlarged).

Source

pub fn scale_4_1() -> Self

4:1 scale (enlarged).

Source

pub fn scale_8_1() -> Self

8:1 scale (enlarged).

Source

pub fn scale_10_1() -> Self

10:1 scale (enlarged).

Source

pub fn scale_100_1() -> Self

100:1 scale (enlarged).

Source

pub fn scale_1in_1ft() -> Self

1“ = 1’ scale (1:12).

Source

pub fn scale_half_in_1ft() -> Self

1/2“ = 1’ scale (1:24).

Source

pub fn scale_quarter_in_1ft() -> Self

1/4“ = 1’ scale (1:48).

Source

pub fn scale_eighth_in_1ft() -> Self

1/8“ = 1’ scale (1:96).

Source

pub fn scale_3_4in_1ft() -> Self

3/4“ = 1’ scale (1:16).

Source

pub fn scale_3_8in_1ft() -> Self

3/8“ = 1’ scale (1:32).

Source

pub fn scale_3_16in_1ft() -> Self

3/16“ = 1’ scale (1:64).

Source

pub fn scale_3_32in_1ft() -> Self

3/32“ = 1’ scale (1:128).

Source

pub fn scale_1_5in_1ft() -> Self

1 1/2“ = 1’ scale (1:8).

Source

pub fn scale_3in_1ft() -> Self

3“ = 1’ scale (1:4).

Source

pub fn scale_6in_1ft() -> Self

6“ = 1’ scale (1:2, half size).

Source

pub fn standard_metric_scales() -> Vec<Scale>

Returns all standard metric scales.

Source

pub fn standard_imperial_scales() -> Vec<Scale>

Returns all standard imperial/architectural scales.

Trait Implementations§

Source§

impl Clone for Scale

Source§

fn clone(&self) -> Scale

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Scale

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Scale

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Scale

Source§

fn eq(&self, other: &Scale) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Scale

Auto Trait Implementations§

§

impl Freeze for Scale

§

impl RefUnwindSafe for Scale

§

impl Send for Scale

§

impl Sync for Scale

§

impl Unpin for Scale

§

impl UnsafeUnpin for Scale

§

impl UnwindSafe for Scale

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.