24 __title__ =
"DialogDistribution" 25 __author__ =
"Amritpal Singh" 26 __url__ =
"https://www.freecadweb.org" 28 from PySide
import QtCore, QtGui
29 from Rebarfunc
import *
30 from PySide.QtCore
import QT_TRANSLATE_NOOP
42 self.
form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0] +
".ui")
43 self.form.setWindowTitle(QtGui.QApplication.translate(
"Arch",
"Rebar Distribution",
None))
44 self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] +
"/icons/RebarDistribution.svg"))
47 amount1 = self.form.amount1.value()
48 spacing1 = self.form.spacing1.text()
49 spacing1 = FreeCAD.Units.Quantity(spacing1).Value
50 amount2 = self.form.amount2.value()
51 spacing2 = self.form.spacing2.text()
52 spacing2 = FreeCAD.Units.Quantity(spacing2).Value
53 amount3 = self.form.amount3.value()
54 spacing3 = self.form.spacing3.text()
55 spacing3 = FreeCAD.Units.Quantity(spacing3).Value
60 self.form.buttonBox.accepted.connect(self.
accept)
64 seg1_area = amount1 * spacing1 - spacing1 / 2
65 seg3_area = amount3 * spacing3 - spacing3 / 2
66 seg2_area = size - seg1_area - seg3_area - 2 * frontCover
68 FreeCAD.Console.PrintError(
"Sum of length of segment 1 and segment 2 is greater than length of rebar expands.\n")
70 if spacing1
and spacing2
and spacing3
and amount1
and amount2
and amount3:
73 if spacing1
and spacing2
and spacing3:
74 amount2 = math.ceil(seg2_area / spacing2)
75 spacing2 = seg2_area / amount2
76 elif amount1
and amount2
and amount3:
77 spacing2 = math.floor(seg2_area / amount2)
78 CustomSpacing = str(amount1) +
"@" + str(spacing1) +
"+" + str(int(amount2)) +
"@" + str(spacing2) +
"+" + str(amount3) +
"@" + str(spacing3)
82 """ gettupleOfCustomSpacing(span_string): This function take input 83 in specific syntax and return output in the form of list. For eg. 84 Input: "3@100+2@200+3@100" 85 Output: [(3, 100), (2, 200), (3, 100)]""" 87 span_st = string.strip(span_string)
88 span_sp = string.split(span_st,
'+')
91 while index < len(span_sp):
93 in_sp = string.split(span_sp[index],
'@')
94 spacinglist.append((int(in_sp[0]),float(in_sp[1])))
99 frontCover = self.form.frontCover.text()
100 frontCover = FreeCAD.Units.Quantity(frontCover).Value
101 face = self.SelectedObj.Shape.Faces[
getFaceNumber(self.FaceName) - 1]
102 size = (ArchCommands.projectToVector(self.SelectedObj.Shape.copy(), face.normalAt(0, 0))).Length
106 self.CustomSpacing = dialog.CustomSpacing
109 self.CustomSpacing =
"" 110 self.Rebar.CustomSpacing =
"" 111 FreeCAD.ActiveDocument.recompute()
def __init__(self, frontCover, size)
def runRebarDistribution(self)
def removeRebarDistribution(self)
def getCustomSpacingString(amount1, spacing1, amount2, spacing2, amount3, spacing3, frontCover, size)
def getupleOfCustomSpacing(span_string)