### Quick Start: Read and Write DXF files Source: https://docs.rs/acadrust Basic example demonstrating how to read a DXF file into a `CadDocument` and then write it back to a new DXF file. ```rust use acadrust::{CadDocument, DxfReader, DxfWriter}; // Read let doc = DxfReader::from_file("input.dxf")?.read()?; println!("Entities: {}", doc.entities().count()); // Write DxfWriter::new(&doc).write_to_file("output.dxf")?; ``` -------------------------------- ### Example: Create and Populate a Table in Rust Source: https://docs.rs/acadrust/latest/src/acadrust/entities/table.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to create a new table and set text content for its cells. This example illustrates basic table manipulation. ```rust /// # Example /// /// ```ignore /// use acadrust::entities::{Table, TableRow}; /// use acadrust::types::Vector3; /// /// // Create a 3x4 table /// let mut table = Table::new(Vector3::new(0.0, 0.0, 0.0), 3, 4); /// /// // Set header row /// table.set_cell_text(0, 0, "Name"); /// table.set_cell_text(0, 1, "Value"); /// table.set_cell_text(0, 2, "Unit"); /// table.set_cell_text(0, 3, "Notes"); /// /// // Add data rows /// table.set_cell_text(1, 0, "Length"); /// table.set_cell_text(1, 1, "100.0"); /// table.set_cell_text(1, 2, "mm"); /// ``` ``` -------------------------------- ### PlotSettings Example Source: https://docs.rs/acadrust/latest/acadrust/objects/struct.PlotSettings.html An example demonstrating how to create and configure a PlotSettings object. ```APIDOC ## Example ```rust use acadrust::objects::{PlotSettings, PlotRotation, PlotPaperUnits}; let mut settings = PlotSettings::new("Layout1"); settings.paper_size = "ISO_A4_(210.00_x_297.00_MM)".to_string(); settings.rotation = PlotRotation::Degrees90; settings.paper_units = PlotPaperUnits::Millimeters; ``` ``` -------------------------------- ### Scale Creation and Usage Example Source: https://docs.rs/acadrust/latest/acadrust/objects/struct.Scale.html?search=std%3A%3Avec Example demonstrating how to create a Scale object and use its `factor()` method. ```APIDOC ## §Example ```rust use acadrust::objects::Scale; let scale = Scale::new("1:50", 1.0, 50.0); assert!((scale.factor() - 0.02).abs() < 1e-10); ``` ``` -------------------------------- ### XRecord Creation Example Source: https://docs.rs/acadrust/latest/src/acadrust/objects/xrecord.rs.html?search= Demonstrates how to create a new XRecord and add various data types to it. ```rust /// # Example /// ```ignore /// use acadrust::objects::XRecord; /// /// let mut xrecord = XRecord::new(); /// xrecord.add_string(1, "Custom Data"); /// xrecord.add_double(40, 3.14159); /// xrecord.add_int32(90, 42); /// ``` ``` -------------------------------- ### SatVersion Search Examples Source: https://docs.rs/acadrust/latest/acadrust/entities/acis/types/struct.SatVersion.html?search= Examples of how to search for SatVersion entities. These demonstrate different query patterns. ```APIDOC ## Search Examples ### Example 1: Searching for a specific type ``` std::vec ``` ### Example 2: Searching for a type conversion ``` u32 -> bool ``` ### Example 3: Searching for generic type transformations ``` Option, (T -> U) -> Option ``` ``` -------------------------------- ### Table Example Usage Source: https://docs.rs/acadrust/latest/acadrust/entities/table/struct.Table.html An example demonstrating how to create and populate a table entity. ```APIDOC ## §Example ⓘ``` use acadrust::entities::{Table, TableRow}; use acadrust::types::Vector3; // Create a 3x4 table let mut table = Table::new(Vector3::new(0.0, 0.0, 0.0), 3, 4); // Set header row table.set_cell_text(0, 0, "Name"); table.set_cell_text(0, 1, "Value"); table.set_cell_text(0, 2, "Unit"); table.set_cell_text(0, 3, "Notes"); // Add data rows table.set_cell_text(1, 0, "Length"); table.set_cell_text(1, 1, "100.0"); table.set_cell_text(1, 2, "mm"); ``` ``` -------------------------------- ### Polyline3D Example Source: https://docs.rs/acadrust/latest/acadrust/entities/polyline3d/struct.Polyline3D.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Example demonstrating how to create and manipulate a Polyline3D entity. ```APIDOC ## §Example ```rust use acadrust::entities::Polyline3D; use acadrust::types::Vector3; let mut polyline = Polyline3D::new(); polyline.add_vertex(Vector3::new(0.0, 0.0, 0.0)); polyline.add_vertex(Vector3::new(10.0, 0.0, 5.0)); polyline.add_vertex(Vector3::new(10.0, 10.0, 10.0)); polyline.close(); ``` ``` -------------------------------- ### MLineStyle Example Usage Source: https://docs.rs/acadrust/latest/src/acadrust/objects/mlinestyle.rs.html Demonstrates how to create a new MLineStyle, set its description, and add elements to it. ```rust use acadrust::objects::{MLineStyle, MLineStyleElement}; use acadrust::types::Color; let mut style = MLineStyle::new("Custom"); style.description = "Custom multiline style".to_string(); style.add_element(MLineStyleElement::new(-0.5)); style.add_element(MLineStyleElement::new(0.5)); ``` -------------------------------- ### Block Search Examples Source: https://docs.rs/acadrust/latest/acadrust/entities/block/struct.Block.html?search= Examples of how to perform searches for blocks. These demonstrate different query patterns. ```APIDOC ## Block Search ### Description Provides methods for searching and filtering blocks within the AcadRust system. ### Example Searches - `std::vec` - `u32 -> bool` - `Option, (T -> U) -> Option` ``` -------------------------------- ### Example Searches for BreakOptionFlags_search Source: https://docs.rs/acadrust/latest/acadrust/entities/table/struct.BreakOptionFlags.html?search= These are example search queries that can be used with BreakOptionFlags_search. They demonstrate different patterns for searching types and type conversions. ```rust * std::vec ``` ```rust * u32 -> bool ``` ```rust * Option, (T -> U) -> Option ``` -------------------------------- ### Example Searches Source: https://docs.rs/acadrust/latest/acadrust/entities/acis/parser/struct.SatParser.html?search= Provides examples of search queries that can be performed. ```text std::vec ``` ```text u32 -> bool ``` ```text Option, (T -> U) -> Option ``` -------------------------------- ### Group Example Usage Source: https://docs.rs/acadrust/latest/acadrust/objects/struct.Group.html?search=std%3A%3Avec An example demonstrating how to create and manipulate a Group object. ```APIDOC ## Example ```rust use acadrust::objects::Group; use acadrust::types::Handle; let mut group = Group::new("MyGroup"); group.description = "A collection of related entities".to_string(); group.add_entity(Handle::new(100)); group.add_entity(Handle::new(101)); ``` ``` -------------------------------- ### MultiLeaderStyle Example Usage Source: https://docs.rs/acadrust/latest/acadrust/objects/struct.MultiLeaderStyle.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E An example demonstrating how to create and modify a MultiLeaderStyle object. ```APIDOC ## Example ⓘ``` use acadrust::objects::MultiLeaderStyle; let mut style = MultiLeaderStyle::new("MyStyle"); style.text_height = 0.25; style.arrowhead_size = 0.25; style.enable_landing = true; ``` ``` -------------------------------- ### Get Start Angle in Degrees Source: https://docs.rs/acadrust/latest/acadrust/objects/struct.MLineStyle.html Retrieves the start cap angle of the multiline style in degrees. ```rust pub fn start_angle_degrees(&self) -> f64; ``` -------------------------------- ### Example: Create and Populate a Table Source: https://docs.rs/acadrust/latest/acadrust/entities/table/struct.Table.html Demonstrates how to create a new table with specified dimensions and populate its cells with text data. ```rust use acadrust::entities::{Table, TableRow}; use acadrust::types::Vector3; // Create a 3x4 table let mut table = Table::new(Vector3::new(0.0, 0.0, 0.0), 3, 4); // Set header row table.set_cell_text(0, 0, "Name"); table.set_cell_text(0, 1, "Value"); table.set_cell_text(0, 2, "Unit"); table.set_cell_text(0, 3, "Notes"); // Add data rows table.set_cell_text(1, 0, "Length"); table.set_cell_text(1, 1, "100.0"); table.set_cell_text(1, 2, "mm"); ``` -------------------------------- ### Get MLINESTYLE Start Angle (Degrees) Source: https://docs.rs/acadrust/latest/src/acadrust/objects/mlinestyle.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the start cap angle of the multiline style in degrees. ```rust /// Get the start angle in degrees pub fn start_angle_degrees(&self) -> f64 { self.start_angle.to_degrees() } ``` -------------------------------- ### Example TableStyle usage Source: https://docs.rs/acadrust/latest/src/acadrust/objects/table_style.rs.html?search= Illustrates how to create a `TableStyle` and modify its properties like margins and cell text height. ```rust /// # Example /// /// ```ignore /// use acadrust::objects::TableStyle; /// /// let mut style = TableStyle::new("MyStyle"); /// style.horizontal_margin = 0.1; /// style.vertical_margin = 0.1; /// style.data_row_style.text_height = 0.2; /// ``` ``` -------------------------------- ### Arc::start_point() - Get the start point of the arc Source: https://docs.rs/acadrust/latest/src/acadrust/entities/arc.rs.html?search= Determines the 3D coordinates of the arc's starting point using its center, radius, and start angle. ```rust pub fn start_point(&self) -> Vector3 { Vector3::new( self.center.x + self.radius * self.start_angle.cos(), self.center.y + self.radius * self.start_angle.sin(), self.center.z, ) } ``` -------------------------------- ### Get MLineStyle Start Angle in Degrees Source: https://docs.rs/acadrust/latest/src/acadrust/objects/mlinestyle.rs.html Retrieves the start angle of the multiline style, converted from radians to degrees. ```rust pub fn start_angle_degrees(&self) -> f64 { self.start_angle.to_degrees() } ``` -------------------------------- ### Get Arc Start Point Source: https://docs.rs/acadrust/latest/acadrust/entities/arc/struct.Arc.html?search=std%3A%3Avec Determines and returns the 3D coordinates of the arc's starting point. This is calculated based on the arc's center, radius, and start angle. ```rust pub fn start_point(&self) -> Vector3 ``` -------------------------------- ### Create PDF Underlay Source: https://docs.rs/acadrust/latest/src/acadrust/entities/underlay.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates creating a PDF Underlay using a convenience constructor and verifies its type and entity name. ```rust let underlay = Underlay::pdf(); assert_eq!(underlay.underlay_type, UnderlayType::Pdf); assert_eq!(underlay.entity_name(), "PDFUNDERLAY"); ``` -------------------------------- ### handle_start Source: https://docs.rs/acadrust/latest/acadrust/io/dwg/dwg_stream_readers/merged_reader/struct.DwgMergedReader.html Gets the bit position where the handle stream starts. ```APIDOC ## pub fn handle_start(&self) -> i64 ### Description Get the bit position where the handle stream starts. For R2007: this equals the RL (total_size_bits) field. Returns 0 if not set (pre-R2007 three-stream or no handle reader). ### Returns The starting bit position of the handle stream as an i64. ``` -------------------------------- ### Example Usage Source: https://docs.rs/acadrust/latest/acadrust/objects/struct.Scale.html?search=u32+-%3E+bool Demonstrates how to create a Scale object and verify its scale factor. ```APIDOC ## Example ```rust use acadrust::objects::Scale; let scale = Scale::new("1:50", 1.0, 50.0); assert!((scale.factor() - 0.02).abs() < 1e-10); ``` ``` -------------------------------- ### Ray Construction and Utility Methods (from tests) Source: https://docs.rs/acadrust/latest/src/acadrust/entities/ray.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to create and use Ray entities, including static constructors and utility functions. ```APIDOC ## Ray Construction and Utility Methods ### Description Examples of creating and utilizing Ray objects, including static constructors and methods for point manipulation and geometric relationships. ### Constructors - `Ray::new(base_point: Vector3, direction: Vector3)` - Creates a new Ray with a specified base point and direction. The direction vector is normalized internally. - `Ray::from_points(start_point: Vector3, end_point: Vector3)` - Creates a new Ray originating from `start_point` and directed towards `end_point`. The direction is calculated and normalized. - `Ray::along_x(base_point: Vector3)` - Creates a Ray originating from `base_point` with its direction along the positive X-axis. - `Ray::along_y(base_point: Vector3)` - Creates a Ray originating from `base_point` with its direction along the positive Y-axis. ### Utility Methods - `point_at(&self, t: f64) -> Vector3` - Calculates a point along the ray at a given distance `t` from the base point. For `t < 0`, it returns the base point. - `closest_point(&self, point: Vector3) -> Vector3` - Finds the closest point on the ray to a given external point. - `distance_to_point(&self, point: Vector3) -> f64` - Calculates the shortest distance from the ray to a given external point. - `is_parallel_to(&self, other: &Ray, tolerance: f64) -> bool` - Checks if this ray is parallel to another ray within a given tolerance. - `is_perpendicular_to(&self, other: &Ray, tolerance: f64) -> bool` - Checks if this ray is perpendicular to another ray within a given tolerance. ``` -------------------------------- ### DwgFileHeaderWriterAC18::handle_section_offset Source: https://docs.rs/acadrust/latest/acadrust/io/dwg/file_headers/file_header_ac18/struct.DwgFileHeaderWriterAC18.html Gets the file offset where the AcDbObjects section starts. ```APIDOC ## pub fn handle_section_offset(&self) -> usize ### Description Get the file offset where the AcDbObjects section starts. For AC18, this is always 0 because object handles are relative to the decompressed section data, not the file. ### Returns The file offset of the AcDbObjects section. ``` -------------------------------- ### LeaderLine::start_point Source: https://docs.rs/acadrust/latest/acadrust/entities/multileader/struct.LeaderLine.html?search=u32+-%3E+bool Gets the first point (start point) of the leader line. ```APIDOC ## pub fn start_point(&self) -> Option ### Description Gets the start point (first point). ### Returns - `Option` - An `Option` containing the start `Vector3` point, or `None` if the leader line has no points. ``` -------------------------------- ### Quick Start: Read and Write DWG files Source: https://docs.rs/acadrust Demonstrates reading a DWG file, creating a new `CadDocument` with a red `Line` entity, and writing it to a new DWG file. ```rust use acadrust::{CadDocument, DwgWriter}; use acadrust::io::dwg::DwgReader; use acadrust::entities::*; use acadrust::types::{Color, Vector3}; // Read let mut reader = DwgReader::from_file("input.dwg")?; let doc = reader.read()?; // Create and write let mut doc = CadDocument::new(); let mut line = Line::from_coords(0.0, 0.0, 0.0, 100.0, 50.0, 0.0); line.common.color = Color::RED; doc.add_entity(EntityType::Line(line))?; DwgWriter::write_to_file("output.dwg", &doc)?; ``` -------------------------------- ### DwgMergedWriter::handle_start_bits Source: https://docs.rs/acadrust/latest/acadrust/io/dwg/dwg_stream_writers/merged_writer/struct.DwgMergedWriter.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Gets the bit position where the handle section starts in the merged data. ```APIDOC ## DwgMergedWriter::handle_start_bits ### Description Get the bit position where the handle section starts in the merged data. Used by R2010+ record framing to compute MC handle_bits. ### Signature `pub fn handle_start_bits(&self) -> i64` ``` -------------------------------- ### Create and Configure MLineStyle Source: https://docs.rs/acadrust/latest/acadrust/objects/struct.MLineStyle.html Demonstrates how to create a new MLineStyle with a custom name and description, and add elements to define its appearance. ```rust use acadrust::objects::{MLineStyle, MLineStyleElement}; use acadrust::types::Color; let mut style = MLineStyle::new("Custom"); style.description = "Custom multiline style".to_string(); style.add_element(MLineStyleElement::new(-0.5)); style.add_element(MLineStyleElement::new(0.5)); ``` -------------------------------- ### Get Line Length Source: https://docs.rs/acadrust/latest/src/acadrust/entities/line.rs.html Calculates and returns the Euclidean distance between the start and end points of the line. ```rust /// Get the length of the line pub fn length(&self) -> f64 { self.start.distance(&self.end) } ``` -------------------------------- ### Create Underlay Definitions Source: https://docs.rs/acadrust/latest/src/acadrust/entities/underlay.rs.html?search= Demonstrates creating different types of underlay definitions (PDF, DWF, DGN) and verifying their entity names. ```rust let pdf_def = UnderlayDefinition::new(UnderlayType::Pdf); assert_eq!(pdf_def.entity_name(), "PDFDEFINITION"); let dwf_def = UnderlayDefinition::new(UnderlayType::Dwf); assert_eq!(dwf_def.entity_name(), "DWFDEFINITION"); let dgn_def = UnderlayDefinition::new(UnderlayType::Dgn); assert_eq!(dgn_def.entity_name(), "DGNDEFINITION"); ``` -------------------------------- ### Get the start point Source: https://docs.rs/acadrust/latest/src/acadrust/entities/polyline3d.rs.html?search= Returns the position of the first vertex in the polyline. Returns None if the polyline is empty. ```rust pub fn start_point(&self) -> Option { self.vertices.first().map(|v| v.position) } ``` -------------------------------- ### UnknownEntity Search Examples Source: https://docs.rs/acadrust/latest/acadrust/entities/unknown_entity/struct.UnknownEntity.html?search= Demonstrates various ways to search for UnknownEntity instances or related types. These examples cover simple type searches, type conversions, and more complex generic transformations. ```APIDOC ## Search Examples This section provides examples of how to perform searches related to `UnknownEntity` and other types. ### Basic Type Search To search for a specific type like `std::vec`: ```rust // Example: Search for std::vec // This would typically involve a function call or macro usage not detailed here. ``` ### Type Conversion Search To search for type conversions, such as from `u32` to `bool`: ```rust // Example: Search for u32 -> bool conversion // This implies checking for the existence or applicability of such a conversion. ``` ### Generic Type Transformation Search To search for more complex generic transformations, like `Option, (T -> U) -> Option`: ```rust // Example: Search for Option, (T -> U) -> Option // This demonstrates searching for a pattern involving Option and a type transformation. ``` ### Note on Implementation The exact methods or functions to perform these searches are not detailed in the provided source. The examples above illustrate the *patterns* of searches that can be performed. ``` -------------------------------- ### Viewport Example Usage Source: https://docs.rs/acadrust/latest/src/acadrust/entities/viewport.rs.html Demonstrates how to create and configure a Viewport entity, setting its center, dimensions, view target, direction, and custom scale. ```rust use acadrust::entities::Viewport; use acadrust::types::Vector3; let mut viewport = Viewport::new(); vieport.center = Vector3::new(5.0, 5.0, 0.0); vieport.width = 10.0; vieport.height = 8.0; vieport.view_target = Vector3::new(0.0, 0.0, 0.0); vieport.view_direction = Vector3::new(0.0, 0.0, 1.0); vieport.custom_scale = 0.5; // 1:2 scale ``` -------------------------------- ### Get Normalized Direction Vector Source: https://docs.rs/acadrust/latest/src/acadrust/entities/line.rs.html?search=u32+-%3E+bool Calculates the normalized vector pointing from the start point to the end point of the line. ```rust pub fn direction(&self) -> Vector3 { (self.end - self.start).normalize() } ``` -------------------------------- ### Get the direction vector Source: https://docs.rs/acadrust/latest/acadrust/entities/line/struct.Line.html?search=std%3A%3Avec Returns a normalized vector representing the direction from the start point to the end point of the line. ```rust pub fn direction(&self) -> Vector3 ``` -------------------------------- ### MLineStyle Example Usage Source: https://docs.rs/acadrust/latest/acadrust/objects/struct.MLineStyle.html Demonstrates how to create and configure a custom MLineStyle object using its associated methods. ```APIDOC ## Example ```rust use acadrust::objects::{MLineStyle, MLineStyleElement}; use acadrust::types::Color; let mut style = MLineStyle::new("Custom"); style.description = "Custom multiline style".to_string(); style.add_element(MLineStyleElement::new(-0.5)); style.add_element(MLineStyleElement::new(0.5)); ``` ``` -------------------------------- ### DwgFileHeaderWriterAC21::handle_section_offset Source: https://docs.rs/acadrust/latest/acadrust/io/dwg/file_headers/file_header_ac21/struct.DwgFileHeaderWriterAC21.html?search=u32+-%3E+bool Gets the file offset where the AcDbObjects section starts. For AC21, handles are relative to decompressed section data. ```APIDOC ## pub fn handle_section_offset(&self) -> usize Get the file offset where the AcDbObjects section starts. For AC21, handles are relative to decompressed section data (always 0). ``` -------------------------------- ### Create and Initialize a Table Source: https://docs.rs/acadrust/latest/src/acadrust/entities/table.rs.html?search=std%3A%3Avec Demonstrates creating a new table with specified dimensions and an insertion point. Used for basic table setup. ```rust let mut table = Table::new(Vector3::ZERO, 2, 2); ``` -------------------------------- ### Viewport Creation and Basic Configuration Source: https://docs.rs/acadrust/latest/acadrust/entities/viewport/struct.Viewport.html Demonstrates how to create a new Viewport and set its basic properties like center, width, height, view target, and view direction. ```APIDOC ## `Viewport::new()` ### Description Creates a new viewport with default settings. ### Method `pub fn new() -> Self` ## `Viewport::with_size(center: Vector3, width: f64, height: f64)` ### Description Creates a viewport with a specific size and position. ### Method `pub fn with_size(center: Vector3, width: f64, height: f64) -> Self` ## `Viewport::model_space()` ### Description Creates a viewport specifically for model space, typically with ID 1. ### Method `pub fn model_space() -> Self` ## `Viewport::set_view_target(&mut self, target: Vector3)` ### Description Sets the point in space that the viewport is focused on. ### Method `pub fn set_view_target(&mut self, target: Vector3)` ## `Viewport::set_view_direction(&mut self, direction: Vector3)` ### Description Sets the direction from which the scene is viewed. ### Method `pub fn set_view_direction(&mut self, direction: Vector3)` ## `Viewport::set_view_height(&mut self, height: f64)` ### Description Adjusts the zoom level by setting the visible height in model space units. ### Method `pub fn set_view_height(&mut self, height: f64)` ## `Viewport::set_scale(&mut self, scale: f64)` ### Description Sets the scale factor for the viewport, defining the ratio between paper space and model space units. ### Method `pub fn set_scale(&mut self, scale: f64)` ## `Viewport::custom_scale` field ### Description Represents the custom scale factor applied to the viewport. ### Type `f64` ``` -------------------------------- ### Get Start Point Source: https://docs.rs/acadrust/latest/src/acadrust/entities/polyline3d.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns an `Option` representing the position of the first vertex in the polyline. Returns `None` if the polyline is empty. ```rust pub fn start_point(&self) -> Option { self.vertices.first().map(|v| v.position) } ``` -------------------------------- ### Quick Start: Read and Write DWG Files Source: https://docs.rs/acadrust/latest/src/acadrust/lib.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Illustrates reading a DWG file, creating a new CadDocument with a Line entity, and writing it to a DWG file using `DwgReader` and `DwgWriter`. ```rust use acadrust::{CadDocument, DwgWriter}; use acadrust::io::dwg::DwgReader; use acadrust::entities::*; use acadrust::types::{Color, Vector3}; // Read let mut reader = DwgReader::from_file("input.dwg")?; let doc = reader.read()?; // Create and write let mut doc = CadDocument::new(); let mut line = Line::from_coords(0.0, 0.0, 0.0, 100.0, 50.0, 0.0); line.common.color = Color::RED; doc.add_entity(EntityType::Line(line))?; DwgWriter::write_to_file("output.dwg", &doc)?; # Ok::<(), acadrust::error::DxfError>(()) ``` -------------------------------- ### Get Bounding Box Source: https://docs.rs/acadrust/latest/src/acadrust/entities/polyface_mesh.rs.html?search=u32+-%3E+bool Retrieves the axis-aligned bounding box of the PolyfaceMesh. This example creates a box and asserts its min and max extents. ```rust let mesh = PolyfaceMesh::create_box( Vector3::ZERO, Vector3::new(2.0, 3.0, 4.0), ); let bb = mesh.bounding_box(); assert_eq!(bb.min, Vector3::ZERO); assert_eq!(bb.max, Vector3::new(2.0, 3.0, 4.0)); ``` -------------------------------- ### handle_start Source: https://docs.rs/acadrust/latest/acadrust/io/dwg/dwg_stream_readers/merged_reader/struct.DwgMergedReader.html?search= Gets the bit position where the handle stream starts. For R2007, this equals the RL (total_size_bits) field. Returns 0 if not set. ```APIDOC ## pub fn handle_start(&self) -> i64 ### Description Get the bit position where the handle stream starts. For R2007: this equals the RL (total_size_bits) field. Returns 0 if not set (pre-R2007 three-stream or no handle reader). ### Method `&self` ### Return Value - **i64** - The bit position where the handle stream starts. ``` -------------------------------- ### Create and Test Dictionary Source: https://docs.rs/acadrust/latest/src/acadrust/objects/mod.rs.html?search=u32+-%3E+bool Demonstrates creating a new dictionary, checking if it's empty, adding an entry with a key and handle, verifying the size, and retrieving the entry. ```rust let mut dict = Dictionary::new(); assert!(dict.is_empty()); dict.add_entry("KEY1", Handle::new(100)); assert_eq!(dict.len(), 1); assert_eq!(dict.get("KEY1"), Some(Handle::new(100))); assert_eq!(dict.get("KEY2"), None); ``` -------------------------------- ### Read DWG Wipeout Variables Source: https://docs.rs/acadrust/latest/src/acadrust/io/dwg/dwg_stream_readers/object_reader/objects.rs.html?search= Reads wipeout variables from a DWG stream. This snippet is incomplete and only shows the start of the reader setup. ```rust let mut r = make_reader(v, d, |w| { w.write_bit_short(1); ``` -------------------------------- ### Get Arc Midpoint Source: https://docs.rs/acadrust/latest/src/acadrust/entities/arc.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Computes the 3D coordinates of the arc's midpoint. This is calculated by finding the angle halfway between the start and end angles. ```rust /// Get the midpoint of the arc pub fn midpoint(&self) -> Vector3 { let mid_angle = self.start_angle + self.sweep_angle() / 2.0; Vector3::new( self.center.x + self.radius * mid_angle.cos(), self.center.y + self.radius * mid_angle.sin(), self.center.z, ) } ``` -------------------------------- ### Get AcDbObjects Section Offset Source: https://docs.rs/acadrust/latest/src/acadrust/io/dwg/file_headers/file_header_ac21.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the starting offset for the AcDbObjects section. For AC21, offsets are relative to decompressed section data, which is always 0. ```rust /// Get the file offset where the AcDbObjects section starts. /// /// For AC21, handles are relative to decompressed section data (always 0). pub fn handle_section_offset(&self) -> usize { 0 } ``` -------------------------------- ### Create and Configure RasterImage Source: https://docs.rs/acadrust/latest/acadrust/entities/raster_image/struct.RasterImage.html Demonstrates creating a new RasterImage with a file path, insertion point, and pixel dimensions. It also shows how to set the display width and adjust brightness and contrast. ```rust use acadrust::entities::RasterImage; use acadrust::types::Vector3; // Create a raster image at a specific location let mut image = RasterImage::new( "photo.jpg", Vector3::new(0.0, 0.0, 0.0), // insertion point 1920.0, // pixel width 1080.0, // pixel height ); // Scale to 10 units wide (maintaining aspect ratio) image.set_width(10.0); // Adjust display properties image.brightness = 60; image.contrast = 50; ``` -------------------------------- ### Get First Entry by Code Source: https://docs.rs/acadrust/latest/src/acadrust/objects/xrecord.rs.html?search=u32+-%3E+bool Retrieves the first XRecordEntry that matches a given code. ```APIDOC ## get_first_by_code ### Description Gets the first entry in the XRecord that has a specific code. ### Method `pub fn get_first_by_code(&self, code: i32) -> Option<&XRecordEntry>` ### Parameters - **code** (i32) - The code to search for. ### Returns - `Option<&XRecordEntry>` - An optional reference to the first matching XRecordEntry, or `None` if no entry with the given code is found. ``` -------------------------------- ### Get edges of a MeshFace Source: https://docs.rs/acadrust/latest/src/acadrust/entities/mesh.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E The `edges` method returns a vector of tuples, where each tuple represents the start and end vertex indices of an edge forming the face. ```rust pub fn edges(&self) -> Vec<(usize, usize)> { if self.vertices.is_empty() { return Vec::new(); } let mut edges = Vec::with_capacity(self.vertices.len()); for i in 0..self.vertices.len() { let next = (i + 1) % self.vertices.len(); edges.push((self.vertices[i], self.vertices[next])); } edges } ``` -------------------------------- ### Polyline3D Example Source: https://docs.rs/acadrust/latest/src/acadrust/entities/polyline3d.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to create a new Polyline3D entity, add vertices with specified 3D coordinates, and close the polyline. ```rust /// Polyline3D entity - a 3D polyline with vertices in 3D space /// /// Unlike 2D polylines, 3D polylines have vertices with full 3D coordinates /// and no bulge or width properties. They are commonly used for representing /// 3D curves and paths. /// /// # DXF Structure /// POLYLINE entity followed by VERTEX entities, terminated by SEQEND /// /// # Example /// ```ignore /// use acadrust::entities::Polyline3D; /// use acadrust::types::Vector3; /// /// let mut polyline = Polyline3D::new(); /// polyline.add_vertex(Vector3::new(0.0, 0.0, 0.0)); /// polyline.add_vertex(Vector3::new(10.0, 0.0, 5.0)); /// polyline.add_vertex(Vector3::new(10.0, 10.0, 10.0)); /// polyline.close(); /// ``` #[derive(Debug, Clone, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Polyline3D { /// Common entity properties pub common: EntityCommon, /// Polyline flags ``` -------------------------------- ### Arc::midpoint() - Get the midpoint of the arc Source: https://docs.rs/acadrust/latest/src/acadrust/entities/arc.rs.html?search= Finds the 3D coordinates of the arc's midpoint by calculating the angle halfway between the start and end angles. ```rust pub fn midpoint(&self) -> Vector3 { let mid_angle = self.start_angle + self.sweep_angle() / 2.0; Vector3::new( self.center.x + self.radius * mid_angle.cos(), self.center.y + self.radius * mid_angle.sin(), self.center.z, ) } ``` -------------------------------- ### Create and Configure a Viewport Source: https://docs.rs/acadrust/latest/acadrust/entities/viewport/struct.Viewport.html Demonstrates how to create a new Viewport and set its basic properties like center, width, height, view target, view direction, and custom scale. ```rust use acadrust::entities::Viewport; use acadrust::types::Vector3; let mut viewport = Viewport::new(); viewport.center = Vector3::new(5.0, 5.0, 0.0); viewport.width = 10.0; viewport.height = 8.0; viewport.view_target = Vector3::new(0.0, 0.0, 0.0); viewport.view_direction = Vector3::new(0.0, 0.0, 1.0); viewport.custom_scale = 0.5; // 1:2 scale ``` -------------------------------- ### Create and Initialize a Group Source: https://docs.rs/acadrust/latest/acadrust/objects/struct.Group.html?search= Demonstrates how to create a new Group with a name, set its description, and add entities using their handles. Ensure Handle and Group are in scope. ```rust use acadrust::objects::Group; use acadrust::types::Handle; let mut group = Group::new("MyGroup"); group.description = "A collection of related entities".to_string(); group.add_entity(Handle::new(100)); group.add_entity(Handle::new(101)); ``` -------------------------------- ### Result unwrap_err_unchecked Example (Err) Source: https://docs.rs/acadrust/latest/acadrust/error/type.Result.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows how to use unwrap_err_unchecked to get the Err value without checking. This is unsafe and should only be used when the Result is guaranteed to be Err. ```rust let x: Result = Err("emergency failure"); assert_eq!(unsafe { x.unwrap_err_unchecked() }, "emergency failure"); ``` -------------------------------- ### Result unwrap_unchecked Example (Ok) Source: https://docs.rs/acadrust/latest/acadrust/error/type.Result.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows how to use unwrap_unchecked to get the Ok value without checking. This is unsafe and should only be used when the Result is guaranteed to be Ok. ```rust let x: Result = Ok(2); assert_eq!(unsafe { x.unwrap_unchecked() }, 2); ``` -------------------------------- ### Example Searches for TextStyle Source: https://docs.rs/acadrust/latest/acadrust/tables/textstyle/struct.TextStyle.html?search= Demonstrates common search patterns for TextStyle, including module paths, type conversions, and generic type transformations. ```rust * std::vec ``` ```rust * u32 -> bool ``` ```rust * Option, (T -> U) -> Option ``` -------------------------------- ### Get LeaderLine Start Point Source: https://docs.rs/acadrust/latest/acadrust/entities/multileader/struct.LeaderLine.html Returns the first point (vertex) of the leader line, if any points exist. Returns None if the leader line has no points. ```rust pub fn start_point(&self) -> Option ``` -------------------------------- ### XLine Creation and Basic Methods Source: https://docs.rs/acadrust/latest/src/acadrust/entities/xline.rs.html Demonstrates how to create an XLine entity and use basic methods like setting direction and applying builder patterns for layer and color. ```APIDOC ## XLine Methods ### `new(base_point: Vector3, direction: Vector3) -> XLine` Creates a new XLine with a specified base point and direction. The direction vector will be normalized. ### `from_points(p1: Vector3, p2: Vector3) -> XLine` Creates an XLine defined by two points. The base point will be `p1` and the direction will be from `p1` to `p2`. ### `horizontal(base_point: Vector3) -> XLine` Creates a horizontal XLine (parallel to the X-axis) at the specified base point. ### `point_at(t: f64) -> Vector3` Calculates a point on the XLine at a given parameter `t`. `t=0` is the base point. ### `closest_point(point: Vector3) -> Vector3` Finds the point on the XLine that is closest to the given `point`. ### `intersection(other: &XLine) -> Option` Calculates the intersection point between this XLine and another XLine. Returns `Some(point)` if they intersect, `None` otherwise (including if they are parallel or coincident). ### `set_direction(&mut self, direction: Vector3)` Sets the direction vector of the XLine. The provided vector will be normalized. ### `with_layer(mut self, layer: impl Into) -> Self` Builder method to set the layer for the XLine. ### `with_color(mut self, color: Color) -> Self` Builder method to set the color for the XLine. ``` -------------------------------- ### Viewport Creation and Configuration Source: https://docs.rs/acadrust/latest/acadrust/entities/viewport/struct.Viewport.html?search=std%3A%3Avec Demonstrates how to create and configure a Viewport entity using various methods and builder patterns. ```APIDOC ## Viewport Methods ### `new()` Create a new viewport with default settings. ```rust let mut viewport = Viewport::new(); ``` ### `with_size(center: Vector3, width: f64, height: f64) -> Self` Create a viewport with specific size and position. ```rust let center = Vector3::new(5.0, 5.0, 0.0); let width = 10.0; let height = 8.0; let mut viewport = Viewport::with_size(center, width, height); ``` ### `model_space() -> Self` Create a viewport for model space (ID 1). ```rust let mut viewport = Viewport::model_space(); ``` ### Builder Methods These methods allow for fluent configuration of Viewport properties. #### `with_center(self, center: Vector3) -> Self` Builder: Set center. ```rust let center = Vector3::new(5.0, 5.0, 0.0); let viewport = Viewport::new().with_center(center); ``` #### `with_view_target(self, target: Vector3) -> Self` Builder: Set view target. ```rust let target = Vector3::new(0.0, 0.0, 0.0); let viewport = Viewport::new().with_view_target(target); ``` #### `with_view_direction(self, direction: Vector3) -> Self` Builder: Set view direction. ```rust let direction = Vector3::new(0.0, 0.0, 1.0); let viewport = Viewport::new().with_view_direction(direction); ``` #### `with_scale(self, scale: f64) -> Self` Builder: Set scale. ```rust let viewport = Viewport::new().with_scale(0.5); ``` #### `with_locked(self) -> Self` Builder: Set locked. ```rust let viewport = Viewport::new().with_locked(); ``` ``` -------------------------------- ### Get Handle Start Bit Position Source: https://docs.rs/acadrust/latest/src/acadrust/io/dwg/dwg_stream_writers/merged_writer.rs.html?search= Retrieves the bit position where the handle section begins in the merged DWG data. This is used for record framing in R2010+ versions. ```rust /// Get the bit position where the handle section starts in the merged data. /// Used by R2010+ record framing to compute MC handle_bits. pub fn handle_start_bits(&self) -> i64 { self.handle_start_bits } ``` -------------------------------- ### Get Handle Start Bits Source: https://docs.rs/acadrust/latest/src/acadrust/io/dwg/dwg_stream_writers/merged_writer.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the bit position where the handle section begins in the merged data. This is used for R2010+ record framing to calculate MC handle_bits. ```rust pub fn handle_start_bits(&self) -> i64 { self.handle_start_bits } ``` -------------------------------- ### Create DGN Underlay Source: https://docs.rs/acadrust/latest/src/acadrust/entities/underlay.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates creating a DGN Underlay using a convenience constructor and verifies its type and entity name. ```rust let underlay = Underlay::dgn(); assert_eq!(underlay.underlay_type, UnderlayType::Dgn); assert_eq!(underlay.entity_name(), "DGNUNDERLAY"); ``` -------------------------------- ### Get the edges of a MeshFace Source: https://docs.rs/acadrust/latest/src/acadrust/entities/mesh.rs.html?search=std%3A%3Avec Calculates and returns a vector of tuples, where each tuple represents an edge of the face by its start and end vertex indices. Handles empty faces by returning an empty vector. ```rust pub fn edges(&self) -> Vec<(usize, usize)> { if self.vertices.is_empty() { return Vec::new(); } let mut edges = Vec::with_capacity(self.vertices.len()); for i in 0..self.vertices.len() { let next = (i + 1) % self.vertices.len(); edges.push((self.vertices[i], self.vertices[next])); } edges } ``` -------------------------------- ### Create a New XRecord Source: https://docs.rs/acadrust/latest/src/acadrust/objects/xrecord.rs.html?search=std%3A%3Avec Initializes a new, empty XRecord with default values. This is the starting point for adding custom data. ```rust pub fn new() -> Self { Self { handle: Handle::NULL, owner: Handle::NULL, name: String::new(), cloning_flags: DictionaryCloningFlags::NotApplicable, entries: Vec::new(), raw_data: Vec::new(), } } ``` -------------------------------- ### Get Handle Section Offset for AC18 Source: https://docs.rs/acadrust/latest/src/acadrust/io/dwg/file_headers/file_header_ac18.rs.html?search= Retrieves the starting file offset for the AcDbObjects section. For the AC18 format, this is always 0, as object handles are relative to the decompressed section data, not the file itself. ```rust pub fn handle_section_offset(&self) -> usize { 0 } ``` -------------------------------- ### Create DWF Underlay Source: https://docs.rs/acadrust/latest/src/acadrust/entities/underlay.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates creating a DWF Underlay using a convenience constructor and verifies its type and entity name. ```rust let underlay = Underlay::dwf(); assert_eq!(underlay.underlay_type, UnderlayType::Dwf); assert_eq!(underlay.entity_name(), "DWFUNDERLAY"); ``` -------------------------------- ### PolyfaceVertexFlags Search Examples Source: https://docs.rs/acadrust/latest/acadrust/entities/polyface_mesh/struct.PolyfaceVertexFlags.html?search= Examples demonstrating how to search for PolyfaceVertexFlags. These examples are illustrative and may require specific context within the AcadRust library. ```APIDOC ## Search PolyfaceVertexFlags ### Description This section provides examples of how to search for specific flags or patterns within PolyfaceVertexFlags. These searches are useful for identifying specific vertex properties or states. ### Example Searches - `std::vec` - `u32 -> bool` - `Option, (T -> U) -> Option` ``` -------------------------------- ### TableStyle Initialization and Usage Example Source: https://docs.rs/acadrust/latest/acadrust/objects/struct.TableStyle.html Demonstrates how to create a new TableStyle, set its margins, and modify data row text height. ```APIDOC ## Example ```rust use acadrust::objects::TableStyle; let mut style = TableStyle::new("MyStyle"); style.horizontal_margin = 0.1; style.vertical_margin = 0.1; style.data_row_style.text_height = 0.2; ``` ``` -------------------------------- ### Read R2000+ Fingerprint and Version GUIDs Source: https://docs.rs/acadrust/latest/src/acadrust/io/dwg/dwg_stream_readers/header_reader.rs.html?search=std%3A%3Avec Reads the fingerprint GUID and version GUID, which are string values introduced in DWG version R2000. ```rust h.fingerprint_guid = r.read_variable_text(); h.version_guid = r.read_variable_text(); ``` -------------------------------- ### Seqend Search Examples Source: https://docs.rs/acadrust/latest/acadrust/entities/seqend/struct.Seqend.html?search= Examples of how to search for Seqend entities. ```APIDOC ## Seqend Search ### Description Provides functionality to search for Seqend entities within the system. ### Example Searches - `std::vec` - `u32 -> bool` - `Option, (T -> U) -> Option` ``` -------------------------------- ### Initialize Root Dictionary and Standard Dictionaries Source: https://docs.rs/acadrust/latest/src/acadrust/document.rs.html?search= Sets up the root dictionary and populates it with handles for standard dictionaries like ACAD_COLOR, ACAD_VISUALSTYLE, ACAD_GROUP, ACAD_MLINESTYLE, ACAD_LAYOUT, ACAD_PLOTSETTINGS, and ACAD_MATERIAL. This is a foundational step for organizing DXF objects. ```rust root_dict.add_entry("ACAD_COLOR", self.header.acad_color_dict_handle); root_dict.add_entry("ACAD_VISUALSTYLE", self.header.acad_visualstyle_dict_handle); self.objects.insert(root_dict_handle, ObjectType::Dictionary(root_dict)); // -- ACAD_GROUP dictionary (empty) -- let mut group_dict = crate::objects::Dictionary::new(); group_dict.handle = self.header.acad_group_dict_handle; group_dict.owner = root_dict_handle; self.objects.insert(group_dict.handle, ObjectType::Dictionary(group_dict)); // -- ACAD_PLOTSETTINGS dictionary (empty) -- let mut plotsettings_dict = crate::objects::Dictionary::new(); plotsettings_dict.handle = self.header.acad_plotsettings_dict_handle; plotsettings_dict.owner = root_dict_handle; self.objects.insert(plotsettings_dict.handle, ObjectType::Dictionary(plotsettings_dict)); // -- ACAD_MATERIAL dictionary (empty, required R2004+) -- let mut material_dict = crate::objects::Dictionary::new(); material_dict.handle = self.header.acad_material_dict_handle; material_dict.owner = root_dict_handle; self.objects.insert(material_dict.handle, ObjectType::Dictionary(material_dict)); // -- ACAD_COLOR dictionary (empty, required R2004+) -- let mut color_dict = crate::objects::Dictionary::new(); color_dict.handle = self.header.acad_color_dict_handle; color_dict.owner = root_dict_handle; self.objects.insert(color_dict.handle, ObjectType::Dictionary(color_dict)); // -- ACAD_VISUALSTYLE dictionary (empty, required R2007+) -- let mut visualstyle_dict = crate::objects::Dictionary::new(); visualstyle_dict.handle = self.header.acad_visualstyle_dict_handle; visualstyle_dict.owner = root_dict_handle; self.objects.insert(visualstyle_dict.handle, ObjectType::Dictionary(visualstyle_dict)); ```