* BIM: Implement smart base removal for Walls
Previously, removing the Base object from an Arch Wall would cause the
wall to reset its position to the document origin and could lead to
unintended geometric changes for complex walls.
This commit introduces a "smart debasing" mechanism integrated into the
Component Task Panel's "Remove" button:
- For walls based on a single straight line, the operation now preserves
the wall's global position and parametric `Length`, making it an
independent object.
- For walls with complex bases (multi-segment, curved), a warning dialog
is now presented to the user, explaining the consequences (shape
alteration and position reset) before allowing the operation to
proceed.
This is supported by new API functions `Arch.is_debasable()` and
`Arch.debaseWall()`, which contain the core logic for the feature.
Fixes: https://github.com/FreeCAD/FreeCAD/issues/24453
* BIM: Move wall debasing logic into ArchWall proxy
The logic for handling the removal of a wall's base object was previously
implemented directly within the generic `ComponentTaskPanel` in
`ArchComponent.py`. This created a tight coupling, forcing the generic
component UI to have specific knowledge about the `ArchWall` type.
This commit refactors the implementation to follow a more object-oriented
and polymorphic design:
1. A new overridable method, `handleComponentRemoval(subobject)`, has been
added to the base `ArchComponent` proxy class. Its default implementation
maintains the standard removal behavior.
2. The `_Wall` proxy class in `ArchWall.py` now overrides this method. All
wall-specific debasing logic, including the eligibility check and the
user-facing warning dialog, now resides entirely within this override.
3. The `ComponentTaskPanel.removeElement` method has been simplified. It is
now a generic dispatcher that calls `handleComponentRemoval` on the
proxy of the object being edited, with no specific knowledge of object types.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* BIM: Add interactive creation of baseless walls
Introduce a new workflow for creating Arch Walls without a dependency on
a baseline object (e.g., a Draft Line).
- The `Arch_Wall` command is enhanced with a "No baseline" mode, controlled
by a new "Walls baseline" preference, allowing users to create
placement-driven walls directly in the 3D view.
- The existing `debaseWall` function has been refactored for correctness
and consistency with the new baseless wall geometry.
Co-authored-by: Yorik van Havre <yorik@uncreated.net>
* BIM: Refactor structure of the Arch Wall command
Refactor the `Arch_Wall` GUI command (`BimWall.py`) for improved
readability, maintainability, and architectural clarity.
- A `WallBaselineMode` Enum is introduced to replace the original
integer values, making the code self-documenting.
- The monolithic `create_wall` method is broken down into smaller,
single-responsibility helper functions for each creation mode.
- The `addDefault` method has been removed, with its logic
integrated into the new structure.
* BIM: Add Draft Stretch support for baseless walls
This commit makes the new baseless Arch Walls graphically editable using
the `Draft_Stretch` tool.
- An API for stretching (`calc_endpoints` and `set_from_endpoints`)
has been added to the `ArchWall` proxy.
- The `Draft_Stretch` tool is now aware of baseless walls and calls this
new proxy API to perform the stretch operation, enabling users to
stretch them.
Co-authored-by: Yorik van Havre <yorik@uncreated.net>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* BIM: address CodeQL warnings
* BIM: Fix wall alignment for GUI creation of baseless walls
Fixes an issue whereby creating a baseless wall from the GUI would
ignore the selected `Align` property, always resulting in a
center-aligned wall.
- The underlying geometry generation for baseless walls now correctly
honors the `Align` property passed by the GUI and API.
- To ensure predictable behavior, the implementation uses the same
geometric convention as walls built from a base object, making the
`Align` property work uniformly for all wall types.
- This also corrects the behavior of the `Arch.makeWall` function for
baseless walls.
- Update unit tests to test wall alignment.
* BIM: Refactor wall geometry generation for improved clarity and maintainability
Improves the internal logic for wall geometry creation, addressing CodeQL warnings and enhancing overall maintainability without changing external behavior.
- The `build_base_from_scratch` method is refactored to unify the separate logic paths for single- and multi-layer walls, reducing code duplication.
- A local helper function is introduced to create face geometry, for better modularity and readability.
- In the `_Wall.execute` method, the control flow that relied on implicit type checking is replaced with an explicit strategy pattern for fusing solids, making the logic more robust.
- Variable names are made more descriptive.
- A NumPy-style docstring is added to better document the function.
* Draft: fix stretching of rotated baseless walls
* BIM: add unit test for stretching baseless walls
* BIM: add regression tests for working-plane-relative coordinates and reuse of base sketches
* BIM: Fix baseless wall creation to respect the working plane
Corrects an issue where baseless walls were created using global
coordinates instead of being relative to the active Draft working plane.
The calculated local placement of the wall is now correctly transformed
into the global coordinate system by multiplying it with the working
plane's placement.
* BIM: Ensure unique baselines for subsequent wall creation
Fixes a bug where creating multiple walls with baselines would
incorrectly reuse the same underlying Sketch or Draft Line object.
The object retrieval logic after the `doCommand` call now correctly uses
`ActiveObject` to get a reliable reference to the new object instead of
relying on a hardcoded name.
* BIM: Make the wall's base object label translatable
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* BIM: use singular for consistency with other labels
Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>
* Fix typo
* BIM: address reviewer's comments about improving object reference passing between Python and FreeCAD contexts, and functions
* BIM: remove defensive programming: the callback is only executed as a result of a user's GUI action
* BIM: use the params API to define WallBaseline parameter
* BIM: add Arch Wall tests for joining wall logic
* BIM: add joining logic
* BIM: re-add ArchSketch support
* BIM: re-add multimaterial support on wall creation
* BIM: address CodeQL warning, remove module duplication
* BIM: fix check for SketchArch module when creating sketch-based walls
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Yorik van Havre <yorik@uncreated.net>
Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>
* Add Draft workbench to .pre-commit-config
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Removed outdated UTF8 declaration
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Update additional files
* The LineColor and LineWidth properties are removed from Text objects.
* Arrow properties are added by the ViewProviderDraftAnnotation class only. This avoids code duplication.
* gui_annotationstyleeditor.py fix except
* view_draft_annotation.py fix except
---------
Co-authored-by: Roy-043 <info@b-k-g.nl>
Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>
* Add custom template path support for WebGL export
- Extract hardcoded template into separate file and store in Mod/BIM/Resources/templates
- Remove hardcoded template from code
- Add new section to Import-Export Preference page ("WebGL"). This introduces two new parameters
- Make export() return bool to indicate success or failure for controlled headless export
- Add new unit tests for WebGL export to ensure functionality
- Update CMakeLists.txt to include the new template resource
* Apply suggestions from code review
Changes to literals, suggested after DWG review
Co-authored-by: Max Wilfinger <6246609+maxwxyz@users.noreply.github.com>
* Removed unused import
* Removed unused import
---------
Co-authored-by: Max Wilfinger <6246609+maxwxyz@users.noreply.github.com>
Co-authored-by: Yorik van Havre <yorik.vanhavre@gmail.com>
* Draft: Introduce 1-axis mode for ortho array
As the title says - the 1 axis mode allows to switch between all of the
axises mode and allows to modify only 1 axis at the time that user can
select with the checkbox.
* Draft: Rename to Linear Mode and remove redundant comments
* Draft: Display only one interval for the selected axis
* Draft: Cache selected variables in user.cfg - axis mode, intervals, etc...
* Draft: Make sure the checkboxes in OrthoArray are exclusively selected
* Draft: Apply review comments
Changed a couple of things according to review:
* linear mode is now being used as default during first startup (it
wasn't before)
* applied Roy's comments about coding style, etc.
* grouped everything into separate QGroupBox which is dedicated for
Linear Mode and has it's own labels, although spinboxes are shared so
during mode switch we reparent them now
* removed Orthogonal Array's icon
* in the QGroup applied naming suggested in the review, X Intervals ->
interval, etc.
* changed to radio buttons since we want exclusivity in selection
* BIM: Use checkbox in model tree for Activation/Deactivation of WP
* BIM: Set active object after deactivating current object if it exists
Currently we can get into a scenario where user can activate two working
planes, one after another. For example, Level, and then Level001. If
they activate both, and then deactivate Level001, working plane switches
back to Level. But, we didn't set the object as the active one, so user
didn't have clear information that they can deactivate it, only the
working plane was switching it.
So this patch sets the object as the active one, if it exists.
* BIM: Add support for deactivation active object to BIM Views Tree
As the title says - it adds the checkbox that's similarly done in Part
workbench, so user can select/deselect the item and if they had previous
active object, it will also fall back to the previous object.
Also, moved out part of the common logic from ArchBuildingPart and
BimViews to utils.
* BIM: Handle correct context on activating WP for NativeIFC/BIM
* BIM: Remove redundant logic from BIM Views upon double click
As all of the logic is being handled now in `activate` function in
BimViews, this logic is redundant
* BIM: Rename button for taskbar and BIM Views from Activate to Active
* To help novice users supply an actual font file from the OS as the default for ShapeStringFontFile.
* The Draft code blocked the use of TTC font files. `Part.makeWireString()` can however handle them (although only the first font in the file can be used).
Additonally:
In a previous PR the bottom spacer was removed from the task panel. This PR brings it back as it is required in some cases. Without it the "..." button of the file selector can become huge.
Fixes#17952.
This PR is a continuation of #20719.
It mainly involves adding `self.doc`. This new attribute is then also used in the rest of the modified classes. In some cases code was slightly reordered for consistency.
The `_finish_command_on_doc_close` function has been modifief to also handle `Gui.Snapper.ui.escape` and the code in gui_arcs.py has been updated accordingly.
Additionally:
Removed the `done` and `spacedone` variables in BimWall.py by tweaking the code.
* Draft: store 3 ShapeString parameters and remove font from prefs
With this PR 3 ShapeString parameters are stored:
* ShapeStringFontFile: this replaces the old FontFile parameter.
* ShapeStringHeight
* ShapeStringText
The ShapeStringFontFile is just the last selected font file and not exposed in the Preferences editor.
Additionally:
* Changed the label of the text input box from "String" to "Text".
* Changed the label of the point reset button to sentence case.
* Remove faulty docstring
* add precision Parameter for importSVG to preferences
* rewrite svgpath import
reorganize the existing svg interpretation code snippets by dividing the responsibilities for data provision and actual shape generation.
That bears the opportunity to optimize the resulting construction data regarding consistency and precision.
* create cuts from inner paths
organize paths in a tree structure where completely contained paths are children of their sorrounding paths
In a second step the even depth paths are cut with their respective (uneven depth) children.
* move svg path import logic into its own module
* Restructure how the import result is controlled by preferences.
* reintroduce alternative transform function
Using transformGeometry() on shapes results in degenerations like lines mutating to bsplines of 1st order. For non-orthogonal Transformations this can't be avoided. But for orthogonal transformations (the majority) we can apply those transformations without degeneration.
The necessary function including fallback to transformGeometry() is already in the code but was disabled due to a regression.
See: https://tracker.freecad.org/view.php?id=2062
Associated commits: f045df1e2509e59bd4f3cb72
I reactivate the code since the degeneration of paths seems a bigger issue to me than misformed svg files producing incorrect measurements. Degenrated paths are often the culprit for later arising 3D-calculation errors.
* avoid path degeneration by keeping scale transformations uniform
* repair style application on shapes
the style should be based on the configured svgstyle mode in the svgimport preferences.
* improve logging of face generation.
* refactor: rename _precision_step to _tolerance
naming according to example set in draft utils.
* fix: indentation
* spelling
Related: #17952.
This PR introduces a document observer to close task panels on doc close.
For now it is for the Draft Workbench only. The BIM Workbench will be dealt with in a future PR.
The basic code is simple, but to make things works some additional things were addressed:
* gui_base.py: the GuiCommandBase class was enhanced to handle App.activeDraftCommand, self.doc, self.view and self.planetracker. Strictly speaking only the first 2 are required for this PR.
* gui_base.py: self.command_name was changed to self.featureName for compatibility with gui_base_original.py. Not required for this PR.
* gui_arcs.py, gui_circulararray.py, gui_polararray.py and gui_orthoarray.py: updated in relation to the GuiCommandBase class.
* gui_arcs.py Arc_3Points: The command now has a ui property and shows a plane tracker. Only the first is required for this PR.
* gui_shapestrings.py: This command had two ui attributes: self.ui and self.task. This was problematic. To fix this the base class of the command was changed from gui_base_original.Creator to gui_base.GuiCommandBase. As a result the getStrings method is no longer available meaning that the useSupport parameter is ignored when creating a ShapeString. But since that mechanism does not work properly anyway, I feel that this is acceptable. Should many user complain the functionality can of course be reintroduced.
* Draft: Cache ContinueMode setting for every tool separately
Currently ContinueMode is done to be held globally, so this patch
changes this to cache it inside `user.cfg` for every cmd separately.
* Draft: Add Chained Mode option for Dimension
Added new option under Dimension, although this is simply porting the
existing logic of "Continue" under "Chained Mode", whereas allowing
existing "Continue" mode to retrigger the command instead of placing
Dimensions in a chain.
* Make some context menu actions translatable
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
See #20198
These functions are no longer used in the Draft WB or in the BIM WB.
There is a small risk that 3rd party code relies on them and breaks, but that can be addressed when such is reported as a problem.
Fixes#19993.
* To determine the `FlipText` value the normal (either the working plane Z axis or its reverse) and the working plane X axis are used.
* A new fine-tuning parameter `DimAutoFlipText` can be used to disable the functionality. Its default value is `True`.
* The `FlipText` property did not work for angular dimensions and the `TextSpacing` property of angular dimensions was not multiplied by `ScaleMultiplier`. This has been corrected.