From 5c79b2f76277b18dd7621e4b4f653608531f065a Mon Sep 17 00:00:00 2001 From: "J.L. Cercos-Pita" Date: Sun, 31 May 2015 18:08:15 +0200 Subject: [PATCH] Updated the areas computation tool to the new spreadsheet --- src/Mod/Ship/shipAreasCurve/PlotAux.py | 44 ++++++++++++-------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/Mod/Ship/shipAreasCurve/PlotAux.py b/src/Mod/Ship/shipAreasCurve/PlotAux.py index 78e3bce05..4d6427a71 100644 --- a/src/Mod/Ship/shipAreasCurve/PlotAux.py +++ b/src/Mod/Ship/shipAreasCurve/PlotAux.py @@ -115,37 +115,35 @@ class Plot(object): @param y Transversal areas. @param ship Active ship instance. """ - # Create the spreadsheet - obj = Spreadsheet.makeSpreadsheet() - s = obj.Proxy - obj.Label = 'Areas curve' + s = FreeCAD.activeDocument().addObject('Spreadsheet::Sheet', + 'Areas curve') # Print the header - s.a1 = "x [m]" - s.b1 = "area [m^2]" - s.c1 = "FP x" - s.d1 = "FP y" - s.e1 = "AP x" - s.f1 = "AP y" + s.set("A1", "x [m]") + s.set("B1", "area [m^2]") + s.set("C1", "FP x") + s.set("D1", "FP y") + s.set("E1", "AP x") + s.set("F1", "AP y") # Print the perpendiculars data Lpp = ship.Length.getValueAs('m').Value FPx = 0.5 * Lpp APx = -0.5 * Lpp maxArea = max(y) - s.c2 = FPx - s.d2 = 0.0 - s.c3 = FPx - s.d3 = maxArea - s.e2 = APx - s.f2 = 0.0 - s.e3 = APx - s.f3 = maxArea - + s.set("C2", str(FPx)) + s.set("D2", str(0.0)) + s.set("C3", str(FPx)) + s.set("D3", str(maxArea)) + s.set("E2", str(APx)) + s.set("F2", str(0.0)) + s.set("E3", str(APx)) + s.set("F3", str(maxArea)) + # Print the data for i in range(len(x)): - s.__setattr__("a{}".format(i + 2), x[i]) - s.__setattr__("b{}".format(i + 2), y[i]) + s.set("A{}".format(i + 2), str(x[i])) + s.set("B{}".format(i + 2), str(y[i])) - # Open the spreadsheet - FreeCADGui.ActiveDocument.setEdit(obj.Name,0) + # Recompute + FreeCAD.activeDocument().recompute() \ No newline at end of file