forked from 1b-agent/opencadstudio-upstream
fix(blocks): a dynamic block copied to another drawing stays dynamic (#1816)
Only the definition's entities crossed drawings: its record's object graph (parameters, visibility states, grips) stayed behind, and a reference showing an evaluated copy lost the link to its definition. The clipboard now captures the graph and the dynamic definition of an evaluated reference, and paste and the block palette's insert-from-file recreate them on the new records, re-pointing members and element tags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ca408f4329
commit
091331f3bd
6 files changed
+109
-21
No files matched your search
@@ -348,7 +348,7 @@ pub(super) fn dynamic(
|
||||
object
|
||||
}
|
||||
|
||||
pub(super) fn members(document: &CadDocument, definition: Handle) -> Vec<Handle> {
|
||||
pub(crate) fn members(document: &CadDocument, definition: Handle) -> Vec<Handle> {
|
||||
document
|
||||
.block_records
|
||||
.iter()
|
||||
@@ -409,6 +409,16 @@ pub(super) fn set_entity_tag(
|
||||
}
|
||||
}
|
||||
|
||||
/// Point each tagged member's element tag back at the member itself, after
|
||||
/// the definition was copied onto new handles.
|
||||
pub(crate) fn retag_members(document: &mut CadDocument, definition: Handle) {
|
||||
for handle in members(document, definition) {
|
||||
if let Some(id) = document.get_entity(handle).and_then(element_id) {
|
||||
set_entity_tag(document, handle, element_tag(id, handle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Give every object of the definition its element tag, numbering the new
|
||||
/// ones after the highest id in use, and record the next id on the block.
|
||||
pub(super) fn tag_members(document: &mut CadDocument, definition: Handle) {
|
||||
|
||||
@@ -521,11 +521,7 @@ impl Scene {
|
||||
record.flags.anonymous = true;
|
||||
let copy = record.handle;
|
||||
// The copies keep their element ids, now naming themselves.
|
||||
for handle in members(&self.document, copy) {
|
||||
if let Some(id) = self.document.get_entity(handle).and_then(element_id) {
|
||||
set_entity_tag(&mut self.document, handle, element_tag(id, handle));
|
||||
}
|
||||
}
|
||||
super::block_authoring::retag_members(&mut self.document, copy);
|
||||
let mut tag = ExtendedDataRecord::new(REPRESENTATION_TAG);
|
||||
tag.add_value(XDataValue::Integer16(1));
|
||||
tag.add_value(XDataValue::Handle(definition));
|
||||
|
||||
Reference in new issue
Block a user