Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve bend offset calculations when angle isn't 90deg. #452

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Resources/panels/FlangeParameters.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,26 @@ min-width: 28px;</string>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Material Inside (90° legacy)</string>
</property>
<property name="icon">
<iconset>
<normalon>Icons:SheetMetal_WallPosMatIns.svg</normalon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Thickness Outside (legacy)</string>
</property>
<property name="icon">
<iconset>
<normalon>Icons:SheetMetal_WallPosThkOut.svg</normalon>
</iconset>
</property>
</item>
</widget>
</item>
</layout>
Expand Down
22 changes: 15 additions & 7 deletions SheetMetalCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1263,12 +1263,18 @@ def smBend(
if BendType == "Material Outside":
offset = 0.0
inside = False
elif BendType == "Material Inside":
elif BendType == "Material Inside": # legacy mode for backwards compatibility
offset = -(thk + bendR)
inside = True
elif BendType == "Thickness Outside":
elif BendType == "Thickness Outside": # legacy mode for backwards compatibility
offset = -bendR
inside = True
elif BendType == "Material Inside V2":
offset = -(thk + bendR) * abs(math.tan(math.radians(bendA * 0.5)))
inside = True
elif BendType == "Thickness Outside V2":
offset = -bendR * abs(math.tan(math.radians(bendA * 0.5)))
inside = True
elif BendType == "Offset":
if offset < 0.0:
inside = True
Expand All @@ -1278,14 +1284,14 @@ def smBend(
if LengthSpec == "Leg":
pass
elif LengthSpec == "Tangential":
if bendA >= 90.0:
if bendA >= 90.0 or bendA <= -90.0:
extLen -= thk + bendR
else:
extLen -= (bendR + thk) / math.tan(math.radians(90.0 - bendA / 2))
extLen -= (bendR + thk) / abs(math.tan(math.radians(90.0 - bendA / 2)))
elif LengthSpec == "Inner Sharp":
extLen -= (bendR) / math.tan(math.radians(90.0 - bendA / 2))
extLen -= (bendR) / abs(math.tan(math.radians(90.0 - bendA / 2)))
elif LengthSpec == "Outer Sharp":
extLen -= (bendR + thk) / math.tan(math.radians(90.0 - bendA / 2))
extLen -= (bendR + thk) / abs(math.tan(math.radians(90.0 - bendA / 2)))

nogaptrimedgelist = []
if not (sketches):
Expand Down Expand Up @@ -1781,7 +1787,9 @@ def addVerifyProperties(self, obj, refAngOffset=None, checkRefFace=False):
obj,
"BendType",
translate("App::Property", "Bend Type"),
["Material Outside", "Material Inside", "Thickness Outside", "Offset"],
["Material Outside", "Material Inside V2", "Thickness Outside V2", "Offset",
# legacy modes
"Material Inside", "Thickness Outside"],
)
SheetMetalTools.smAddEnumProperty(
obj,
Expand Down