mod associative;
mod block_visibility;
mod class_object;
mod data_objects;
mod dgn_linestyle;
mod dictionary_variable;
mod dynamic_block;
mod field;
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 stub_objects;
mod table_style;
mod xrecord;
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, DataTableCellType, DataTableColumn, DataTableValue,
DetailViewStyle, GeoMapImage, GradientBackground, GroundPlaneBackground, IblBackground,
ImageBackground, LayerFilter, LightList, LightListEntry, MentalRayRenderSettings,
ModelDocViewStyle, MotionPath, NavisworksModelDefinition, PartialViewingIndex,
PartialViewingIndexEntry, PersistentSubentityManager, PointCloudColorMap, PointCloudColorRamp,
PointCloudDefinition, PointCloudDefinitionReactor, PointCloudRampColor, PointPath,
RapidRtRenderSettings, RenderEntry, RenderEnvironment, RenderGlobal, RenderSettings,
SectionGeometrySettings, SectionManager, SectionSettings, SectionTypeSettings,
SectionViewStyle, SkyLightBackground, SolidBackground, SpatialIndex, Sun, SunStudy,
SunStudyDate, TvDeviceProperties, VbaProject, ViewRep, ViewRepBlockPath, ViewRepBlockPathEntry,
ViewRepGuid, ViewRepModelSpaceSource, ViewRepModelSpaceViewSelectionSet, ViewRepObjectPath,
ViewRepOrientation, ViewRepSectionDefinition, ViewRepSketch, ViewRepSketchGeometry,
ViewRepSketchReference, ViewRepSourceManager, ViewRepStandard,
};
pub use data_objects::{
BreakData, BreakPointReference, CellStyleMap, DataObject, DataObjectData, IdBuffer, Index,
LayerIndex, LayerIndexEntry, PartialViewingFilter, TableGeometry, TableGeometryCell,
};
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 dynamic_block::{
is_dynamic_block_object_name, 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, BlockLookupColumn, BlockLookupParameter, BlockMoveAction,
BlockOnePointParameter, BlockOrientedGrip, BlockParameter, BlockParameterDependencyBody,
BlockParameterProperty, BlockParameterValueSet, BlockPointParameter, BlockPolarParameter,
BlockPolarStretchAction, BlockPropertiesTable, BlockPropertiesTableField,
BlockPropertiesTableValue, BlockRepresentationData, BlockRotationParameter, BlockStretchAction,
BlockStretchCode, BlockStretchHandle, BlockTwoPointParameter, BlockUserParameter,
BlockXYParameter, DynamicBlockData, DynamicBlockObject, SolidHistory, SolidHistoryBoolean,
SolidHistoryBox, SolidHistoryBrep, SolidHistoryChamfer, SolidHistoryCone, SolidHistoryCylinder,
SolidHistoryFillet, SolidHistoryLoft, SolidHistoryLoftOptions, SolidHistoryLoftParameters,
SolidHistoryNodeBase, SolidHistoryOperation, SolidHistoryPyramid, SolidHistoryRevolve,
SolidHistorySphere, SolidHistorySweep, SolidHistoryTorus, SolidHistoryTree,
};
pub use field::{Field, FieldChildValue, FieldList};
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 multileader_style::{
BlockContentConnectionType, LeaderContentType, LeaderDrawOrderType,
LeaderLinePropertyOverrideFlags, MultiLeaderDrawOrderType, MultiLeaderPathType,
MultiLeaderPropertyOverrideFlags, MultiLeaderStyle, TextAlignmentType, TextAngleType,
TextAttachmentDirectionType, TextAttachmentType,
};
pub use object_context_data::{
DimContext, DimSubtype, EmbeddedMTextContext, HatchLoopContext, HatchScaleContext,
HatchViewContext, LeaderContext, MTextAttributeContext, MTextColumns, MTextContext,
ObjectContextData, ObjectContextKind,
};
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::{SortEntitiesTable, SortEntsEntry};
pub(crate) use stub_objects::{restore_visual_style_roundtrip, store_visual_style_roundtrip};
pub use stub_objects::{
BookColor, DictionaryWithDefault, GeoData, GeoDataMeshFace, GeoDataMeshPoint, Material,
MaterialColor, MaterialMap, MaterialProceduralValue, MaterialTexture, PlaceHolder,
RasterVariables, SpatialFilter, StubObject, VisualStyle, VisualStyleProperty,
VisualStylePropertyValue, WipeoutVariables,
};
pub(crate) use table_style::{restore_table_style_roundtrip, store_table_style_roundtrip};
pub use table_style::{
CellAlignment, NamedTableCellStyle, RowCellStyle, TableBorderPropertyFlags, TableBorderType,
TableCellBorder, TableCellStyleData, TableCellStylePropertyFlags, TableContentFormat,
TableFlowDirection, TableGridFormat, TableStyle, TableStyleFlags,
};
pub use xrecord::{
DictionaryCloningFlags, KnownXRecordKind, XRecord, XRecordEntry, XRecordSection, XRecordValue,
XRecordValueType,
};
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),
Arch(crate::classes::arch::ArchObject),
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 clear_storage_data(&mut self) {
match self {
ObjectType::XRecord(value) => {
value.raw_dwg_data = None;
value.raw_dwg_version = None;
}
ObjectType::TableStyle(value) => value.raw_dxf_codes = None,
ObjectType::SortEntitiesTable(value) => {
value.raw_dxf_codes = None;
value.raw_dxf_version = None;
}
ObjectType::ClassObject(value) => {
if let ClassObjectData::CsacDocumentOptions(options) = &mut value.data {
options.raw_dwg_data = None;
options.raw_dwg_version = None;
}
}
ObjectType::RegisteredClass(value) => {
value.raw_dwg_data = None;
value.raw_dwg_version = None;
}
ObjectType::Arch(value) => {
value.raw_dwg_data = None;
value.raw_dwg_version = None;
value.raw_dxf_codes = None;
}
ObjectType::Unknown {
raw_dxf_codes,
raw_dwg_data,
raw_dwg_version,
..
} => {
*raw_dxf_codes = None;
*raw_dwg_data = None;
*raw_dwg_version = None;
}
ObjectType::Layout(value) => value.raw_plot_settings_codes = None,
_ => {}
}
}
pub fn intrinsic_handle(&self) -> Handle {
match self {
ObjectType::Dictionary(value) => value.handle,
ObjectType::Layout(value) => value.handle,
ObjectType::XRecord(value) => value.handle,
ObjectType::Group(value) => value.handle,
ObjectType::MLineStyle(value) => value.handle,
ObjectType::ImageDefinition(value) => value.handle,
ObjectType::UnderlayDefinition(value) => value.handle,
ObjectType::PlotSettings(value) => value.handle,
ObjectType::MultiLeaderStyle(value) => value.handle,
ObjectType::TableStyle(value) => value.handle,
ObjectType::TableContent(value) => value.common.handle,
ObjectType::Scale(value) => value.handle,
ObjectType::ObjectContextData(value) => value.handle,
ObjectType::SortEntitiesTable(value) => value.handle,
ObjectType::DictionaryVariable(value) => value.handle,
ObjectType::VisualStyle(value) => value.handle,
ObjectType::Material(value) => value.handle,
ObjectType::ImageDefinitionReactor(value) => value.handle,
ObjectType::GeoData(value) => value.handle,
ObjectType::SpatialFilter(value) => value.handle,
ObjectType::RasterVariables(value) => value.handle,
ObjectType::BookColor(value) => value.handle,
ObjectType::PlaceHolder(value) => value.handle,
ObjectType::DictionaryWithDefault(value) => value.handle,
ObjectType::WipeoutVariables(value) => value.handle,
ObjectType::BlockVisibilityParameter(value) => value.handle,
ObjectType::DynamicBlock(value) => value.handle,
ObjectType::Associative(value) => value.handle,
ObjectType::ClassObject(value) => value.handle,
ObjectType::DataObject(value) => value.handle,
ObjectType::Field(value) => value.handle,
ObjectType::FieldList(value) => value.handle,
ObjectType::RegisteredClass(value) => value.handle,
ObjectType::DgnLineStyle(value) => value.handle,
ObjectType::ProxyObject(value) => value.handle,
ObjectType::Arch(value) => value.handle,
ObjectType::Unknown { handle, .. } => *handle,
}
}
pub fn preserve_storage_data_from(&mut self, source: &Self) {
match (self, source) {
(Self::Layout(value), Self::Layout(source)) => {
value.raw_plot_settings_codes = source.raw_plot_settings_codes.clone();
}
(Self::XRecord(value), Self::XRecord(source)) => {
value.raw_dwg_data = source.raw_dwg_data.clone();
value.raw_dwg_version = source.raw_dwg_version;
}
(Self::TableStyle(value), Self::TableStyle(source)) => {
value.raw_dxf_codes = source.raw_dxf_codes.clone();
}
(Self::SortEntitiesTable(value), Self::SortEntitiesTable(source)) => {
value.raw_dxf_codes = source.raw_dxf_codes.clone();
value.raw_dxf_version = source.raw_dxf_version;
}
(Self::ClassObject(value), Self::ClassObject(source)) => {
if let (
ClassObjectData::CsacDocumentOptions(value),
ClassObjectData::CsacDocumentOptions(source),
) = (&mut value.data, &source.data)
{
value.raw_dwg_data = source.raw_dwg_data.clone();
value.raw_dwg_version = source.raw_dwg_version;
}
}
(Self::RegisteredClass(value), Self::RegisteredClass(source)) => {
value.raw_dwg_data = source.raw_dwg_data.clone();
value.raw_dwg_version = source.raw_dwg_version;
}
(Self::Arch(value), Self::Arch(source)) => {
value.raw_dwg_data = source.raw_dwg_data.clone();
value.raw_dwg_version = source.raw_dwg_version;
value.raw_dxf_codes = source.raw_dxf_codes.clone();
}
(
Self::Unknown {
raw_dxf_codes,
raw_dwg_data,
raw_dwg_version,
..
},
Self::Unknown {
raw_dxf_codes: source_dxf,
raw_dwg_data: source_dwg,
raw_dwg_version: source_version,
..
},
) => {
*raw_dxf_codes = source_dxf.clone();
*raw_dwg_data = source_dwg.clone();
*raw_dwg_version = *source_version;
}
_ => {}
}
}
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::Arch(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::Arch(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);
}
#[test]
fn public_record_edit_can_preserve_opaque_object_data() {
let source = ObjectType::Unknown {
type_name: "CUSTOM_OBJECT".into(),
handle: Handle::new(0x42),
owner: Handle::NULL,
raw_dxf_codes: Some(vec![(1, "source".into())]),
raw_dwg_data: Some(vec![1, 2, 3]),
raw_dwg_handle_bits: 7,
raw_dwg_version: Some(crate::types::DxfVersion::AC1032),
};
let mut edited = ObjectType::Unknown {
type_name: "EDITED_OBJECT".into(),
handle: Handle::new(0x42),
owner: Handle::NULL,
raw_dxf_codes: None,
raw_dwg_data: None,
raw_dwg_handle_bits: 7,
raw_dwg_version: None,
};
edited.preserve_storage_data_from(&source);
let ObjectType::Unknown {
type_name,
raw_dxf_codes,
raw_dwg_data,
raw_dwg_version,
..
} = edited
else {
unreachable!()
};
assert_eq!(type_name, "EDITED_OBJECT");
assert_eq!(raw_dxf_codes, Some(vec![(1, "source".into())]));
assert_eq!(raw_dwg_data, Some(vec![1, 2, 3]));
assert_eq!(raw_dwg_version, Some(crate::types::DxfVersion::AC1032));
}
}