Skip to content
Permalink
Browse files

Implemented Pick selected button in all rebar shapes

  • Loading branch information...
amrit3701 committed Jul 6, 2017
1 parent 6f013f2 commit f2dd3c23381af4a827605c573304dc78d161bae5
Showing with 154 additions and 108 deletions.
  1. +14 −0 Rebarfunc.py
  2. +19 −11 Stirrup.py
  3. +44 −30 Stirrup.ui
  4. +4 −25 StraightRebar.py
  5. +24 −24 StraightRebar.ui
  6. +18 −9 UShapeRebar.py
  7. +31 −9 UShapeRebar.ui
@@ -183,6 +183,20 @@ def extendedTangentLength(rounding, diameter, angle):
x2 = radius * math.tan(math.radians(90 - angle))
return x1 + x2

def getSelectedFace(self):
selected_objs = FreeCADGui.Selection.getSelectionEx()
if selected_objs:
if len(selected_objs[0].SubObjects) == 1:
if "Face" in selected_objs[0].SubElementNames[0]:
self.SelectedObj = selected_objs[0].Object
self.FaceName = selected_objs[0].SubElementNames[0]
else:
showWarning("Select any face of the structural element.")
else:
showWarning("Select only one face of the structural element.")
else:
showWarning("Select any face of the structural element.")

def showWarning(message):
""" showWarning(message): This function is used to produce warning
message for the user."""
@@ -119,7 +119,10 @@ def __init__(self, Rebar = None):
self.form.amount_radio.clicked.connect(self.amount_radio_clicked)
self.form.spacing_radio.clicked.connect(self.spacing_radio_clicked)
#self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0]+"/icons/UShapeRebar.svg"))
self.form.PickSelectedFace.clicked.connect(lambda: getSelectedFace(self))
self.Rebar = Rebar
self.SelectedObj = None
self.FaceName = None

def getStandardButtons(self):
return int(QtGui.QDialogButtonBox.Ok) | int(QtGui.QDialogButtonBox.Cancel)
@@ -140,12 +143,12 @@ def accept(self):
if amount_check:
amount = self.form.amount.value()
makeStirrup(s_cover, f_cover, bentAngle, bentFactor, diameter,\
rounding, True, amount)
rounding, True, amount, self.SelectedObj, self.FaceName)
elif spacing_check:
spacing = self.form.spacing.text()
spacing = FreeCAD.Units.Quantity(spacing).Value
makeStirrup(s_cover, f_cover, bentAngle, bentFactor, diameter,\
rounding, False, spacing)
rounding, False, spacing, self.SelectedObj, self.FaceName)
else:
if amount_check:
amount = self.form.amount.value()
@@ -168,15 +171,19 @@ def spacing_radio_clicked(self):


def makeStirrup(s_cover, f_cover, bentAngle, bentFactor, diameter, rounding,\
amount_spacing_check, amount_spacing_value):
amount_spacing_check, amount_spacing_value, structure = None, facename = None):
""" makeStirrup(s_cover, f_cover, bentAngle, diameter, rounding,
amount_spacing_check, amount_spacing_value): Adds the Stirrup reinforcement bar
to the selected structural object."""
selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
StructurePRM = getTrueParametersOfStructure(selected_obj.Object)
FacePRM = getParametersOfFace(selected_obj.Object, selected_obj.SubObjects[0], False)
FaceNormal = selected_obj.SubObjects[0].normalAt(0,0)
FaceNormal = selected_obj.SubObjects[0].Placement.Rotation.inverted().multVec(FaceNormal)
if not structure and not facename:
selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
structure = selected_obj.Object
facename = selected_obj.SubElementNames[0]
face = structure.Shape.Faces[int(facename[-1]) - 1]
StructurePRM = getTrueParametersOfStructure(structure)
FacePRM = getParametersOfFace(structure, face, False)
FaceNormal = face.normalAt(0,0)
FaceNormal = face.Placement.Rotation.inverted().multVec(FaceNormal)
if not FacePRM:
FreeCAD.Console.PrintError("Cannot identified shape or from which base object sturctural element is derived\n")
return
@@ -185,11 +192,11 @@ def makeStirrup(s_cover, f_cover, bentAngle, bentFactor, diameter, rounding,\
import Draft
line = Draft.makeWire(points, closed = False, face = True, support = None)
import Arch
line.Support = [(selected_obj.Object, selected_obj.SubElementNames[0])]
line.Support = [(structure, facename)]
if amount_spacing_check:
rebar = Arch.makeRebar(selected_obj.Object, line, diameter, amount_spacing_value, f_cover)
rebar = Arch.makeRebar(structure, line, diameter, amount_spacing_value, f_cover)
else:
rebar = Arch.makeRebar(selected_obj.Object, line, diameter,\
rebar = Arch.makeRebar(structure, line, diameter,\
int((StructurePRM[1] - diameter) / amount_spacing_value), f_cover)
rebar.Direction = FaceNormal.negative()
rebar.Rounding = rounding
@@ -279,6 +286,7 @@ def editDialog(vobj):
obj.form.amount.setDisabled(True)
obj.form.spacing.setEnabled(True)
obj.form.spacing.setText(str(vobj.Object.TrueSpacing))
obj.form.PickSelectedFace.setVisible(False)
FreeCADGui.Control.showDialog(obj)

def CommandStirrup():
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>197</width>
<height>321</height>
<height>410</height>
</rect>
</property>
<property name="windowTitle">
@@ -23,35 +23,6 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="heading">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Fill all the values</string>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
@@ -216,6 +187,49 @@
</item>
</layout>
</item>
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="heading">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Fill all the values</string>
</property>
</widget>
</item>
<item row="4" column="0" alignment="Qt::AlignHCenter">
<widget class="QPushButton" name="PickSelectedFace">
<property name="text">
<string>Pick Selected Face</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="PickSelectedFaceLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@@ -51,7 +51,7 @@ def __init__(self, Rebar = None):
self.form.spacing_radio.clicked.connect(self.spacing_radio_clicked)
self.form.PickSelectedFace.setCheckable(True)
self.form.PickSelectedFace.toggle()
self.form.PickSelectedFace.clicked.connect(self.getSelectedFace)
self.form.PickSelectedFace.clicked.connect(lambda: getSelectedFace(self))
self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/StraightRebar.svg"))
self.Rebar = Rebar
self.SelectedObj = None
@@ -60,29 +60,6 @@ def __init__(self, Rebar = None):
def getStandardButtons(self):
return int(QtGui.QDialogButtonBox.Ok) | int(QtGui.QDialogButtonBox.Cancel)

def getSelectedFace(self):
if not self.form.PickSelectedFace.isChecked():
for i in self.form.children():
if hasattr(i, "setDisabled"):
i.setDisabled(True)
self.form.PickSelectedFaceLabel.setText("Select face of the Structural element and press 'Done'")
self.form.PickSelectedFace.setText("Done")
self.form.PickSelectedFace.setEnabled(True)
self.form.PickSelectedFaceLabel.setEnabled(True)
FreeCADGui.Selection.clearSelection()
FreeCADGui.Selection.addSelectionGate('SELECT Part::Feature SUBELEMENT Face')
else:
for i in self.form.children():
if hasattr(i, "setDisabled"):
i.setEnabled(True)
self.form.PickSelectedFaceLabel.setText("")
self.form.PickSelectedFace.setText("Pick Selected Face")
selected_objs = FreeCADGui.Selection.getSelectionEx()
if selected_objs:
self.SelectedObj = selected_objs[0].Object
self.FaceName = selected_objs[0].SubElementNames[0]
FreeCADGui.Selection.removeSelectionGate()

def accept(self):
f_cover = self.form.frontCover.text()
f_cover = FreeCAD.Units.Quantity(f_cover).Value
@@ -174,6 +151,9 @@ def editStraightRebar(Rebar, f_cover, b_cover, s_cover, diameter, amount_spacing
if not sketch.Support:
showWarning("You have checked remove external geometry of base sketchs when needed.\nTo unchecked Edit->Preferences->Arch.")
return
#if structure and facename:
# sketch.Support = [(structure, facename)]
# FreeCAD.ActiveDocument.recompute()
# Assigned values
facename = sketch.Support[0][1][0]
structure = sketch.Support[0][0]
@@ -220,7 +200,6 @@ def editDialog(vobj):
obj.form.spacing.setEnabled(True)
obj.form.spacing.setText(str(vobj.Object.TrueSpacing))
obj.form.PickSelectedFace.setVisible(False)
obj.form.PickSelectedFaceLabel.setVisible(False)
FreeCADGui.Control.showDialog(obj)

def CommandStraightRebar():
@@ -36,6 +36,22 @@
</property>
</widget>
</item>
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
@@ -166,7 +182,7 @@
<item row="3" column="1">
<widget class="Gui::InputField" name="diameter">
<property name="text">
<string>8</string>
<string>8 mm</string>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
@@ -175,29 +191,6 @@
</item>
</layout>
</item>
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="PickSelectedFaceLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0" alignment="Qt::AlignHCenter">
<widget class="QPushButton" name="PickSelectedFace">
<property name="enabled">
@@ -211,6 +204,13 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="PickSelectedFaceLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>

0 comments on commit f2dd3c2

Please sign in to comment.
You can’t perform that action at this time.