Commit Graph

81 Commits

Author SHA1 Message Date
Vincent
ebf528a653 Assembly: fix gears created with null radius and de-sync (#18275) 2024-12-09 11:23:05 -06: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
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
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
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
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
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
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
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
PaddleStroke
876389af23 JointObject: fix flip one part 2024-10-14 08:58:35 -05:00
PaddleStroke
eab65cc42c Assembly: Remove JointObject camera callbacks. And fix lock highlight. 2024-10-14 08:27:36 -05:00
PaddleStroke
82a98d6e31 Assembly: Joint: add support to non ascii characters. 2024-10-10 20:36:54 -05:00
PaddleStroke
a445b01869 Assembly: Fix joint labels bad auto-rename issue. 2024-10-10 20:36:54 -05:00
PaddleStroke
736f03caf2 Assembly: Fix gear/belt switch on checkbox toggle 2024-10-10 20:26:18 -05:00
PaddleStroke
13eeb7b8c2 Assembly: Fix migrationScript2 error with bad joints (#17010)
* Fix migrationScript2 to handle bad joints
2024-10-07 18:48:38 -05:00
Chris Hennes
7a37ea9bc0 Merge pull request #16726 from bgbsww/bgbsww-AssemblySubNames
Assembly: Correctly build reference from selection subname
2024-10-03 13:46:35 -05:00
bgbsww
d535c5a6e7 Refine further 2024-09-27 13:00:19 -04:00
bgbsww
7bed7ef370 Return to python; simplify to work with only classic names, provide migration 2024-09-26 00:01:10 -04:00
bgbsww
f0053e5388 Correctly build reference from selection subname 2024-09-24 22:01:14 -04:00
bgbsww
a715a4d161 Support macros and console logs in Assembly 2024-09-23 14:10:55 -05:00
PaddleStroke
7f83336ba8 Assembly: Replace Offset and Rotation properties by Offset1 and Offset2, giving full control over JCS positions. 2024-09-09 18:22:06 +02:00
PaddleStroke
7c6dde17fb Assembly: Fix case of link groups 2024-09-02 18:20:18 +02:00
PaddleStroke
4f79c675b7 Assembly: Property change from Object/Part to Reference 2024-07-29 17:48:25 +02:00
PaddleStroke
a3436c2d5f Assembly: Create joint: prevent errors on undo/ctrl-Z 2024-07-10 08:44:08 +02:00
Max Wilfinger
7d21d9edb8 Fix source string typos mentioned on Crowdin (#15261) 2024-07-08 17:18:31 -05:00
PaddleStroke
cf5314919a Assembly: Change Object1/2 from strings to PropertyXLinkSub and Remove Element1/2 and Vertex1/2 2024-07-01 11:22:30 -05:00
Chris Hennes
0a39ab952d Merge pull request #14738 from Ondsel-Development/asm_limits
Assembly: Limits: Set one checkbox for each limit.
2024-07-01 10:54:19 -05:00
PaddleStroke
e7699b531e Assembly: Gears: Fix crash if user selected first elements before triggering tool. 2024-06-28 12:07:11 -05:00
PaddleStroke
632780ce35 Assembly: Create Joint limit: Moving objects updates the spinboxes values if they are disabled. 2024-06-27 09:10:38 +02:00
PaddleStroke
a0c4a273ba Assembly: Enable moving objects while making joints. 2024-06-27 09:10:38 +02:00
PaddleStroke
bba868912b Assembly: Create Joint : fix untranslated strings. 2024-06-27 09:10:37 +02:00
PaddleStroke
2114da3bbb Assembly: Limits: Set one checkbox for each limit. 2024-06-26 17:06:02 +02:00
Chris Hennes
87154d75a8 Merge pull request #14908 from Ondsel-Development/asm_sub_fix
Assembly: Fix link to external sub assemblies issues.
2024-06-25 09:15:52 -05:00
PaddleStroke
5e14435e02 Assembly: Fix a bug with presolve. Presolve should not happen when there's a loop of joints. 2024-06-25 09:12:50 -05:00
PaddleStroke
5dfb708d7d Assembly: jointObject : handle case where gui_doc.ActiveView is None. 2024-06-24 17:52:29 +02:00
PaddleStroke
55dd8076cc Assembly: deleting a component deletes its joints. 2024-06-17 10:58:11 -05:00
PaddleStroke
47031f2d4e Assembly: Translate error 2024-05-30 10:33:19 +02:00
PaddleStroke
cecb965f50 Assembly: Add 'Angle', 'Perpendicular' and 'Parallel' joints. 2024-05-27 11:59:06 -05:00
Max Wilfinger
748306dcaf Update assembly icons to be consistent with main updates.
Add commands to menu/toolbar.
2024-05-20 10:46:45 -05:00
PaddleStroke
de683708ba Assembly: Fix Gear Radius2 spinbox issue 2024-05-06 18:32:00 +02:00
PaddleStroke
ca8ab83e09 Assembly: Improve Exploded View's radial explosion, and various small fixes. 2024-05-06 18:32:00 +02:00
PaddleStroke
15176db32c Assembly: Mark new features as experimental. To enable them you need to create a parameter called ExperimentalFeatures and set it to true. 2024-05-06 18:32:00 +02:00
PaddleStroke
b44505db39 Assembly: Fix small bugs in AssemblyObject.cpp, JointObject.py and UtilsAssembly.py 2024-05-06 18:32:00 +02:00
PaddleStroke
d5beaf900e Assembly: Introduce Belt joint. 2024-05-06 18:32:00 +02:00