feat(bedit): author visibility states of dynamic blocks

In the Block Editor, BVSTATE makes a new visibility state, makes one
current, renames or deletes one; BVHIDE and BVSHOW hide or show the
picked objects in the current state (BVSHOW shows every object of the
block while they are picked). The first use makes the block dynamic.

The states are stored as the format keeps them: a
BLOCKVISIBILITYPARAMETER in the block's ACAD_ENHANCEDBLOCK evaluation
graph with its visibility grip and the grip's two location expressions,
the round-trip purge preventer, AcDbDynamicBlockTrueName /
AcDbDynamicBlockGUID / AcDbBlockRepETag on the definition and element
tags on each of its objects. The definition shows its first state; a
reference given another state gets its own evaluated *U copy, tagged
AcDbBlockRepBTag and linked back through AcDbBlockRepresentation /
AcDbRepData, so it shows that state and the other references do not
change. Saving the block drops erased objects from the states.

Checked: a block authored this way reads back with its states and
reference link from DWG and DXF, and the ODA converter accepts the DWG.

Closes #1566

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-14 10:02:34 +03:00
1 parent 353c1b0d0f
commit da8e976a60
31 files changed
+1464 -1

No files matched your search

+5
View File
@@ -7,6 +7,7 @@
// cache — block-definition and property caches
pub mod annotative;
pub mod assoc_array;
pub mod block_visibility;
pub mod compare;
pub mod section_cull;
pub mod sub_select;
@@ -2123,6 +2124,9 @@ pub struct Scene {
/// frozen-layer signature. Invalidated only when a light entity changes;
/// ordinary geometry edits never rescan the drawing's lights.
lighting_cache: RefCell<HashMap<(Handle, u64), Vec<SceneLight>>>,
/// The visibility state each dynamic block shows in the Block Editor,
/// by block record.
pub visibility_states: HashMap<Handle, usize>,
/// Currently selected entity handles.
pub selected: HashSet<Handle>,
/// Polylines only part of which is selected (Ctrl+click): the picked
@@ -2772,6 +2776,7 @@ impl Scene {
last_created_dimension: None,
object_data_cache: crate::entities::object_data::ObjectDataCache::default(),
lighting_cache: RefCell::new(HashMap::default()),
visibility_states: HashMap::default(),
selected: HashSet::default(),
sub_segments: HashMap::default(),
selected_order: Vec::new(),