#[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
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: ColorColor.
linetype: Option<String>Linetype name; None means by layer.
lineweight: LineweightLineweight.
visible: boolEntity is displayed.
kind: EntityKindGeometry and type-specific data.
attributes: Vec<Attribute>Attached non-graphic data: DWG attributes, DGN tags, item-type properties.
props: PropsFormat-specific extras.
raw: Option<Raw>Original record bytes, kept only when crate::ReadOptions::keep_raw is set.
Implementations§
Source§impl Entity
impl Entity
Sourcepub fn transformed(&self, tf: &Transform) -> Entity
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
impl Entity
Sourcepub fn new(kind: EntityKind) -> Self
pub fn new(kind: EntityKind) -> Self
An entity with default symbology.
Sourcepub fn point(position: Point3) -> Self
pub fn point(position: Point3) -> Self
Constructs a EntityKind::Point entity.
Sourcepub fn line(start: Point3, end: Point3) -> Self
pub fn line(start: Point3, end: Point3) -> Self
Constructs a EntityKind::Line entity.
Sourcepub fn polyline(points: impl IntoIterator<Item = Point3>, closed: bool) -> Self
pub fn polyline(points: impl IntoIterator<Item = Point3>, closed: bool) -> Self
Constructs a straight-segment EntityKind::Polyline in the world XY plane (normal = +Z).
Sourcepub fn circle(center: Point3, radius: f64) -> Self
pub fn circle(center: Point3, radius: f64) -> Self
Constructs a EntityKind::Circle in the world XY plane (normal = +Z).
Sourcepub fn arc(
center: Point3,
radius: f64,
start_angle: f64,
end_angle: f64,
) -> Self
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).
Sourcepub fn text(position: Point3, height: f64, value: impl Into<String>) -> Self
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).
Sourcepub fn mtext(position: Point3, height: f64, plain: impl Into<String>) -> Self
pub fn mtext(position: Point3, height: f64, plain: impl Into<String>) -> Self
Constructs a top-left EntityKind::MText entity from plain UTF-8 text.
Sourcepub fn insert(block: impl Into<String>, position: Point3) -> Self
pub fn insert(block: impl Into<String>, position: Point3) -> Self
Constructs a unit-scale EntityKind::Insert block reference at position.
Sourcepub fn with_color(self, color: Color) -> Self
pub fn with_color(self, color: Color) -> Self
Assigns the entity’s Color.
Sourcepub fn with_linetype(self, linetype: impl Into<String>) -> Self
pub fn with_linetype(self, linetype: impl Into<String>) -> Self
Assigns the entity’s linetype name.
Sourcepub fn with_lineweight(self, lineweight: Lineweight) -> Self
pub fn with_lineweight(self, lineweight: Lineweight) -> Self
Assigns the entity’s Lineweight.
Sourcepub fn with_visible(self, visible: bool) -> Self
pub fn with_visible(self, visible: bool) -> Self
Sets Entity::visible.
Sourcepub fn with_prop(self, key: impl Into<String>, value: impl Into<Value>) -> Self
pub fn with_prop(self, key: impl Into<String>, value: impl Into<Value>) -> Self
Inserts a key-value entry into Entity::props.
Sourcepub fn with_attribute(
self,
tag: impl Into<String>,
value: impl Into<Value>,
) -> Self
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
impl Entity
Sourcepub fn with_kind(self, value: EntityKind) -> Self
pub fn with_kind(self, value: EntityKind) -> Self
Sets Self::kind.
Sourcepub fn with_attributes(self, value: Vec<Attribute>) -> Self
pub fn with_attributes(self, value: Vec<Attribute>) -> Self
Sets Self::attributes.
Sourcepub fn with_props(self, value: Props) -> Self
pub fn with_props(self, value: Props) -> Self
Sets Self::props.
Source§impl Entity
impl Entity
Sourcepub fn resolved_color(&self, doc: &Document) -> (u8, u8, u8)
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.
Sourcepub fn resolved_color_in(
&self,
doc: &Document,
ctx: &WalkContext<'_>,
) -> (u8, u8, u8)
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.