Commit Graph

84 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
1806857c42 Assembly: Enable the use of App::Datums 2024-12-13 18:04:10 +01: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
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
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
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
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
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
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
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
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
PaddleStroke
fd432f2bdc JointObject: fix flip one part 2024-10-14 08:58:35 -05:00
PaddleStroke
70142112f9 Assembly: Remove JointObject camera callbacks. And fix lock highlight. 2024-10-14 08:27:36 -05:00
PaddleStroke
ab4b95a459 Assembly: Joint: add support to non ascii characters. 2024-10-10 20:36:54 -05:00
PaddleStroke
c6c4e8cc25 Assembly: Fix joint labels bad auto-rename issue. 2024-10-10 20:36:54 -05:00
PaddleStroke
5ce79a760b Assembly: Fix gear/belt switch on checkbox toggle 2024-10-10 20:26:18 -05:00
PaddleStroke
29b719664b Assembly: Fix migrationScript2 error with bad joints (#17010)
* Fix migrationScript2 to handle bad joints
2024-10-07 18:48:38 -05:00
Chris Hennes
d1cdcd18bf Merge pull request #16726 from bgbsww/bgbsww-AssemblySubNames
Assembly: Correctly build reference from selection subname
2024-10-03 13:46:35 -05:00
bgbsww
d14ca595bd Refine further 2024-09-27 13:00:19 -04:00
bgbsww
d51f0f0f2a Return to python; simplify to work with only classic names, provide migration 2024-09-26 00:01:10 -04:00
bgbsww
e0e1cb565a Correctly build reference from selection subname 2024-09-24 22:01:14 -04:00
bgbsww
48c65aed76 Support macros and console logs in Assembly 2024-09-23 14:10:55 -05:00
PaddleStroke
20219c7e28 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
452d4a61d2 Assembly: Fix case of link groups 2024-09-02 18:20:18 +02:00
PaddleStroke
8d3e3acd11 Assembly: Property change from Object/Part to Reference 2024-07-29 17:48:25 +02:00
PaddleStroke
f92c4e393d Assembly: Create joint: prevent errors on undo/ctrl-Z 2024-07-10 08:44:08 +02:00
Max Wilfinger
8ff5a1f688 Fix source string typos mentioned on Crowdin (#15261) 2024-07-08 17:18:31 -05:00
PaddleStroke
f5a6e0fd32 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
82a680443c 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
61c800c708 Assembly: Gears: Fix crash if user selected first elements before triggering tool. 2024-06-28 12:07:11 -05:00
PaddleStroke
c2c2178c51 Assembly: Create Joint limit: Moving objects updates the spinboxes values if they are disabled. 2024-06-27 09:10:38 +02:00
PaddleStroke
fcf54e031c Assembly: Enable moving objects while making joints. 2024-06-27 09:10:38 +02:00
PaddleStroke
e5d604369b Assembly: Create Joint : fix untranslated strings. 2024-06-27 09:10:37 +02:00
PaddleStroke
9ae198ab95 Assembly: Limits: Set one checkbox for each limit. 2024-06-26 17:06:02 +02:00
Chris Hennes
2354e08699 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
74eb6bb156 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
4fcd31a373 Assembly: jointObject : handle case where gui_doc.ActiveView is None. 2024-06-24 17:52:29 +02:00
PaddleStroke
3052760541 Assembly: deleting a component deletes its joints. 2024-06-17 10:58:11 -05:00
PaddleStroke
9ec47a58a8 Assembly: Translate error 2024-05-30 10:33:19 +02:00
PaddleStroke
5fb3589f26 Assembly: Add 'Angle', 'Perpendicular' and 'Parallel' joints. 2024-05-27 11:59:06 -05:00
Max Wilfinger
323ec08e8e Update assembly icons to be consistent with main updates.
Add commands to menu/toolbar.
2024-05-20 10:46:45 -05:00
PaddleStroke
b12b95b908 Assembly: Fix Gear Radius2 spinbox issue 2024-05-06 18:32:00 +02:00
PaddleStroke
fed17ff6f1 Assembly: Improve Exploded View's radial explosion, and various small fixes. 2024-05-06 18:32:00 +02:00