Commit Graph

546 Commits

Author SHA1 Message Date
PaddleStroke
802c9c286d Assembly: Joint creation presolve: move part2 rather than part1 when both are unconnected. 2024-12-20 11:37:04 -05:00
PaddleStroke
83026233a7 Merge branch 'main' into core_LCS3 2024-12-13 18:48:35 +01:00
Andrea
5c6b93e92b [Mod] Clean AssemblyObject.cpp
Removed dead code

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

.
2024-12-13 12:34:46 -05:00
mosfet80
6783d674bb Clean ViewProviderAssembly.cpp 2024-12-13 12:27:40 -05:00
PaddleStroke
7dcd2610f0 AssemblyObject: Use std::unordered_set instead of vector. 2024-12-13 18:04:10 +01:00
PaddleStroke
1806857c42 Assembly: Enable the use of App::Datums 2024-12-13 18:04:10 +01:00
efferre79
70ec5a7583 cmake fixes for external OndselSolver building (#18379)
* Assembly: fix building with external OndselSolver

This commit pairs with f35b075e271e9cb3451f3439f7dc0274841a0838.
It solves two issues:

- remove hardcoded includes of 3rdparty files
- add missing include_directories()

* Assembly: add check for external OndselSolver includes
2024-12-13 10:46:46 -06:00
PaddleStroke
dbdbc9934e Core: SoShapeScale fix weird scaling on viewport resize. See https://github.com/FreeCAD/FreeCAD/issues/18382#issuecomment-2527623758 2024-12-10 17:15:13 +01:00
Vincent
8dd3704d3a Assembly: fix gears created with null radius and de-sync (#18275) 2024-12-09 11:23:05 -06:00
Kacper Donat
954b729b56 Gui: Use getObject<T>() helpers in classes
This commit is generated using regex based find and replace:

```
s/[\w:]+_cast\s*<([^>]+)\*>\s*\(\s*getObject\(\s*\)\)/getObject<$1>/
s/[\w:]+_cast\s*<([^>]+)\*>\s*\(\s*([^)]*)\s*->\s*getObject\(\s*\)\)/$2->getObject<$1>()/
```

To regenerate if needed.
2024-12-06 18:29:39 +01:00
Jiří Mácha
020532dc57 Assembly: migrationScript2 and migrationScript4 improved and refactored
Description of Defects in migrationScript2 and migrationScript4:

Several additional issues have been identified in the Assembly
functions migrationScript4 and migrationScript2, beyond those fixed in
patch 71f0104bb2.

One common problem is that the Joint property Reference1 or Reference2
can be set to an invalid format. For example, user can manually cause
this issue by assigning an incorrect reference (e.g., the Z-axis) to
these properties via the FreeCAD GUI.  When this happens, internal
errors (exceptions and their corresponding Python call stack) are
reported in the Report View.  However, such information is not helpful
for the user to fix their 3D model.

Issues with the Current Implementation (Using migrationScript4 as
Reference):

- Lack of Type Validation for Reference1 and Reference2:

  The script does not check whether joint.Reference1[1] or
  joint.Reference2[1] is a sequence. If this condition is not met,
  statements like:

    sub1 = joint.Reference1[1][0]

  will throw an exception, printing the Python call stack.

- Lack of Length Validation for Sequences:

  The script does not ensure that the sequence length is sufficient
  for indexing. For example, joint.Reference1 and joint.Reference2
  must each have at least two elements to allow:

    joint.Reference1[1][1]
    joint.Reference2[1][1]

  Without validation, such calls can result in exceptions, printing the
  Python call stack.

- No Feedback on Problematic Joint:

  The user is not informed about which Assembly joint in the object
  hierarchy has an invalid Reference1 or Reference2. Depending on the
  size of the 3D model, identifying the defect can be time-consuming
  and frustrating without proper feedback.

This patch is focused on:

- Reporting Problematic Joint Path:

  A new function has been added to retrieve the full path to the
  Assembly joint. The return value (a string) is used to report the
  issue.

- Improved Exception Handling:

  Instead of adding more conditional checks (see above), exception
  handling is implemented. AttributeError, IndexError, and TypeError
  exceptions are caught. The exception message (excluding the call
  stack) is displayed at the end of a user-friendly warning.

- User-Friendly Warnings in the Report View:

  A single-line warning is now shown in the Report View, containing
  the following details:

    - Source of Warning:              'Assembly joint'
    - Location in the 3D Model: e.g., 'Assembly_XY.object_XY.joint_XY'
    - Problematic Attribute: e.g.,    'ReferenceXY'
    - Exception Message: e.g.,        'list index out of range'

- Refactoring and Optimization:

  The functions were refactored and optimized at the end of the
  conversion process.

Advantages:

- Cleaner Report View:
  Internal errors (e.g., Python call stacks) are no longer logged in
  the Report View, as they are not useful for end users. Only the
  exception message is displayed.

- Improved User Feedback:
  Users can now identify the problematic Assembly joint in the object
  hierarchy, saving significant time and effort.

- Robust and Concise Code:
  The solution simplifies the code while increasing its robustness.
2024-12-06 12:13:41 -05:00
luzpaz
2d40efd555 Fix various typos
Found with codespell
2024-12-04 23:18:00 -05:00
Aik-Siong Koh
5d143d1f59 Assembly: Simulation implementation 2024-12-03 20:07:04 +01:00
wmayer
d1ef73dddc Fix compiler warnings 2024-12-03 10:16:08 +01:00
PaddleStroke
5d937a4f84 Assembly: Insert new part (#17922)
* Assembly: Joint Object : encapsulate the joint creation widget such that the task can be subclassed and ui customized by other commands.

* Assembly: Insert New Part

* Update src/Mod/Assembly/CommandInsertNewPart.py

Co-authored-by: Kacper Donat <kadet1090@gmail.com>

---------

Co-authored-by: Kacper Donat <kadet1090@gmail.com>
2024-12-02 18:34:02 +01:00
PaddleStroke
734814f495 Assembly: Make ExplodedView: a group extension. So that we don't mimick group. Fixing the delete exploded view group issue 2024-12-02 12:14:43 -05:00
Fabio Rossi
d4b495bfd5 add local OndselSolver includes only when not external 2024-12-02 12:04:54 -05:00
Benjamin Nauck
32e339447a Move back the assembly util functions to AssemblyUtil (#18020)
* Move back util functions to AssemblyUtils again

* Add getPropertyByName<T>() helper

* Improve constness in AssemblyUtils

* [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>
2024-12-02 10:48:48 -06:00
PaddleStroke
3357baef99 Core / Assembly: Add a way for vp edit modes to be restored. 2024-11-29 12:04:25 -05:00
Jacob Oursland
960f4e4d63 CMake: Add missing target_link_directories() for OCCT. 2024-11-26 16:03:08 -05:00
Kacper Donat
03d4157627 Assembly: Refactor get/setDraggerPlacement
It seems that Base has very handy helpers for converting between various
types. This simplifies code of ViewProviderAssembly::get/setDraggerPlacement a
lot.
2024-11-25 12:27:35 -05:00
PaddleStroke
97387325c8 Assembly: Fix joints not being deleted when subassembly is deleted. 2024-11-25 18:20:46 +01:00
PaddleStroke
d0da5f7969 Assembly: Pressing Esc while a task is active will not escape edit mode 2024-11-22 12:15:57 -05:00
haruka tsubota
cabdea2764 Add help message about customizing BOM export file format in Assembly workbench 2024-11-22 11:35:00 -05:00
Jiří Mácha
2eec246e95 Assembly: fixed defect in the migrationScript4 function
The old CAD model created by the development version of FreeCAD
(in which the Assembly workbench was used) contained joints that,
for some reason, had an empty Joint Connector 1 reference (Reference1).

This was causing an exception and a crash of the Python function
called migrationScript4. The FreeCAD Report view contained:

23:28:29  pyException: Traceback (most recent call last):
  File "/FreeCAD/Mod/Assembly/JointObject.py", line 175, in onDocumentRestored
    self.createProperties(joint)
  File "/FreeCAD/Mod/Assembly/JointObject.py", line 181, in createProperties
    self.migrationScript4(joint)
  File "/FreeCAD/Mod/Assembly/JointObject.py", line 514, in migrationScript4
    if hasattr(joint, "Reference1") and joint.Reference1[0] is not None:
                                        ~~~~~~~~~~~~~~~~^^^
<class 'TypeError'>: 'NoneType' object is not subscriptable

This patch attempts to avoid such exceptions by validating the type of
the property variable before accessing it.
2024-11-18 17:46:44 +01:00
PaddleStroke
a174d87fac Assembly: Store DocumentObject instead of mbdPart for the dragged parts. Fixing the bug where doDragStep was 50% of time failing to find the correct DocumentObject due to bundling. 2024-11-18 17:43:53 +01:00
Max Wilfinger
fc3996b53f Merge pull request #17637 from furgo16/patch-3
Reword rigid/flexible sub-assemblies tooltip.
2024-11-16 10:03:52 +01:00
Furgo
2577cc9cf0 Re-add the note about right click, with more context 2024-11-16 07:15:05 +01:00
Furgo
a5c7fc98ca Reword error log to be more verbose 2024-11-15 18:53:00 +01:00
wmayer
dbc9615308 Coverity scan: Uninitialized scalar variable
* CID 350633
* CID 512344
* CID 514343
2024-11-13 18:58:16 -05:00
Yorik van Havre
04f0e7a330 Merge pull request #17782 from wwmayer/issue_17770
Unhandled std exception dragging Cylindrical joint
2024-11-11 17:56:04 +01:00
Yorik van Havre
56a897cc96 Translations (#17725)
* Translations: updated ts files

* Translations: merged crowdin translations

* [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>
2024-11-11 17:01:52 +01:00
wmayer
3db95989d3 Assembly: Handle thrown Base::Exception in ViewProviderAssembly 2024-11-11 01:11:56 +01:00
PaddleStroke
dfdd9cd286 Assembly: Fix problem with App::Link to AssemblyObject : they would not go back to position. 2024-11-09 10:16:47 -05:00
PaddleStroke
035e863592 Assembly: Fix regressions of https://github.com/FreeCAD/FreeCAD/pull/16671 2024-11-09 10:16:47 -05:00
PaddleStroke
4f2bd32048 Assembly: JointObject refactor adaptUi 2024-11-09 10:10:57 -05:00
PaddleStroke
458c2f96b1 Assembly: Improve joint taskbox offset ui. 2024-11-09 10:10:57 -05:00
PaddleStroke
6453bb578e Update CommandExportASMT.py 2024-11-09 10:09:52 -05:00
PaddleStroke
d7ea8dbe8b Update CommandSolveAssembly.py 2024-11-09 10:09:52 -05:00
PaddleStroke
38ea260fef Assembly: Fix reverse button in joint task (#17663) 2024-11-04 18:23:17 +01:00
PaddleStroke
ea334d2504 Update JointObject.py 2024-11-04 18:18:21 +01:00
PaddleStroke
f0e0f92424 Assembly: Joint creation: add expression support to spinboxes 2024-11-04 18:07:12 +01:00
Furgo
db9fbc5ff8 Reword rigid/flexible sub-assembiles tooltip. Fixes: #17636 2024-11-03 09:07:59 +01:00
Yorik van Havre
7e12ce34e7 Merge pull request #15629 from Ondsel-Development/asm_assembly_link
Assembly: Flexible sub-assemblies.
2024-10-28 17:07:26 +01:00
PaddleStroke
5ab2f3ea7e Assembly: CommandInsertLink: Hide hidden objects 2024-10-24 23:07:54 -05:00
PaddleStroke
4bd750db82 Assembly: Fix limits disappearing on edit (#17289) 2024-10-17 20:19:21 -05:00
PaddleStroke
3a7139dc39 Fix regressions of #16726 2024-10-17 20:13:23 -05:00
PaddleStroke
127d5dd840 Assembly: AssemblyLinks. 2024-10-16 15:39:23 +02:00
PaddleStroke
e0471f580d Assembly: Create SoSwitchMarker.py to externalize the coin stuff that draw the joint's markers(JCS) 2024-10-16 15:39:23 +02:00
PaddleStroke
0a4d965baf Assembly: Joint creation UI : add advanced offset handling. 2024-10-16 15:39:23 +02:00