Skip to content

Fix: Multiple bugs in ElbowQM (dodoPM.py) causing invisible/null shape elbows in FreeCAD 1.1+ #55

Description

@sanfemar

When inserting an elbow using the QM dialog in FreeCAD 1.1.1 (Linux, Spanish locale), the elbow object is created in the tree but has a Null Shape (invisible, the "eye" icon is toggled off and cannot be toggled on).

After debugging, I found 6 interconnected bugs in dodoPM.py, pCmd.py, and pFeatures.py. Here are the details and the fixes I applied locally to make it work:
Bug 1: Incorrect argument order in dodoPM.py (Critical - Main cause of Null Shape)

The eQM.go() method calls pCmd.doElbow() passing arguments in the wrong order.doElbow signature is: def doElbow(rating, propList, pypeline, doOffset)But the call omits rating and shifts the arguments:

CURRENT (WRONG):pCmd.doElbow( [d["PSize"], float(d["OD"]), float(d["thk"]), ang, rad], # Goes to 'rating' FreeCAD.activePypeLine, # Goes to 'propList')

Fix:
python

FIXED:

pCmd.doElbow(
self.PRating, # rating
[d["PSize"], float(d["OD"]), float(d.get("thk") or d.get("Thk") or d.get("thickness") or 0), ang, rad], # propList
FreeCAD.activePypeLine, # pypeline
)

Bug 2: Locale decimal separator crash

In locales that use a comma as a decimal separator (e.g., Spanish), typing 304,8 in the radius field causes a ValueError.

Fix in dodoPM.py line ~425:
python

CURRENT:

rad = float(self.QM.lineEdit2.text())

FIXED:

rad = float(self.QM.lineEdit2.text().replace(',', '.'))

Bug 3: KeyError: 'thk'

Some CSV standards might not have the thk column, or it might be capitalized, causing a KeyError.

Fix in dodoPM.py line ~432:
python

CURRENT:

float(d["thk"])

FIXED:

float(d.get("thk") or d.get("Thk") or d.get("thickness") or 0)

Bug 4: Empty BendRadius in CSV

In Elbow_SCH-XS_SR90.csv, rows for DN15 and DN20 have an empty BendRadius column. This causes a float conversion error downstream.

Fix in dodoPM.py line ~429:
python

CURRENT:

rad = d["BendRadius"]

FIXED:

rad = float(d["BendRadius"]) if d["BendRadius"] else float(d["OD"]) * 1.5

Bug 5: No selection validation on listSize

If no size is selected in the QM dialog, self.QM.listSize.currentRow() returns -1, causing an IndexError or passing invalid data.

Fix in dodoPM.py method eQM.go():
python

CURRENT:

def go(self):
d = self.dictList[self.QM.listSize.currentRow()]

FIXED:

def go(self):
row = self.QM.listSize.currentRow()
if row < 0:
return
d = self.dictList[row]

Bug 6: Silent failures in pFeatures.py

The execute method in the Elbow class catches exceptions with pass or minimal warnings. If the shape generation fails (due to Bug 1), the object is left with a Null Shape and the user has no idea why.

Fix in pFeatures.py around lines 371 and 411:
Change silent exception handling to print the actual error so users can debug:
python

CURRENT:

except Exception:
# FreeCAD.Console.PrintWarning(str(e) + "\n")
pass

FIXED:

except Exception as e:
import traceback
FreeCAD.Console.PrintWarning("ELBOW PARENT ERROR: " + str(e) + "\n")
traceback.print_exc()

And:
python

CURRENT:

except Part.OCCError as occer:
FreeCAD.Console.PrintWarning(str(occer) + "\n")

FIXED:

except Exception as occer:
import traceback
FreeCAD.Console.PrintWarning("ELBOW SHAPE ERROR: " + str(occer) + "\n")
traceback.print_exc()

Environment:

 FreeCAD version: 1.1.1
 OS: Linux (Spanish locale)
 Quetzal: v1.8.9

Thank you for this great workbench! I hope these fixes can be integrated into the next release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions