Commit Graph

541 Commits

Author SHA1 Message Date
mosfet80
29d685b452 Clean ViewProviderAssembly.cpp 2024-12-13 12:27:40 -05:00
efferre79
fe57e3176d 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
396963006b 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
ebf528a653 Assembly: fix gears created with null radius and de-sync (#18275) 2024-12-09 11:23:05 -06:00
Kacper Donat
651cefde4d 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
878d9525dc 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
96c838f3b9 Fix various typos
Found with codespell
2024-12-04 23:18:00 -05:00
Aik-Siong Koh
3326c33d83 Assembly: Simulation implementation 2024-12-03 20:07:04 +01:00
wmayer
7fdc3b807a Fix compiler warnings 2024-12-03 10:16:08 +01:00
PaddleStroke
f6268ffd28 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
b29f2cdfe2 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
18f63edadb add local OndselSolver includes only when not external 2024-12-02 12:04:54 -05:00
Benjamin Nauck
e5c2c81685 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
ef3445e9e1 Core / Assembly: Add a way for vp edit modes to be restored. 2024-11-29 12:04:25 -05:00
Jacob Oursland
fb7ce6405b CMake: Add missing target_link_directories() for OCCT. 2024-11-26 16:03:08 -05:00
Kacper Donat
710542d121 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
99b2f23214 Assembly: Fix joints not being deleted when subassembly is deleted. 2024-11-25 18:20:46 +01:00
PaddleStroke
979075ce0d Assembly: Pressing Esc while a task is active will not escape edit mode 2024-11-22 12:15:57 -05:00
haruka tsubota
2c1348fdc2 Add help message about customizing BOM export file format in Assembly workbench 2024-11-22 11:35:00 -05:00
Jiří Mácha
71f0104bb2 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
a049641771 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
b3423694c0 Merge pull request #17637 from furgo16/patch-3
Reword rigid/flexible sub-assemblies tooltip.
2024-11-16 10:03:52 +01:00
Furgo
477ea046d0 Re-add the note about right click, with more context 2024-11-16 07:15:05 +01:00
Furgo
a597015d05 Reword error log to be more verbose 2024-11-15 18:53:00 +01:00
wmayer
ee1af2748a Coverity scan: Uninitialized scalar variable
* CID 350633
* CID 512344
* CID 514343
2024-11-13 18:58:16 -05:00
Yorik van Havre
36c6a9ffa0 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
a9b4cb5611 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
ae32212245 Assembly: Handle thrown Base::Exception in ViewProviderAssembly 2024-11-11 01:11:56 +01:00
PaddleStroke
03af502347 Assembly: Fix problem with App::Link to AssemblyObject : they would not go back to position. 2024-11-09 10:16:47 -05:00
PaddleStroke
22d278c7c0 Assembly: Fix regressions of https://github.com/FreeCAD/FreeCAD/pull/16671 2024-11-09 10:16:47 -05:00
PaddleStroke
b3d9c471ee Assembly: JointObject refactor adaptUi 2024-11-09 10:10:57 -05:00
PaddleStroke
bf64ab9f51 Assembly: Improve joint taskbox offset ui. 2024-11-09 10:10:57 -05:00
PaddleStroke
ca0549d489 Update CommandExportASMT.py 2024-11-09 10:09:52 -05:00
PaddleStroke
6fa1b1c3b2 Update CommandSolveAssembly.py 2024-11-09 10:09:52 -05:00
PaddleStroke
1b1e355b9b Assembly: Fix reverse button in joint task (#17663) 2024-11-04 18:23:17 +01:00
PaddleStroke
1b35d8b0f1 Update JointObject.py 2024-11-04 18:18:21 +01:00
PaddleStroke
28a977b5fc Assembly: Joint creation: add expression support to spinboxes 2024-11-04 18:07:12 +01:00
Furgo
02847d25dc Reword rigid/flexible sub-assembiles tooltip. Fixes: #17636 2024-11-03 09:07:59 +01:00
Yorik van Havre
15100357df Merge pull request #15629 from Ondsel-Development/asm_assembly_link
Assembly: Flexible sub-assemblies.
2024-10-28 17:07:26 +01:00
PaddleStroke
5823046e6b Assembly: CommandInsertLink: Hide hidden objects 2024-10-24 23:07:54 -05:00
PaddleStroke
f111d46002 Assembly: Fix limits disappearing on edit (#17289) 2024-10-17 20:19:21 -05:00
PaddleStroke
9b407eed07 Fix regressions of #16726 2024-10-17 20:13:23 -05:00
PaddleStroke
761e5a43e8 Assembly: AssemblyLinks. 2024-10-16 15:39:23 +02:00
PaddleStroke
62575f2d63 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
fe5c883e4c Assembly: Joint creation UI : add advanced offset handling. 2024-10-16 15:39:23 +02:00
pre-commit-ci[bot]
dda69c8b60 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-10-14 17:56:08 +02:00
Yorik van Havre
e8fc9cf45f crowdin translations 2024-10-14 17:56:08 +02:00
Yorik van Havre
6c08b5a63c updated ts files 2024-10-14 17:56:08 +02:00
Furgo
df639075b1 Assembly: make "Solve failed" error more verbose (#17117)
* Add FC_ERR macro for the 'Solve failed' Assembly error

* Handle standard exceptions during assembly solve

* [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-10-14 10:43:15 -05:00
PaddleStroke
28b1112451 AssemblyObject.cpp : add failsafe checks 2024-10-14 08:58:35 -05:00