Draft: fix issues with grid spacing parameter

This commit is contained in:
0penBrain
2022-05-18 08:45:02 +02:00
parent d92c018eb6
commit 272ab6ff72
3 changed files with 11 additions and 5 deletions

View File

@@ -96,7 +96,10 @@ class Draft_SelectPlane:
# Fill values
self.taskd.form.checkCenter.setChecked(self.param.GetBool("CenterPlaneOnView", False))
q = FreeCAD.Units.Quantity(self.param.GetFloat("gridSpacing", 1.0), FreeCAD.Units.Length)
try:
q = FreeCAD.Units.Quantity(self.param.GetString("gridSpacing", "1 mm"))
except ValueError:
q = FreeCAD.Units.Quantity("1 mm")
self.taskd.form.fieldGridSpacing.setText(q.UserString)
self.taskd.form.fieldGridMainLine.setValue(self.param.GetInt("gridEvery", 10))
self.taskd.form.fieldGridExtension.setValue(self.param.GetInt("gridSize", 100))
@@ -477,7 +480,7 @@ class Draft_SelectPlane:
except Exception:
pass
else:
self.param.SetFloat("gridSpacing", q.Value)
self.param.SetString("gridSpacing", q.UserString)
if hasattr(FreeCADGui, "Snapper"):
FreeCADGui.Snapper.setGrid()

View File

@@ -1210,7 +1210,10 @@ class gridTracker(Tracker):
def reset(self):
"""Reset the grid according to preferences settings."""
self.space = Draft.getParam("gridSpacing", 1)
try:
self.space = FreeCAD.Units.Quantity(Draft.getParam("gridSpacing", "1 mm")).Value
except ValueError:
self.space = 1
self.mainlines = Draft.getParam("gridEvery", 10)
self.numlines = Draft.getParam("gridSize", 100)
self.update()

View File

@@ -172,9 +172,9 @@ def get_param_type(param):
elif param in ("constructiongroupname", "textfont",
"patternFile", "template", "snapModes",
"FontFile", "ClonePrefix", "overrideUnit",
"labeltype") or "inCommandShortcut" in param:
"labeltype", "gridSpacing") or "inCommandShortcut" in param:
return "string"
elif param in ("textheight", "tolerance", "gridSpacing",
elif param in ("textheight", "tolerance",
"arrowsize", "extlines", "dimspacing",
"dimovershoot", "extovershoot", "HatchPatternSize"):
return "float"