Skip to content

BricsCAD parametric blocks: create and edit visibility states with VISIBILITYSTATES and a palette - #3573

Merged
HakanSeven12 merged 7 commits into
HakanSeven12:mainfrom
ohagmann:feat/bricscad-visibility-authoring
Nov 24, 2026
Merged

HakanSeven12 merged 7 commits into
HakanSeven12:mainfrom
ohagmann:feat/bricscad-visibility-authoring

Conversation

@ohagmann

Copy link
Copy Markdown
Contributor

Builds on #3572 (Properties show and switch the states), which builds on #3571; the last three commits are this PR's.

What

  • VISIBILITYSTATES creates and edits the visibility states of a BricsCAD parametric block in model space of the
    block's own drawing, with BricsCAD's prompts: a parameter, a state (new names make new ones), then Add / Remove /
    make Visible / make Invisible / Select state and the objects. It leaves what BricsCAD's own command leaves for the
    same steps, so BricsCAD lists and switches the states and goes on editing them.
  • The Visibility States palette (VISIBILITYSTATESPANELOPEN, Parametric tab › Manage › Visibility States) does the same
    with the mouse, after BricsCAD's own Visibility States panel: each parameter with its states (a click shows a state,
    ▲/▼ move it, ▸ opens its page, Add state, + for a parameter started with the objects then picked), and per state its
    objects with an eye to show or hide each, ✕ to take one out of the parameter and a button to add objects; an object
    that shows the same in every state is marked, as BricsCAD marks it.
  • Moving states is something BricsCAD's panel cannot do: the order is the table's row order, which is the order
    Properties lists a reference's states in. A moved state takes its row along and the state shown stays shown.

How BricsCAD stores what it authors

A parameter is a configuration feature with a table: a row per state, a column (look_n, the lowest free number) per
group of objects that show and hide together, 1 where the group shows. A new state starts with every group hidden.
Each group is a suppression feature whose variable is 1 - the product of the group's columns, one per parameter
that rules it, in parameter order (1 - look_1 * look_4). Each object has a dependency and a BDMOBJECT; Remove keeps
the BDMOBJECT with no dependency, and adding the object again reuses it. Suppression and object names depend on
BricsCAD's interface language (Unterdrücken_1, Objekt_1 in German).

What BricsCAD relies on beyond its tables, found while checking against it:

  • each key variable holds the number of the state shown, which BricsCAD shows again on its next evaluation;
  • a key can be disabled over a variable with an expression of its own (drawings made in BricsCAD have keys showing the
    second state over 0); BricsCAD reads such a state by name and leaves the key alone until the parameter's state is
    picked, then enables it and drops the expression;
  • BricsCAD finds variables by name, so a second variable of a name gets mixed up with the first; some of its own
    drawings name a group's variable after another group, so a new name is checked against every variable;
  • a variable's reads carry their position as flags.

Changes

  • scene::bricscad_parameters::author (Scene::edit_bricscad_visibility): reads model space's parameters, groups and
    members; applies the action the way BricsCAD does (Add/Visible on an object the parameter does not rule: this state
    only; Invisible: every state but this; Remove: no longer ruled; objects whose patterns agree share a group, a group
    that changes as a whole changes in place, an empty group goes with its columns); writes the features, tables,
    reactors, variables with their reads, dependencies and BDMOBJECTs; registers BricsCAD's classes when the drawing
    has none yet; shows the current states again. Actions NewState, MoveUp, MoveDown for the palette. New names
    follow the drawing's, else the interface language (BricsCAD's English or German names).
  • Keys of parameters an edit was not asked about stay as BricsCAD left them (second commit).
  • VISIBILITYSTATES command (modules::draw::modify::visibilitystates, app::commands::bricscad_visibility): one
    undo step per run; refused in the Block Editor and in layouts (see below).
  • ui::window::bricscad_visibility: the palette, PanelId::BricscadVisibility, VISIBILITYSTATESPANELOPEN/CLOSE, a
    ribbon button. In the kit audit with no generic colours or literal sizes.
  • Undo: a step recorded as a document snapshot now also restores the drawing's parameter table
    (PendingHistorySnapshot::named_parameters_before). The table used to stay, and the next command wrote the undone
    variables back into the drawing.
  • The texts of the command and the palette are in every locale's catalog. The German prompts follow BricsCAD's German
    interface; the other 21 languages are machine translations kept to each catalog's terms for visibility states and
    parameters, with prompt options that differ in their first letters where the language allows. Corrections welcome.
  • Wiki: VISIBILITYSTATES and VISIBILITYSTATESPANELOPEN/CLOSE pages, a paragraph in Blocks and Attributes.

Tests

  • scene::bricscad_parameters::author_tests on tests/fixtures/bricscad/authoring-*.dwg: BricsCAD V26 saved these
    along one run of its VISIBILITYSTATES on five lines (17 steps, two parameters, a line ruled by both, Remove and
    Add again; the README lists them). The same run here leaves the same tables, groups, expressions, variable values,
    member layers and objects. Also: reads hold their values and are numbered, keys hold their state's number, a new
    group's name is free among the variables, a moved state keeps its objects and the shown state stays shown, nothing
    moves past either end, a new state hides every object of its parameter, a disabled key is left alone until its
    state is picked.
  • app::visibilitystates_tests: the same run typed at the command line; objects picked before or when the command
    asks; one undo step per run, with redo; a refused step and the Block Editor change nothing; the palette switches,
    moves, adds a state and objects, removes one, starts a parameter, and each step undoes; outside model space it has
    nothing to edit.

Against real drawings (a block library, templates and sheets of one project; not shareable), edited here, saved and
opened in BricsCAD V26 (Linux):

  • 150 drawings with visibility parameters in model space (library blocks, stamps, templates), each edited in 4 to 7
    steps (Select, a new state with an object made visible, Add of an object no parameter ruled, Invisible, Remove, Add
    to a second parameter, Select). BricsCAD then selects every state of every parameter in turn: the visibility of
    every model-space object matches what OCS shows for the same state, 7,698 states in all (with the two runs of the
    fixture drawing).
  • BricsCAD's VISIBILITYSTATES goes on editing each of them (a new state, an object made visible), and the drawing it
    saves reads here with the visibility BricsCAD left and can be edited on here.
  • 80 of them insert parametric blocks, whose 5,950 reference states read in BricsCAD as before the edit.
  • Ordering: 31 of them (and the fixture) with a state moved down, a new state added and moved up and an object shown in
    it. BricsCAD's VISIBILITYSTATES lists the states of every parameter in the order written here (654 lists), and each
    state shows the same objects as here (1,341 states).
  • AUDIT reports nothing beyond what it reports for the same drawing saved by OCS without a change.

cargo test --workspace passes, apart from runner::tests::run_v4_delivers_document_changed_delta_to_v27_plugin,
which fails the same way on main when the whole workspace runs in parallel and passes on its own.

Not covered:

  • The Block Editor: a block definition stores the states the same way, but the copies its references show would keep
    the old ones; BricsCAD updates them after its own block editor, and does not on a later switch. The command and the
    palette say to edit the block's own drawing.
  • Renaming or deleting states and parameters, and BricsCAD's "Show Invisible" (dimmed hidden objects).

…nds on

BricsCAD keeps the visibility states of its parametric blocks in objects of
its own classes, which are read here as raw records. They reach the block's
ACAD_ASSOCNETWORK variables by handle, and the variables list them as
reactors. The graph sync that runs on save rebuilt every scope's network
under new handles and dropped its value dependencies, so BricsCAD found its
objects pointing at erased variables and dropped every parameter of the
drawing.

A network whose variables list a raw record as reactor is now written back
as it was read, as long as the editor's model of that scope still equals the
one the network holds; a scope the user changed is rebuilt as before. Kept
networks go back under the rebuilt root network.
…reference

BricsCAD keeps the visibility parameters of its parametric blocks in objects
of its own classes, which are read as raw records. A new scene module decodes
the few it needs from their DWG bytes (2010 and later): each object is a list
of named properties, with names and text in the string stream and object
references in the handle stream. From them it reads a block's visibility
parameters, their states and the state the block shows, and the block an
anonymous copy was made from.

A reference to such a block now shows one read-only row per parameter in the
Custom section, with the state it shows and the states as tooltip, and its
Name row names the block rather than the *U copy a reference in another state
shows.
…k reference

A reference to a BricsCAD parametric block now lists each visibility
parameter's states in Properties, and a state picked there is shown the way
BricsCAD shows it, so BricsCAD reads the reference in that state, keeps its
parameters and goes on from there:

- the reference shows the block when the states are the block's own, a copy
  of the block that shows them when there is one (BricsCAD shares copies
  too), or a new anonymous copy: the block's members and every object under
  its extension dictionary (BricsCAD's parameter objects, the associative
  network, the draw order) cloned under new handles, with the states set as
  BricsCAD sets them in its own copies;
- its attributes move on or off *SUPPRESS with their definitions;
- its entry in model space (a BmAssemblyParameters feature reached through a
  BDMOBJECT) lists every parameter set on it, as BricsCAD keeps it, and is
  created, with model space's own parameter objects when there are none.

A block BricsCAD never copied gets the tag BricsCAD gives it on its first
copy. Picking works for several references at once and is one undo step.

Writing BricsCAD's objects needs their records encoded again: the decoder
moves into scene::bricscad_parameters::record, keeps everything needed to
write a record back bit for bit, and encodes. Besides the plain property
lists it reads the constraint manager, BDMOBJECT and the object dependency.
BricsCAD keeps every value dependency (ACDBASSOCVALUEDEPENDENCY) at the
value of the variable it reads: all 14,882 of them in 408 drawings made in
BricsCAD do. It takes a variable whose new value its reads already hold for
unchanged and does not evaluate what depends on it; in model space a stale
read keeps it from hiding a member on the next change of state.

A copy made for a reference kept the reads of the block it was cloned
from. Setting a variable now sets its reads too.
…D parametric block

BricsCAD sets up a parametric block's visibility states with its own
VISIBILITYSTATES command, on model space of the drawing that becomes the
block. OCS now has the same command, with the same prompts: a parameter, a
state (new names make new ones), then Add, Remove, make Visible, make
Invisible or Select state, and the objects. What it leaves is what BricsCAD
leaves for the same steps, stored where BricsCAD reads it, so BricsCAD lists
and switches the states and goes on editing them:

- per parameter a configuration feature with a table, a row per state and a
  column (`look_n`) per group of objects that show and hide together;
- per group a suppression whose variable is `1 - ` the product of its
  columns, one per parameter that rules the group, in parameter order;
- the variables in model space's associative network, a dependency and a
  `BDMOBJECT` per object; names of new objects follow the drawing's, else
  the interface language (BricsCAD's English or German names). A new group
  or column takes a name no variable of the network has: BricsCAD finds
  variables by name, and some of its drawings name a group's variable after
  another group.

After each step the current states show again. Each key also gets the
number of the state it shows: BricsCAD shows the state of that number when
it next evaluates, and its own state selection leaves the number behind.

The command works in model space only. In the Block Editor the copies the
block's references show would keep the old states, and BricsCAD itself
does not bring them up to date on a later switch.

A step is one undo step. Undo of a step taken as a document snapshot now
also puts back the drawing's parameter table, which these steps change; it
used to stay, and the next command wrote the undone variables back.

Tests: the BricsCAD drawings in tests/fixtures/bricscad/authoring-*.dwg
(see the README there) were saved along one run of BricsCAD's command; the
same run here, through the scene and typed at the command line, leaves the
same tables, groups, expressions, values and layers. Reads hold their
variables' values, keys the number of their state, a new group's name is
free, undo and redo work, a refused step and the Block Editor change
nothing.

Wiki: VISIBILITYSTATES page, a paragraph on BricsCAD parametric blocks in
Blocks and Attributes.
… as BricsCAD left them

A visibility parameter's key (a BdmDbConfigVarReactor with IsKeyVar) can
be disabled, its variable holding an expression of its own: openCirt's
templates, made in BricsCAD, have keys showing the second state over a
variable `0`. BricsCAD reads such a state by name and leaves the key alone
until the parameter's state is picked; then it enables the key, drops the
expression and gives the variable the state's number.

VISIBILITYSTATES enabled every key of the drawing and renumbered it under
its expression, so BricsCAD's next evaluation could show another state of
a parameter nobody touched. Now only enabled keys are renumbered, and the
key of the parameter whose state is picked is set the way BricsCAD sets
it. Switching references is unchanged: a copy's keys are still set as in
BricsCAD's own copies.
…tes with the mouse

VISIBILITYSTATESPANELOPEN (Parametric tab › Manage › Visibility States)
opens a palette on model space of a BricsCAD block drawing, after
BricsCAD's own Visibility States panel:

- each visibility parameter with the number of objects it rules and its
  states; a click shows a state, ▲/▼ move it up or down, the arrow opens
  its page; Add state and + (a parameter, named with its first state and
  started with the objects then picked);
- a state's page lists the parameter's objects (type, layer when shown,
  handle) with an eye to show or hide each in the state, ✕ to take it out
  of the parameter and a button to add objects; a row selects its object;
  an object that shows the same in every state is marked, as BricsCAD
  marks it.

Moving states is something BricsCAD cannot do: the order is the order of
the table's rows, which is the order Properties lists a reference's states
in. A moved state takes its row along; the state shown stays shown and its
key gets its new number. BricsCAD V26 lists the moved states in the new
order and shows each as before.

Every change runs through VISIBILITYSTATES' edit and is one undo step;
the two new actions are MoveUp/MoveDown and NewState (a state with every
object of the parameter hidden, shown at once). The command takes the
whole source option a translated prompt hands back, and its prompts no
longer build "or [...]" from English fragments.

The texts of the command and the palette are in every locale's catalog.
The palette is in the kit audit with no generic colours or literal sizes.

Tests: moving keeps every state's objects and the shown state, past
either end nothing moves; a new state hides every object of its
parameter; the palette switches, moves, adds a state and objects, removes
one, starts a parameter, and each step undoes; outside model space it has
nothing to edit. Wiki: VISIBILITYSTATESPANELOPEN/CLOSE pages.
@HakanSeven12
HakanSeven12 merged commit a557a3e into HakanSeven12:main Nov 24, 2026
HakanSeven12 added a commit that referenced this pull request Nov 24, 2026
… VISIBILITYSTATES docs name no other product

Follow-up to #3573, #3576.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants