Skip to content

Commit

Permalink
Updated the areas computation tool to the new spreadsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
sanguinariojoe authored and yorikvanhavre committed Jun 1, 2015
1 parent 071829d commit 5c79b2f
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions src/Mod/Ship/shipAreasCurve/PlotAux.py
Expand Up @@ -115,37 +115,35 @@ def spreadSheet(self, x, y, ship):
@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()

0 comments on commit 5c79b2f

Please sign in to comment.