mwganson / ThreadProfile

Create 2d thread profile for sweeping along helix in Part or Part Design workbenches
GNU Lesser General Public License v2.1
40 stars 8 forks source link

Helix is not putted to active body #47

Closed tritol closed 2 years ago

tritol commented 2 years ago

Make helix button at active body fails with:

Running the Python command 'ThreadProfileMakeHelix' failed: Traceback (most recent call last): File "/home/tritol/.local/share/FreeCAD/Mod/ThreadProfile/./ThreadProfileCmd.py", line 399, in Activated body.Group=body.Group+[getattr(doc,name)] #put helix in body to avoid out of scope warnings

Object can only be in a single GeoFeatureGroup

[code] OS: Arch Linux Word size of FreeCAD: 64-bit Version: 0.20.29177 (Git) AppImage Build type: Release Branch: (HEAD detached at 0.20) Hash: 68e337670e227889217652ddac593c93b5e8dc94 Python 3.9.13, Qt 5.12.9, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.3 Locale: Czech/Czech Republic (cs_CZ) Installed mods:

tritol commented 2 years ago

This probably fixed it:

--- ThreadProfileCmd.py.orig    2022-08-04 00:10:48.974435796 +0200
+++ ThreadProfileCmd.py 2022-08-04 00:11:11.488046725 +0200
@@ -393,10 +393,10 @@
             helix.AttachmentOffset = profile.AttachmentOffset
         body=FreeCADGui.ActiveDocument.ActiveView.getActiveObject("pdbody")
         part=FreeCADGui.ActiveDocument.ActiveView.getActiveObject("part")
-        if part:
-            part.Group=part.Group+[getattr(doc,name)]
         if body:
             body.Group=body.Group+[getattr(doc,name)] #put helix in body to avoid out of scope warnings
+        elif part:
+            part.Group=part.Group+[getattr(doc,name)]
         doc.commitTransaction()
         doc.recompute()
         return
mwganson commented 2 years ago

I added your change to new version (1.82). Please test.

tritol commented 2 years ago

1.82 works for me, thanks.