forked from 1b-agent/opencadstudio-upstream
DGNIMPORT: cells inside shared cell definitions are part of the definition; empty cells stay out
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fc04472472
commit
dca6c9d116
2 files changed
+11
-11
No files matched your search
@@ -715,15 +715,7 @@ fn place_converted(
|
||||
if scene.document.block_records.get(target).is_some() {
|
||||
continue;
|
||||
}
|
||||
let entities: Vec<codec::EntityType> = entities.into_iter().map(&fix).collect();
|
||||
if entities.is_empty() {
|
||||
// A cell that draws nothing still names a block.
|
||||
let mut record = codec::tables::block_record::BlockRecord::new(target);
|
||||
record.handle = scene.document.allocate_handle();
|
||||
let _ = scene.document.block_records.add(record);
|
||||
crate::io::xref::ensure_block_entities(&mut scene.document, target);
|
||||
continue;
|
||||
}
|
||||
let entities = entities.into_iter().map(&fix).collect();
|
||||
let _ = scene.define_block_from_owned_entities(entities, target, glam::DVec3::ZERO);
|
||||
}
|
||||
for entity in converted.entities {
|
||||
|
||||
@@ -616,6 +616,9 @@ struct Converter<'a> {
|
||||
/// (cell, made inside a copy) → copy block name.
|
||||
copies: HashMap<(String, bool), String>,
|
||||
names: Vec<String>,
|
||||
/// Converting a shared cell definition: the cells inside it are not
|
||||
/// blocks of their own, their objects are part of the definition.
|
||||
in_definition: bool,
|
||||
}
|
||||
|
||||
impl<'a> Converter<'a> {
|
||||
@@ -774,6 +777,9 @@ impl<'a> Converter<'a> {
|
||||
// A cell that is not shared becomes a block of its own ("the
|
||||
// cell's name, else AnonymousCell" and a number) placed at the
|
||||
// origin; its objects keep their layers.
|
||||
DgnGeom::CellGroup { parts, .. } if self.in_definition => {
|
||||
self.elements(parts, true, copy, depth + 1)
|
||||
}
|
||||
DgnGeom::CellGroup { name, parts } => {
|
||||
let base = if name.is_empty() { "AnonymousCell" } else { name.as_str() };
|
||||
let block = self.unique(&block_name(base));
|
||||
@@ -864,6 +870,7 @@ pub fn convert(import: &DgnImport, sub_units: bool, explode_text_nodes: bool) ->
|
||||
.collect(),
|
||||
copies: HashMap::new(),
|
||||
names: cells.iter().map(|(name, _)| block_name(name)).collect(),
|
||||
in_definition: false,
|
||||
};
|
||||
if !import.v7 {
|
||||
for level in &import.level_order {
|
||||
@@ -877,13 +884,14 @@ pub fn convert(import: &DgnImport, sub_units: bool, explode_text_nodes: bool) ->
|
||||
c.layer(&element, false);
|
||||
}
|
||||
}
|
||||
c.in_definition = true;
|
||||
for (name, elements) in &cells {
|
||||
let entities = c.elements(elements, true, CellCopy::default(), 0);
|
||||
// Every named cell becomes a block, even one with nothing it draws.
|
||||
if !name.is_empty() {
|
||||
if !name.is_empty() && !entities.is_empty() {
|
||||
c.out.blocks.push((block_name(name), entities));
|
||||
}
|
||||
}
|
||||
c.in_definition = false;
|
||||
let entities = c.elements(&top, false, CellCopy::default(), 0);
|
||||
c.out.entities = entities;
|
||||
c.out
|
||||
|
||||
Reference in new issue
Block a user