fix(insert): place block attributes by their ATTDEF geometry, follow the block (#255)

Inserting a block piled every attribute at the origin: each AttributeEntity
was built from just tag + value with default geometry. Carry the full
AttributeDefinition through the attreq flow and build attributes with
AttributeEntity::from_definition, then apply the block's insertion transform
so each lands in WCS at its proper position / alignment / rotation.

Attributes are stored in world space, so moving the block must move them
too. The MOVE command already did (acadrust translate_insert); apply_grip
(grip-drag) and the Position X/Y/Z property edit now translate the
attributes by the same world delta so they no longer stay behind.

Rotate/scale/mirror of a block still don't carry the attributes — acadrust's
transform_insert has no attribute pass — tracked separately.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-07-03 16:47:39 +03:00
commit ab0a4f790c
4 changed files with 60 additions and 40 deletions

View file

@ -549,8 +549,9 @@ impl OpenCADStudio {
}
}
CmdResult::AttreqNeeded { block_name } => {
// Collect AttributeDefinitions owned by this block record.
let attdefs: Vec<(String, String, String)> = {
// Collect the full AttributeDefinitions owned by this block
// record so each created attribute keeps its geometry (#255).
let attdefs: Vec<acadrust::entities::AttributeDefinition> = {
let doc = &self.tabs[i].scene.document;
if let Some(br) = doc.block_records.get(&block_name) {
br.entity_handles
@ -559,11 +560,7 @@ impl OpenCADStudio {
if let Some(acadrust::EntityType::AttributeDefinition(ad)) =
doc.get_entity(h)
{
Some((
ad.tag.clone(),
ad.prompt.clone(),
ad.default_value.clone(),
))
Some(ad.clone())
} else {
None
}