Repository navigation
BricsCAD parametric blocks: create and edit visibility states with VISIBILITYSTATES and a palette - #3573
Merged
HakanSeven12 merged 7 commits intoNov 24, 2026
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.
…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.
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 #3572 (Properties show and switch the states), which builds on #3571; the last three commits are this PR's.
What
VISIBILITYSTATEScreates and edits the visibility states of a BricsCAD parametric block in model space of theblock'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.
VISIBILITYSTATESPANELOPEN, Parametric tab › Manage › Visibility States) does the samewith 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.
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) pergroup 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 parameterthat rules it, in parameter order (
1 - look_1 * look_4). Each object has a dependency and aBDMOBJECT; Remove keepsthe
BDMOBJECTwith no dependency, and adding the object again reuses it. Suppression and object names depend onBricsCAD's interface language (
Unterdrücken_1,Objekt_1in German).What BricsCAD relies on beyond its tables, found while checking against it:
second state over
0); BricsCAD reads such a state by name and leaves the key alone until the parameter's state ispicked, then enables it and drops the expression;
drawings name a group's variable after another group, so a new name is checked against every variable;
Changes
scene::bricscad_parameters::author(Scene::edit_bricscad_visibility): reads model space's parameters, groups andmembers; 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 drawinghas none yet; shows the current states again. Actions
NewState,MoveUp,MoveDownfor the palette. New namesfollow the drawing's, else the interface language (BricsCAD's English or German names).
VISIBILITYSTATEScommand (modules::draw::modify::visibilitystates,app::commands::bricscad_visibility): oneundo step per run; refused in the Block Editor and in layouts (see below).
ui::window::bricscad_visibility: the palette,PanelId::BricscadVisibility,VISIBILITYSTATESPANELOPEN/CLOSE, aribbon button. In the kit audit with no generic colours or literal sizes.
(
PendingHistorySnapshot::named_parameters_before). The table used to stay, and the next command wrote the undonevariables back into the drawing.
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.
VISIBILITYSTATESandVISIBILITYSTATESPANELOPEN/CLOSEpages, a paragraph in Blocks and Attributes.Tests
scene::bricscad_parameters::author_testsontests/fixtures/bricscad/authoring-*.dwg: BricsCAD V26 saved thesealong one run of its
VISIBILITYSTATESon five lines (17 steps, two parameters, a line ruled by both, Remove andAdd 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 commandasks; 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):
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).
VISIBILITYSTATESgoes on editing each of them (a new state, an object made visible), and the drawing itsaves reads here with the visibility BricsCAD left and can be edited on here.
it. BricsCAD's
VISIBILITYSTATESlists the states of every parameter in the order written here (654 lists), and eachstate shows the same objects as here (1,341 states).
AUDITreports nothing beyond what it reports for the same drawing saved by OCS without a change.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:
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.