diff --git a/src/Mod/Draft/Resources/ui/dialogHatch.ui b/src/Mod/Draft/Resources/ui/dialogHatch.ui
index 8721a59577..9f19858492 100644
--- a/src/Mod/Draft/Resources/ui/dialogHatch.ui
+++ b/src/Mod/Draft/Resources/ui/dialogHatch.ui
@@ -75,6 +75,25 @@
+ -
+
+
+ Align to face:
+
+
+
+ -
+
+
+ If checked, the pattern aligns with the base object.
+If unchecked, the pattern aligns with the global coordinate system.
+This setting modifies the Translate property.
+
+
+
+
+
+
diff --git a/src/Mod/Draft/draftguitools/gui_hatch.py b/src/Mod/Draft/draftguitools/gui_hatch.py
index 8ae0db536a..9d6eae9523 100644
--- a/src/Mod/Draft/draftguitools/gui_hatch.py
+++ b/src/Mod/Draft/draftguitools/gui_hatch.py
@@ -70,6 +70,7 @@ class Draft_Hatch_TaskPanel:
self.form.Pattern.setCurrentText(pat)
self.form.Scale.setValue(params.get_param("HatchPatternScale"))
self.form.Rotation.setValue(params.get_param("HatchPatternRotation"))
+ self.form.Translate.setChecked(params.get_param("HatchPatternTranslate"))
todo.delay(self.form.setFocus, None) # Make sure using Esc works.
def accept(self):
@@ -80,6 +81,7 @@ class Draft_Hatch_TaskPanel:
params.set_param("HatchPatternName", self.form.Pattern.currentText())
params.set_param("HatchPatternScale", self.form.Scale.value())
params.set_param("HatchPatternRotation", self.form.Rotation.value())
+ params.set_param("HatchPatternTranslate", self.form.Translate.isChecked())
if hasattr(self.baseobj,"File") and hasattr(self.baseobj,"Pattern"):
# modify existing hatch object
o = "FreeCAD.ActiveDocument.getObject(\""+self.baseobj.Name+"\")"
@@ -87,6 +89,7 @@ class Draft_Hatch_TaskPanel:
FreeCADGui.doCommand(o+".Pattern=\""+self.form.Pattern.currentText()+"\"")
FreeCADGui.doCommand(o+".Scale="+str(self.form.Scale.value()))
FreeCADGui.doCommand(o+".Rotation="+str(self.form.Rotation.value()))
+ FreeCADGui.doCommand(o+".Translate="+str(self.form.Translate.isChecked()))
else:
# create new hatch object
FreeCAD.ActiveDocument.openTransaction("Create Hatch")
@@ -96,7 +99,8 @@ class Draft_Hatch_TaskPanel:
cmd += "\"),filename=\""+self.form.File.property("fileName")
cmd += "\",pattern=\""+self.form.Pattern.currentText()
cmd += "\",scale="+str(self.form.Scale.value())
- cmd += ",rotation="+str(self.form.Rotation.value())+")"
+ cmd += ",rotation="+str(self.form.Rotation.value())
+ cmd += ",translate="+str(self.form.Translate.isChecked())+")"
FreeCADGui.doCommand(cmd)
FreeCAD.ActiveDocument.commitTransaction()
FreeCADGui.doCommand("FreeCAD.ActiveDocument.recompute()")
diff --git a/src/Mod/Draft/draftmake/make_hatch.py b/src/Mod/Draft/draftmake/make_hatch.py
index e88792d2ac..c237b57a69 100644
--- a/src/Mod/Draft/draftmake/make_hatch.py
+++ b/src/Mod/Draft/draftmake/make_hatch.py
@@ -27,11 +27,11 @@ from draftobjects.hatch import Hatch
if FreeCAD.GuiUp:
from draftviewproviders.view_hatch import ViewProviderDraftHatch
-def make_hatch(baseobject, filename, pattern, scale, rotation):
+def make_hatch(baseobject, filename, pattern, scale, rotation, translate=True):
- """make_hatch(baseobject, filename, pattern, scale, rotation): Creates and returns a
+ """make_hatch(baseobject, filename, pattern, scale, rotation, translate): Creates and returns a
hatch object made by applying the given pattern of the given PAT file to the faces of
- the given base object. Given scale and rotation factors are applied to the hatch object.
+ the given base object. Given scale, rotation and translate factors are applied to the hatch object.
The result is a Part-based object created in the active document."""
if not FreeCAD.ActiveDocument:
@@ -43,6 +43,7 @@ def make_hatch(baseobject, filename, pattern, scale, rotation):
obj.Pattern = pattern
obj.Scale = scale
obj.Rotation = rotation
+ obj.Translate = translate
if FreeCAD.GuiUp:
ViewProviderDraftHatch(obj.ViewObject)
return obj
diff --git a/src/Mod/Draft/draftutils/params.py b/src/Mod/Draft/draftutils/params.py
index c2b26f62f7..e4046a8a90 100644
--- a/src/Mod/Draft/draftutils/params.py
+++ b/src/Mod/Draft/draftutils/params.py
@@ -454,6 +454,7 @@ def _get_param_dictionary():
"HatchPatternResolution": ("int", 128), # used for SVG patterns
"HatchPatternRotation": ("float", 0.0),
"HatchPatternScale": ("float", 100.0),
+ "HatchPatternTranslate": ("bool", True),
"labeltype": ("string", "Custom"),
"LayersManagerHeight": ("int", 320),
"LayersManagerWidth": ("int", 640),
diff --git a/src/Mod/Draft/draftviewproviders/view_hatch.py b/src/Mod/Draft/draftviewproviders/view_hatch.py
index 142ecb7b7d..f66f0c20bf 100644
--- a/src/Mod/Draft/draftviewproviders/view_hatch.py
+++ b/src/Mod/Draft/draftviewproviders/view_hatch.py
@@ -67,6 +67,7 @@ class ViewProviderDraftHatch:
taskd.form.Pattern.setCurrentText(vobj.Object.Pattern)
taskd.form.Scale.setValue(vobj.Object.Scale)
taskd.form.Rotation.setValue(vobj.Object.Rotation)
+ taskd.form.Translate.setChecked(vobj.Object.Translate)
Gui.Control.showDialog(taskd)
return True