Skip to content

BricsCAD parametric blocks: Properties show and switch visibility states - #3572

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

HakanSeven12 merged 4 commits into
HakanSeven12:mainfrom
ohagmann:feat/bricscad-visibility-properties

Conversation

@ohagmann

Copy link
Copy Markdown
Contributor

Builds on #3571 (saving keeps the associative network these blocks depend on); without it BricsCAD drops their
parameters whenever OCS saves, so the first commit of this branch is that PR's.

What

A reference to a BricsCAD parametric block (visibility states set up with VISIBILITYSTATES) now lists each visibility
parameter in the Custom section of Properties, with the state it shows, and a state picked there is shown the way
BricsCAD shows it: BricsCAD reads the reference in that state, keeps its parameters and can go on switching it. Works
for several references at once and is one undo step. The Name row names the block, also when the reference shows the
anonymous *U copy BricsCAD makes for a reference in another state (before: *U2). This is the dropdown #1862 brought
for dynamic blocks, for BricsCAD's own parametric blocks.

How BricsCAD keeps the states

BricsCAD keeps a block's parameters in objects of its own classes under BDM_DATABASE in the block's extension
dictionary, which OCS reads as raw records. A reference shows the block or an anonymous copy whose own objects hold
the states it shows; BricsCAD shares a copy between references in the same states. The members a state hides sit on
the frozen layer *SUPPRESS in the copy, and so do the reference's attributes whose definitions are hidden. When a
state is changed, BricsCAD starts from the reference's entry in model space: a BmAssemblyParameters feature, reached
from the reference through a BDMOBJECT and a dependency, that lists every parameter ever set on the reference.

Each of the objects is a list of named properties: in the data stream a count and, per property, a type byte and the
value (text, integer, real, flag, byte, raw bytes, object reference, list, map); names and text in the string stream,
references in the handle stream, in the order the data stream names them. Three classes hold a few values around such
a list (BDMDBCONSTRAINTMANAGER, BDMOBJECT, BDMDBOBJECTDEPENDENCY).

Changes

  • scene::bricscad_parameters::record decodes these records so that encoding them again gives the same bits, and
    encodes them after a change. A record that does not decode in full gives nothing.
  • scene::bricscad_parameters reads a block's visibility parameters, the states a reference shows, the block a copy
    was made from.
  • scene::bricscad_parameters::switch switches a reference in model space:
    • to the block when the states are the block's own, to a copy that shows them when there is one, or to a new
      anonymous copy: the block's members and every object under its extension dictionary (BricsCAD's objects, the
      associative network, the draw order) cloned under new handles, with the states set as BricsCAD sets them in its
      own copies (LastKeyValue, the variable reactors, the table columns, each suppression's value, status and the
      layers it moved, the variables and every read of them, original.block/map/tag);
    • its attributes move on or off *SUPPRESS with their definitions;
    • its entry lists the parameter, created with model space's own parameter objects when there are none.
      A block BricsCAD never copied gets the tag (ParametricBlockGUID) BricsCAD gives it on its first copy.
  • Every read of a variable (ACDBASSOCVALUEDEPENDENCY) is set with the variable: BricsCAD keeps each at the value of
    the variable it reads (all 14,882 in the drawings below do) and does not evaluate past a read that already holds a
    new value, so a stale read in a copy would keep a member from hiding on a later switch (last commit).
  • Properties: one list per parameter (BlockParameterComponent::Bricscad), read-only in the Block Editor and Test
    Block and for a reference this cannot switch; the batch path takes the references of one block together.

Tests

  • scene::bricscad_parameters::record_tests: every BricsCAD record of tests/fixtures/bricscad/visibility-states.dwg
    (made in BricsCAD V26; the README says how) encodes to the bits it was read from; a changed record reads back as
    changed.
  • scene::bricscad_parameters::switch_tests on the fixture: sharing a copy, back to the block, a new copy, a copy made
    here holds what BricsCAD's own copy in the same states holds (every property of every object compared, references
    by class and member), each read of a variable holds the variable's value, the drawing keeps everything through a DWG
    save, no new dangling references.
  • app::bricscad_visibility_tests: Properties list the states, a pick switches and undoes in one step, references
    selected together switch together.

Against real drawings (a block library, templates and sheets of one project; not shareable):

  • all 217,645 BricsCAD objects of 408 drawings decode and encode to the same bits;
  • 342 switches in 173 drawings, each saved and opened in BricsCAD V26 (Linux): every state of all parametric
    references reads in BricsCAD as it reads here (18,548 checks); switching another parameter of each switched reference
    in BricsCAD works (336 of 336) and keeps the state set here (4,089 checks); AUDIT reports nothing beyond what it
    reports for the same drawing saved by OCS without a switch.

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: references in paper space or nested in blocks (read-only), DXF (BricsCAD does not keep these
parameters through DXF), parameters other than visibility states. Creating and editing the states follows in a
separate PR that builds on this one.

…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.
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