forked from ixmilia/dxf-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve compat when writing
BLOCK
/INSERT
on R12
- Loading branch information
Showing
9 changed files
with
180 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use dxf::entities::*; | ||
use dxf::enums::AcadVersion; | ||
use dxf::{Block, Drawing, Point}; | ||
|
||
pub fn all() -> dxf::DxfResult<()> { | ||
basic_block_and_insert()?; | ||
Ok(()) | ||
} | ||
|
||
fn basic_block_and_insert() -> dxf::DxfResult<()> { | ||
let mut drawing = Drawing::new(); | ||
drawing.header.version = AcadVersion::R12; // this example only tested on R12 | ||
|
||
// | ||
// create a block with a unique name... | ||
// | ||
let mut block = Block::default(); | ||
block.name = "my-block-name".to_string(); | ||
|
||
// | ||
// ...and populate it with entities | ||
// | ||
block.entities.push(Entity { | ||
common: Default::default(), | ||
specific: EntityType::Line(Line::new( | ||
// line from (0,0) to (1,1) | ||
Point::new(0.0, 0.0, 0.0), | ||
Point::new(1.0, 1.0, 0.0), | ||
)), | ||
}); | ||
|
||
// | ||
// add the block to the drawing | ||
// | ||
drawing.add_block(block); | ||
|
||
// | ||
// add a reference to the block with an `INSERT` entity | ||
// | ||
let mut insert = Insert::default(); | ||
insert.name = "my-block-name".to_string(); // use the same name as the block defined above | ||
insert.location = Point::new(3.0, 3.0, 0.0); // select the base-point of the insertion | ||
drawing.add_entity(Entity { | ||
common: Default::default(), | ||
specific: EntityType::Insert(insert), | ||
}); // the end result is a line from (3,3) to (4,4) | ||
|
||
drawing.save_file("basic_block_and_insert.dxf")?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
extern crate dxf; | ||
|
||
mod block_examples; | ||
mod line_type_examples; | ||
|
||
fn main() -> dxf::DxfResult<()> { | ||
block_examples::all()?; | ||
line_type_examples::all()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters