Repository navigation
BricsCAD parametric blocks: Properties show and switch visibility states - #3572
Merged
HakanSeven12 merged 4 commits intoNov 24, 2026
Merged
HakanSeven12 merged 4 commits into
HakanSeven12 merged 4 commits into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 visibilityparameter 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
*Ucopy BricsCAD makes for a reference in another state (before:*U2). This is the dropdown #1862 broughtfor 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_DATABASEin the block's extensiondictionary, 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
*SUPPRESSin the copy, and so do the reference's attributes whose definitions are hidden. When astate is changed, BricsCAD starts from the reference's entry in model space: a
BmAssemblyParametersfeature, reachedfrom the reference through a
BDMOBJECTand 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::recorddecodes these records so that encoding them again gives the same bits, andencodes them after a change. A record that does not decode in full gives nothing.
scene::bricscad_parametersreads a block's visibility parameters, the states a reference shows, the block a copywas made from.
scene::bricscad_parameters::switchswitches a reference in model space: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 thelayers it moved, the variables and every read of them,
original.block/map/tag);*SUPPRESSwith their definitions;A block BricsCAD never copied gets the tag (
ParametricBlockGUID) BricsCAD gives it on its first copy.ACDBASSOCVALUEDEPENDENCY) is set with the variable: BricsCAD keeps each at the value ofthe 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).
BlockParameterComponent::Bricscad), read-only in the Block Editor and TestBlock 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 oftests/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_testson the fixture: sharing a copy, back to the block, a new copy, a copy madehere 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, referencesselected together switch together.
Against real drawings (a block library, templates and sheets of one project; not shareable):
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);
AUDITreports nothing beyond what itreports for the same drawing saved by OCS without a switch.
cargo test --workspacepasses, apart fromrunner::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.