mod associative;
mod block_visibility;
mod class_object;
mod data_objects;
mod dynamic_block;
mod field;
mod dgn_linestyle;
mod dictionary_variable;
mod group;
mod image_definition;
mod mlinestyle;
mod multileader_style;
mod object_context_data;
mod plot_settings;
mod scale;
pub(crate) mod semantic_property;
mod sort_entities_table;
mod table_style;
mod xrecord;
mod stub_objects;
pub use associative::*;
pub use block_visibility::{
BlockEvalValue, BlockParameterConnection, BlockParameterPropertyInfo,
BlockVisibilityParameter, BlockVisibilityState,
};
pub use class_object::{
AcMeCommandHistory, AcMeScope, AcMeStateManager, ClassObject,
ClassObjectData, ContextDataEntry, ContextDataManager,
ContextDataSubManager, CsacDocumentOptions, CurvePath, DataLink,
DataLinkCustomData, DataTable, DataTableColumn, DataTableValue,
DetailViewStyle, GeoMapImage, GradientBackground,
GroundPlaneBackground, IblBackground, ImageBackground, LayerFilter,
LightList, LightListEntry, MentalRayRenderSettings, ModelDocViewStyle,
MotionPath, NavisworksModelDefinition, PartialViewingIndex,
PartialViewingIndexEntry, PersistentSubentityManager,
PointCloudColorMap, PointCloudColorRamp, PointCloudDefinition,
PointCloudDefinitionReactor, PointPath, RapidRtRenderSettings,
RenderEntry, RenderEnvironment, RenderGlobal, RenderSettings,
SectionGeometrySettings, SectionManager, SectionSettings,
SectionTypeSettings, SectionViewStyle, SkyLightBackground,
SolidBackground, SpatialIndex, Sun, SunStudy, SunStudyDate,
TvDeviceProperties, VbaProject, ViewRepModelSpaceViewSelectionSet,
ViewRepOrientation, ViewRepSectionDefinition, ViewRepSourceManager,
ViewRepStandard, ViewRep, ViewRepBlockPath, ViewRepBlockPathEntry,
ViewRepGuid, ViewRepModelSpaceSource, ViewRepObjectPath, ViewRepSketch,
ViewRepSketchGeometry, ViewRepSketchReference,
};
pub use data_objects::{
BreakData, BreakPointReference, CellStyleMap, DataObject, DataObjectData, IdBuffer,
Index, LayerIndex, LayerIndexEntry, PartialViewingFilter, TableGeometry,
TableGeometryCell,
};
pub use dynamic_block::{
BlockAction, BlockActionOffsets, BlockActionWithBasePoint, BlockAlignmentParameter,
BlockAngularConstraintParameter, BlockAngularConstraintParameterEntity, BlockArrayAction,
BlockBasePointAction, BlockBasePointParameter, BlockConnection, BlockConstraintParameter,
BlockDistanceConstraintParameter, BlockElement, BlockEvalExpression, BlockEvaluationEdge,
BlockEvaluationGraph, BlockEvaluationNode, BlockFlipAction, BlockFlipGrip,
BlockFlipParameter, BlockGrip, BlockGripExpression, BlockLinearConstraintParameter,
BlockLinearParameter, BlockLookupAction, BlockLookupParameter, BlockLookupRow,
BlockMoveAction, BlockOnePointParameter, BlockOrientedGrip, BlockParameter,
BlockParameterDependencyBody, BlockParameterProperty, BlockParameterValueSet,
BlockPointParameter, BlockPolarParameter, BlockPolarStretchAction, BlockRepresentationData,
BlockRotationParameter, BlockStretchAction, BlockStretchCode, BlockStretchHandle,
BlockTwoPointParameter, BlockUserParameter, BlockXYParameter, DynamicBlockData,
DynamicBlockObject, SolidHistory, SolidHistoryBoolean, SolidHistoryBox, SolidHistoryBrep,
SolidHistoryChamfer, SolidHistoryCone, SolidHistoryCylinder, SolidHistoryFillet, SolidHistoryLoft,
SolidHistoryNodeBase, SolidHistoryOperation, SolidHistoryPyramid, SolidHistoryRevolve,
SolidHistorySphere, SolidHistorySweep, SolidHistoryTorus,
};
pub use field::{Field, FieldChildValue, FieldList};
pub use dgn_linestyle::{
DgnLineStyleData, DgnLineStyleObject, DgnLsComponent, DgnLsComponentData,
DgnLsComponentType, DgnLsCompoundComponent, DgnLsCompoundEntry, DgnLsDefinition,
DgnLsInternalComponent, DgnLsPhaseMode, DgnLsPointComponent, DgnLsStroke,
DgnLsStrokePattern, DgnLsSymbolComponent, DgnLsSymbolReference,
};
pub use dictionary_variable::DictionaryVariable;
pub use group::Group;
pub use image_definition::{ImageDefinition, ImageDefinitionReactor, ResolutionUnit};
pub use crate::entities::underlay::UnderlayDefinition;
pub use mlinestyle::{MLineStyle, MLineStyleElement, MLineStyleFlags};
pub use object_context_data::{
DimContext, DimSubtype, EmbeddedMTextContext, HatchScaleContext, HatchViewContext,
LeaderContext, MTextAttributeContext, MTextColumns, MTextContext, ObjectContextData,
ObjectContextKind,
};
pub use multileader_style::{
BlockContentConnectionType, LeaderContentType, LeaderDrawOrderType,
LeaderLinePropertyOverrideFlags, MultiLeaderDrawOrderType, MultiLeaderPathType,
MultiLeaderPropertyOverrideFlags, MultiLeaderStyle, TextAlignmentType, TextAngleType,
TextAttachmentDirectionType, TextAttachmentType,
};
pub use plot_settings::{
PaperMargin, PlotFlags, PlotPaperUnits, PlotRotation, PlotSettings, PlotType, PlotWindow,
ScaledType, ShadePlotMode, ShadePlotResolutionLevel,
};
pub use scale::Scale;
pub use semantic_property::{
ProxyObject, ProxyObjectReference, ProxyPayload, ProxyPayloadEncoding,
ProxyPayloadRecord, ProxyReferenceKind,
RegisteredClassObject, SemanticProperty, SemanticPropertyValue,
};
pub use sort_entities_table::{SortEntsEntry, SortEntitiesTable};
pub use table_style::{
CellAlignment, RowCellStyle, TableBorderPropertyFlags, TableBorderType, TableCellBorder,
TableCellStylePropertyFlags, TableFlowDirection, TableStyle, TableStyleFlags,
TableContentFormat, TableGridFormat, TableCellStyleData, NamedTableCellStyle,
};
pub use xrecord::{
DictionaryCloningFlags, KnownXRecordKind, XRecord, XRecordEntry, XRecordSection,
XRecordValue, XRecordValueType,
};
pub use stub_objects::{
VisualStyle, VisualStyleProperty, VisualStylePropertyValue,
Material, MaterialColor, MaterialMap, MaterialProceduralValue, MaterialTexture,
GeoData, GeoDataMeshFace, GeoDataMeshPoint,
SpatialFilter, RasterVariables, BookColor, PlaceHolder,
DictionaryWithDefault, WipeoutVariables, StubObject,
};
use crate::types::Handle;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Dictionary {
pub handle: Handle,
pub owner: Handle,
pub entries: Vec<(String, Handle)>,
#[cfg_attr(feature = "serde", serde(default))]
pub hard_owner_entries: Vec<String>,
pub duplicate_cloning: i16,
pub hard_owner: bool,
pub reactors: Vec<Handle>,
pub xdictionary_handle: Option<Handle>,
}
impl Dictionary {
pub fn new() -> Self {
Self {
handle: Handle::NULL,
owner: Handle::NULL,
entries: Vec::new(),
hard_owner_entries: Vec::new(),
duplicate_cloning: 1,
hard_owner: false,
reactors: Vec::new(),
xdictionary_handle: None,
}
}
pub fn add_entry(&mut self, key: impl Into<String>, handle: Handle) {
self.entries.push((key.into(), handle));
}
pub fn set_entry_hard_owner(&mut self, key: &str, hard_owner: bool) {
self.hard_owner_entries
.retain(|name| !name.eq_ignore_ascii_case(key));
if hard_owner {
self.hard_owner_entries.push(key.to_string());
}
}
pub fn is_entry_hard_owner(&self, key: &str) -> bool {
self.hard_owner_entries
.iter()
.any(|name| name.eq_ignore_ascii_case(key))
}
pub fn is_canonical_hard_owner_key(key: &str) -> bool {
matches!(
key.to_ascii_uppercase().as_str(),
"ACAD_FIELD"
)
}
pub fn get(&self, key: &str) -> Option<Handle> {
self.entries
.iter()
.find(|(k, _)| k.eq_ignore_ascii_case(key))
.map(|(_, h)| *h)
}
pub fn len(&self) -> usize {
self.entries.len()
}
pub fn is_empty(&self) -> bool {
self.entries.is_empty()
}
}
impl Default for Dictionary {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Layout {
pub handle: Handle,
pub owner: Handle,
pub name: String,
pub flags: i16,
pub tab_order: i16,
pub min_limits: (f64, f64),
pub max_limits: (f64, f64),
pub insertion_base: (f64, f64, f64),
pub min_extents: (f64, f64, f64),
pub max_extents: (f64, f64, f64),
pub elevation: f64,
pub ucs_origin: (f64, f64, f64),
pub ucs_x_axis: (f64, f64, f64),
pub ucs_y_axis: (f64, f64, f64),
pub ucs_ortho_type: i16,
pub block_record: Handle,
pub viewport: Handle,
pub viewports: Vec<Handle>,
pub base_ucs: Handle,
pub named_ucs: Handle,
pub reactors: Vec<Handle>,
pub xdictionary_handle: Option<Handle>,
#[cfg_attr(feature = "serde", serde(skip))]
pub raw_plot_settings_codes: Option<Vec<(i32, String)>>,
pub paper_width: f64,
pub paper_height: f64,
pub plot_rotation: i16,
pub plot_flags: PlotFlags,
pub plot_page_name: String,
pub plot_printer_name: String,
pub paper_size: String,
pub plot_view_name: String,
pub plot_style_sheet: String,
pub plot_margin_left: f64,
pub plot_margin_bottom: f64,
pub plot_margin_right: f64,
pub plot_margin_top: f64,
pub plot_origin_x: f64,
pub plot_origin_y: f64,
pub plot_window_min_x: f64,
pub plot_window_min_y: f64,
pub plot_window_max_x: f64,
pub plot_window_max_y: f64,
pub plot_paper_units: i16,
pub plot_type: i16,
pub plot_scale_numerator: f64,
pub plot_scale_denominator: f64,
pub plot_scale_type: i16,
pub plot_scale_factor: f64,
pub paper_image_origin_x: f64,
pub paper_image_origin_y: f64,
pub shade_plot_mode: i16,
pub shade_plot_resolution: i16,
pub shade_plot_dpi: i16,
pub plot_view_handle: Handle,
pub visual_style_handle: Handle,
}
impl Layout {
pub fn new(name: impl Into<String>) -> Self {
Self {
handle: Handle::NULL,
owner: Handle::NULL,
name: name.into(),
flags: 0,
tab_order: 0,
min_limits: (0.0, 0.0),
max_limits: (0.0, 0.0),
insertion_base: (0.0, 0.0, 0.0),
min_extents: (0.0, 0.0, 0.0),
max_extents: (12.0, 9.0, 0.0),
elevation: 0.0,
ucs_origin: (0.0, 0.0, 0.0),
ucs_x_axis: (1.0, 0.0, 0.0),
ucs_y_axis: (0.0, 1.0, 0.0),
ucs_ortho_type: 0,
block_record: Handle::NULL,
viewport: Handle::NULL,
viewports: Vec::new(),
base_ucs: Handle::NULL,
named_ucs: Handle::NULL,
reactors: Vec::new(),
xdictionary_handle: None,
raw_plot_settings_codes: None,
paper_width: 0.0,
paper_height: 0.0,
plot_rotation: 0,
plot_flags: PlotFlags::default(),
plot_page_name: String::new(),
plot_printer_name: String::new(),
paper_size: String::new(),
plot_view_name: String::new(),
plot_style_sheet: String::new(),
plot_margin_left: 0.0,
plot_margin_bottom: 0.0,
plot_margin_right: 0.0,
plot_margin_top: 0.0,
plot_origin_x: 0.0,
plot_origin_y: 0.0,
plot_window_min_x: 0.0,
plot_window_min_y: 0.0,
plot_window_max_x: 0.0,
plot_window_max_y: 0.0,
plot_paper_units: 0,
plot_type: 5,
plot_scale_numerator: 1.0,
plot_scale_denominator: 1.0,
plot_scale_type: 0,
plot_scale_factor: 1.0,
paper_image_origin_x: 0.0,
paper_image_origin_y: 0.0,
shade_plot_mode: 0,
shade_plot_resolution: 0,
shade_plot_dpi: 300,
plot_view_handle: Handle::NULL,
visual_style_handle: Handle::NULL,
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ObjectType {
Dictionary(Dictionary),
Layout(Layout),
XRecord(XRecord),
Group(Group),
MLineStyle(MLineStyle),
ImageDefinition(ImageDefinition),
UnderlayDefinition(UnderlayDefinition),
PlotSettings(PlotSettings),
MultiLeaderStyle(MultiLeaderStyle),
TableStyle(TableStyle),
TableContent(crate::entities::Table),
Scale(Scale),
ObjectContextData(ObjectContextData),
SortEntitiesTable(SortEntitiesTable),
DictionaryVariable(DictionaryVariable),
VisualStyle(VisualStyle),
Material(Material),
ImageDefinitionReactor(ImageDefinitionReactor),
GeoData(GeoData),
SpatialFilter(SpatialFilter),
RasterVariables(RasterVariables),
BookColor(BookColor),
PlaceHolder(PlaceHolder),
DictionaryWithDefault(DictionaryWithDefault),
WipeoutVariables(WipeoutVariables),
BlockVisibilityParameter(BlockVisibilityParameter),
DynamicBlock(DynamicBlockObject),
Associative(AssociativeObject),
ClassObject(ClassObject),
DataObject(DataObject),
Field(Field),
FieldList(FieldList),
RegisteredClass(RegisteredClassObject),
DgnLineStyle(DgnLineStyleObject),
ProxyObject(ProxyObject),
Unknown {
type_name: String,
handle: Handle,
owner: Handle,
#[cfg_attr(feature = "serde", serde(skip))]
raw_dxf_codes: Option<Vec<(i32, String)>>,
#[cfg_attr(feature = "serde", serde(skip))]
raw_dwg_data: Option<Vec<u8>>,
raw_dwg_handle_bits: i64,
#[cfg_attr(feature = "serde", serde(skip))]
raw_dwg_version: Option<crate::types::DxfVersion>,
},
}
impl ObjectType {
pub(crate) fn set_handle(&mut self, handle: Handle) {
match self {
ObjectType::Dictionary(value) => value.handle = handle,
ObjectType::Layout(value) => value.handle = handle,
ObjectType::XRecord(value) => value.handle = handle,
ObjectType::Group(value) => value.handle = handle,
ObjectType::MLineStyle(value) => value.handle = handle,
ObjectType::ImageDefinition(value) => value.handle = handle,
ObjectType::UnderlayDefinition(value) => value.handle = handle,
ObjectType::PlotSettings(value) => value.handle = handle,
ObjectType::MultiLeaderStyle(value) => value.handle = handle,
ObjectType::TableStyle(value) => value.handle = handle,
ObjectType::TableContent(value) => value.common.handle = handle,
ObjectType::Scale(value) => value.handle = handle,
ObjectType::ObjectContextData(value) => value.handle = handle,
ObjectType::SortEntitiesTable(value) => value.handle = handle,
ObjectType::DictionaryVariable(value) => value.handle = handle,
ObjectType::VisualStyle(value) => value.handle = handle,
ObjectType::Material(value) => value.handle = handle,
ObjectType::ImageDefinitionReactor(value) => value.handle = handle,
ObjectType::GeoData(value) => value.handle = handle,
ObjectType::SpatialFilter(value) => value.handle = handle,
ObjectType::RasterVariables(value) => value.handle = handle,
ObjectType::BookColor(value) => value.handle = handle,
ObjectType::PlaceHolder(value) => value.handle = handle,
ObjectType::DictionaryWithDefault(value) => value.handle = handle,
ObjectType::WipeoutVariables(value) => value.handle = handle,
ObjectType::BlockVisibilityParameter(value) => value.handle = handle,
ObjectType::DynamicBlock(value) => value.handle = handle,
ObjectType::Associative(value) => value.handle = handle,
ObjectType::ClassObject(value) => value.handle = handle,
ObjectType::DataObject(value) => value.handle = handle,
ObjectType::Field(value) => value.handle = handle,
ObjectType::FieldList(value) => value.handle = handle,
ObjectType::RegisteredClass(value) => value.handle = handle,
ObjectType::DgnLineStyle(value) => value.handle = handle,
ObjectType::ProxyObject(value) => value.handle = handle,
ObjectType::Unknown {
handle: old_handle,
..
} => *old_handle = handle,
}
}
pub(crate) fn has_null_handle(&self) -> bool {
match self {
ObjectType::Dictionary(value) => value.handle.is_null(),
ObjectType::Layout(value) => value.handle.is_null(),
ObjectType::XRecord(value) => value.handle.is_null(),
ObjectType::Group(value) => value.handle.is_null(),
ObjectType::MLineStyle(value) => value.handle.is_null(),
ObjectType::ImageDefinition(value) => value.handle.is_null(),
ObjectType::UnderlayDefinition(value) => value.handle.is_null(),
ObjectType::PlotSettings(value) => value.handle.is_null(),
ObjectType::MultiLeaderStyle(value) => value.handle.is_null(),
ObjectType::TableStyle(value) => value.handle.is_null(),
ObjectType::TableContent(value) => value.common.handle.is_null(),
ObjectType::Scale(value) => value.handle.is_null(),
ObjectType::ObjectContextData(value) => value.handle.is_null(),
ObjectType::SortEntitiesTable(value) => value.handle.is_null(),
ObjectType::DictionaryVariable(value) => value.handle.is_null(),
ObjectType::VisualStyle(value) => value.handle.is_null(),
ObjectType::Material(value) => value.handle.is_null(),
ObjectType::ImageDefinitionReactor(value) => value.handle.is_null(),
ObjectType::GeoData(value) => value.handle.is_null(),
ObjectType::SpatialFilter(value) => value.handle.is_null(),
ObjectType::RasterVariables(value) => value.handle.is_null(),
ObjectType::BookColor(value) => value.handle.is_null(),
ObjectType::PlaceHolder(value) => value.handle.is_null(),
ObjectType::DictionaryWithDefault(value) => value.handle.is_null(),
ObjectType::WipeoutVariables(value) => value.handle.is_null(),
ObjectType::BlockVisibilityParameter(value) => value.handle.is_null(),
ObjectType::DynamicBlock(value) => value.handle.is_null(),
ObjectType::Associative(value) => value.handle.is_null(),
ObjectType::ClassObject(value) => value.handle.is_null(),
ObjectType::DataObject(value) => value.handle.is_null(),
ObjectType::Field(value) => value.handle.is_null(),
ObjectType::FieldList(value) => value.handle.is_null(),
ObjectType::RegisteredClass(value) => value.handle.is_null(),
ObjectType::DgnLineStyle(value) => value.handle.is_null(),
ObjectType::ProxyObject(value) => value.handle.is_null(),
ObjectType::Unknown { handle, .. } => handle.is_null(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_dictionary_creation() {
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);
}
#[test]
fn test_layout_creation() {
let layout = Layout::new("Layout1");
assert_eq!(layout.name, "Layout1");
assert_eq!(layout.tab_order, 0);
}
}