Skip to main content

Entity

Struct Entity 

Source
#[non_exhaustive]
pub struct Entity { pub id: Option<u64>, pub layer: Option<String>, pub color: Color, pub linetype: Option<String>, pub lineweight: Lineweight, pub visible: bool, pub kind: EntityKind, pub attributes: Vec<Attribute>, pub props: Props, pub raw: Option<Raw>, }
Expand description

One drawn object.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: Option<u64>

Native identifier (DWG handle, DGN element id).

§layer: Option<String>

Layer name; None means the default layer.

§color: Color

Color.

§linetype: Option<String>

Linetype name; None means by layer.

§lineweight: Lineweight

Lineweight.

§visible: bool

Entity is displayed.

§kind: EntityKind

Geometry and type-specific data.

§attributes: Vec<Attribute>

Attached non-graphic data: DWG attributes, DGN tags, item-type properties.

§props: Props

Format-specific extras.

§raw: Option<Raw>

Original record bytes, kept only when crate::ReadOptions::keep_raw is set.

Implementations§

Source§

impl Entity

Source

pub fn transformed(&self, tf: &Transform) -> Entity

Returns a copy of this entity with its geometry and displayed attributes mapped by tf.

Circles and circular arcs that undergo anisotropic scaling are promoted to exact EntityKind::Ellipse entities. Format props are copied unchanged, except the direction props dgn.curve_start_tangent / dgn.curve_end_tangent, which are dropped unless tf only translates and scales uniformly by a positive factor.

Source§

impl Entity

Source

pub fn new(kind: EntityKind) -> Self

An entity with default symbology.

Source

pub fn point(position: Point3) -> Self

Constructs a EntityKind::Point entity.

Source

pub fn line(start: Point3, end: Point3) -> Self

Constructs a EntityKind::Line entity.

Source

pub fn polyline(points: impl IntoIterator<Item = Point3>, closed: bool) -> Self

Constructs a straight-segment EntityKind::Polyline in the world XY plane (normal = +Z).

Source

pub fn circle(center: Point3, radius: f64) -> Self

Constructs a EntityKind::Circle in the world XY plane (normal = +Z).

Source

pub fn arc( center: Point3, radius: f64, start_angle: f64, end_angle: f64, ) -> Self

Constructs a counter-clockwise EntityKind::Arc in the world XY plane (normal = +Z).

Source

pub fn text(position: Point3, height: f64, value: impl Into<String>) -> Self

Constructs a left-baseline EntityKind::Text entity in the world XY plane (normal = +Z).

Source

pub fn mtext(position: Point3, height: f64, plain: impl Into<String>) -> Self

Constructs a top-left EntityKind::MText entity from plain UTF-8 text.

Source

pub fn insert(block: impl Into<String>, position: Point3) -> Self

Constructs a unit-scale EntityKind::Insert block reference at position.

Source

pub fn on_layer(self, layer: impl Into<String>) -> Self

Assigns the entity’s layer name.

Source

pub fn with_color(self, color: Color) -> Self

Assigns the entity’s Color.

Source

pub fn with_linetype(self, linetype: impl Into<String>) -> Self

Assigns the entity’s linetype name.

Source

pub fn with_lineweight(self, lineweight: Lineweight) -> Self

Assigns the entity’s Lineweight.

Source

pub fn with_visible(self, visible: bool) -> Self

Source

pub fn with_prop(self, key: impl Into<String>, value: impl Into<Value>) -> Self

Inserts a key-value entry into Entity::props.

Source

pub fn with_attribute( self, tag: impl Into<String>, value: impl Into<Value>, ) -> Self

Appends a non-graphic Attribute tag/value pair to Entity::attributes.

Source§

impl Entity

Source

pub fn with_id(self, value: u64) -> Self

Sets Self::id to Some(value).

Source

pub fn with_kind(self, value: EntityKind) -> Self

Sets Self::kind.

Source

pub fn with_attributes(self, value: Vec<Attribute>) -> Self

Source

pub fn with_raw(self, value: Raw) -> Self

Sets Self::raw to Some(value).

Source

pub fn with_props(self, value: Props) -> Self

Source§

impl Entity

Source

pub fn resolved_color(&self, doc: &Document) -> (u8, u8, u8)

Display color as RGB, resolved without block context (ByBlock becomes black).

Rules: Rgb as stored; Aci through the AutoCAD table, except ACI 7 (the “foreground” color, white on dark and black on light backgrounds) which is mapped to black to read on a white page; ByLayer uses the layer’s color (layer "0" when the entity has none; a missing layer, or a layer color that is itself ByLayer/ByBlock, gives black); ByBlock gives black here and the inserting entity’s color via Entity::resolved_color_in.

Source

pub fn resolved_color_in( &self, doc: &Document, ctx: &WalkContext<'_>, ) -> (u8, u8, u8)

Entity::resolved_color inside a Document::walk callback: ByBlock resolves to the color of the inserting entity and layer "0" to the inherited layer.

Source

pub fn bbox(&self) -> Option<BBox>

World-space bounding box of this entity without an additional placement transform.

Source

pub fn bbox_in(&self, transform: &Transform) -> Option<BBox>

Bounding box of this entity mapped through transform.

Trait Implementations§

Source§

impl Clone for Entity

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Entity

Source§

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

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

impl<'de> Deserialize<'de> for Entity

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Entity

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Entity

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Entity

Auto Trait Implementations§

§

impl Forget for Entity

§

impl Freeze for Entity

§

impl Move for Entity

§

impl RefUnwindSafe for Entity

§

impl Send for Entity

§

impl Sync for Entity

§

impl Unpin for Entity

§

impl UnsafeUnpin for Entity

§

impl UnwindSafe for Entity

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.