Rebar Addon for FreeCAD
Classes | Functions | Variables
BentShapeRebar Namespace Reference

Classes

class  _BentShapeRebarTaskPanel
 

Functions

def getpointsOfBentShapeRebar (FacePRM, l_cover, r_cover, b_cover, t_cover, bentLength, bentAngle, orientation)
 
def makeBentShapeRebar (f_cover, b_cover, l_cover, r_cover, diameter, t_cover, bentLength, bentAngle, rounding, amount_spacing_check, amount_spacing_value, orientation="Bottom Left", structure=None, facename=None)
 
def editBentShapeRebar (Rebar, f_cover, b_cover, l_cover, r_cover, diameter, t_cover, bentLength, bentAngle, rounding, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None)
 
def editDialog (vobj)
 
def CommandBentShapeRebar ()
 

Variables

string __title__ = "BentShapeRebar"
 
string __author__ = "Amritpal Singh"
 
string __url__ = "https://www.freecadweb.org"
 

Function Documentation

def BentShapeRebar.CommandBentShapeRebar ( )

Definition at line 359 of file BentShapeRebar.py.

360  selected_obj = check_selected_face()
361  if selected_obj:
362  FreeCADGui.Control.showDialog(_BentShapeRebarTaskPanel())

Here is the call graph for this function:

Here is the caller graph for this function:

def BentShapeRebar.editBentShapeRebar (   Rebar,
  f_cover,
  b_cover,
  l_cover,
  r_cover,
  diameter,
  t_cover,
  bentLength,
  bentAngle,
  rounding,
  amount_spacing_check,
  amount_spacing_value,
  orientation,
  structure = None,
  facename = None 
)

Definition at line 270 of file BentShapeRebar.py.

270 def editBentShapeRebar(Rebar, f_cover, b_cover, l_cover, r_cover, diameter, t_cover, bentLength, bentAngle, rounding, amount_spacing_check, amount_spacing_value, orientation, structure = None, facename = None):
271  sketch = Rebar.Base
272  if structure and facename:
273  sketch.Support = [(structure, facename)]
274  # Check if sketch support is empty.
275  if not sketch.Support:
276  showWarning("You have checked remove external geometry of base sketchs when needed.\nTo unchecked Edit->Preferences->Arch.")
277  return
278  # Assigned values
279  facename = sketch.Support[0][1][0]
280  structure = sketch.Support[0][0]
281  face = structure.Shape.Faces[getFaceNumber(facename) - 1]
282  #StructurePRM = getTrueParametersOfStructure(structure)
283  # Get parameters of the face where sketch of rebar is drawn
284  FacePRM = getParametersOfFace(structure, facename)
285  # Get points of L-Shape rebar
286  points = getpointsOfBentShapeRebar(FacePRM, l_cover, r_cover, b_cover, t_cover, bentLength, bentAngle, orientation)
287  sketch.movePoint(0, 1, points[0], 0)
288  FreeCAD.ActiveDocument.recompute()
289  sketch.movePoint(0, 2, points[1], 0)
290  FreeCAD.ActiveDocument.recompute()
291  sketch.movePoint(1, 1, points[1], 0)
292  FreeCAD.ActiveDocument.recompute()
293  sketch.movePoint(1, 2, points[2], 0)
294  FreeCAD.ActiveDocument.recompute()
295 
296  sketch.movePoint(2, 1, points[2], 0)
297  FreeCAD.ActiveDocument.recompute()
298  sketch.movePoint(2, 2, points[3], 0)
299  FreeCAD.ActiveDocument.recompute()
300  sketch.movePoint(3, 1, points[3], 0)
301  FreeCAD.ActiveDocument.recompute()
302  sketch.movePoint(3, 2, points[4], 0)
303  FreeCAD.ActiveDocument.recompute()
304 
305  sketch.movePoint(4, 1, points[4], 0)
306  FreeCAD.ActiveDocument.recompute()
307  sketch.movePoint(4, 2, points[5], 0)
308  FreeCAD.ActiveDocument.recompute()
309 
310  Rebar.OffsetStart = f_cover
311  Rebar.OffsetEnd = f_cover
312  if amount_spacing_check:
313  Rebar.Amount = amount_spacing_value
314  FreeCAD.ActiveDocument.recompute()
315  Rebar.AmountCheck = True
316  else:
317  size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length
318  Rebar.Amount = int((size - diameter) / amount_spacing_value)
319  FreeCAD.ActiveDocument.recompute()
320  Rebar.AmountCheck = False
321  Rebar.Diameter = diameter
322  Rebar.FrontCover = f_cover
323  Rebar.LeftCover = l_cover
324  Rebar.RightCover = r_cover
325  Rebar.BottomCover = b_cover
326  Rebar.TopCover = t_cover
327  Rebar.BentLength = bentLength
328  Rebar.BentAngle = bentAngle
329  Rebar.Rounding = rounding
330  Rebar.TrueSpacing = amount_spacing_value
331  Rebar.Orientation = orientation
332  FreeCAD.ActiveDocument.recompute()
333  return Rebar
334 
def getFaceNumber(s)
Definition: Rebarfunc.py:72
def getpointsOfBentShapeRebar(FacePRM, l_cover, r_cover, b_cover, t_cover, bentLength, bentAngle, orientation)
def editBentShapeRebar(Rebar, f_cover, b_cover, l_cover, r_cover, diameter, t_cover, bentLength, bentAngle, rounding, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None)
def showWarning(message)
Definition: Rebarfunc.py:293
def getParametersOfFace(structure, facename, sketch=True)
Definition: Rebarfunc.py:126

Here is the call graph for this function:

Here is the caller graph for this function:

def BentShapeRebar.editDialog (   vobj)

Definition at line 335 of file BentShapeRebar.py.

335 def editDialog(vobj):
336  FreeCADGui.Control.closeDialog()
337  obj = _BentShapeRebarTaskPanel(vobj.Object)
338  obj.form.frontCover.setText(str(vobj.Object.FrontCover))
339  obj.form.l_sideCover.setText(str(vobj.Object.LeftCover))
340  obj.form.r_sideCover.setText(str(vobj.Object.RightCover))
341  obj.form.bottomCover.setText(str(vobj.Object.BottomCover))
342  obj.form.diameter.setText(str(vobj.Object.Diameter))
343  obj.form.topCover.setText(str(vobj.Object.TopCover))
344  obj.form.bentLength.setText(str(vobj.Object.BentLength))
345  obj.form.bentAngle.setValue(vobj.Object.BentAngle)
346  obj.form.rounding.setValue(vobj.Object.Rounding)
347  obj.form.orientation.setCurrentIndex(obj.form.orientation.findText(str(vobj.Object.Orientation)))
348  if vobj.Object.AmountCheck:
349  obj.form.amount.setValue(vobj.Object.Amount)
350  else:
351  obj.form.amount_radio.setChecked(False)
352  obj.form.spacing_radio.setChecked(True)
353  obj.form.amount.setDisabled(True)
354  obj.form.spacing.setEnabled(True)
355  obj.form.spacing.setText(str(vobj.Object.TrueSpacing))
356  #obj.form.PickSelectedFace.setVisible(False)
357  FreeCADGui.Control.showDialog(obj)
358 
def editDialog(vobj)
def BentShapeRebar.getpointsOfBentShapeRebar (   FacePRM,
  l_cover,
  r_cover,
  b_cover,
  t_cover,
  bentLength,
  bentAngle,
  orientation 
)
getpointsOfBentShapeRebar(FacePRM, LeftCover, RightCover, BottomCover, TopCover, BentLength, BentAngle, Orientation):
Return points of the LShape rebar in the form of array for sketch.
It takes four different orientations input i.e. 'Bottom', 'Top', 'Left', 'Right'.

Definition at line 40 of file BentShapeRebar.py.

40 def getpointsOfBentShapeRebar(FacePRM, l_cover, r_cover, b_cover, t_cover, bentLength, bentAngle, orientation):
41  """ getpointsOfBentShapeRebar(FacePRM, LeftCover, RightCover, BottomCover, TopCover, BentLength, BentAngle, Orientation):
42  Return points of the LShape rebar in the form of array for sketch.
43  It takes four different orientations input i.e. 'Bottom', 'Top', 'Left', 'Right'.
44  """
45  if orientation == "Bottom":
46  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
47  y1 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
48  x2 = x1 + bentLength
49  y2 = y1
50  dis = (FacePRM[0][1] - t_cover - b_cover) * math.tan(math.radians(bentAngle - 90))
51  x3 = x2 + dis
52  y3 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
53  x4 = FacePRM[1][0] + FacePRM[0][0] / 2 - r_cover - bentLength - dis
54  y4 = y3
55  x5 = x4 + dis
56  y5 = y2
57  x6 = x5 + bentLength
58  y6 = y5
59  elif orientation == "Top":
60  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
61  y1 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
62  x2 = x1 + bentLength
63  y2 = y1
64  dis = (FacePRM[0][1] - t_cover - b_cover) * math.tan(math.radians(bentAngle - 90))
65  x3 = x2 + dis
66  y3 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
67  x4 = FacePRM[1][0] + FacePRM[0][0] / 2 - r_cover - bentLength - dis
68  y4 = y3
69  x5 = x4 + dis
70  y5 = y2
71  x6 = x5 + bentLength
72  y6 = y5
73  elif orientation == "Left":
74  x1 = FacePRM[1][0] + FacePRM[0][0] / 2 - r_cover
75  y1 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
76  x2 = x1
77  y2 = y1 - bentLength
78  dis = (FacePRM[0][0] - r_cover - l_cover) * math.tan(math.radians(bentAngle - 90))
79  x3 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
80  y3 = y2 - dis
81  x4 = x3
82  y4 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover + bentLength + dis
83  x5 = x2
84  y5 = y4 - dis
85  x6 = x5
86  y6 = y5 - bentLength
87  elif orientation == "Right":
88  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
89  y1 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
90  x2 = x1
91  y2 = y1 - bentLength
92  dis = (FacePRM[0][0] - r_cover - l_cover) * math.tan(math.radians(bentAngle - 90))
93  x3 = FacePRM[1][0] + FacePRM[0][0] / 2 - r_cover
94  y3 = y2 - dis
95  x4 = x3
96  y4 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover + bentLength + dis
97  x5 = x2
98  y5 = y4 - dis
99  x6 = x5
100  y6 = y5 - bentLength
101  return [FreeCAD.Vector(x1, y1, 0), FreeCAD.Vector(x2, y2, 0),\
102  FreeCAD.Vector(x3, y3, 0), FreeCAD.Vector(x4, y4, 0),\
103  FreeCAD.Vector(x5, y5, 0), FreeCAD.Vector(x6, y6, 0)]
104 
def getpointsOfBentShapeRebar(FacePRM, l_cover, r_cover, b_cover, t_cover, bentLength, bentAngle, orientation)

Here is the caller graph for this function:

def BentShapeRebar.makeBentShapeRebar (   f_cover,
  b_cover,
  l_cover,
  r_cover,
  diameter,
  t_cover,
  bentLength,
  bentAngle,
  rounding,
  amount_spacing_check,
  amount_spacing_value,
  orientation = "Bottom Left",
  structure = None,
  facename = None 
)
makeBentShapeRebar(FrontCover, BottomCover, LeftCover, RightCover, Diameter, TopCover, BentLength, BentAngle, Rounding,
AmountSpacingCheck, AmountSpacingValue, Orientation, Structure, Facename): Adds the Bent-Shape reinforcement bar to the
selected structural object.
It takes four different orientations input i.e. 'Bottom', 'Top', 'Left', 'Right'.

Definition at line 200 of file BentShapeRebar.py.

200 def makeBentShapeRebar(f_cover, b_cover, l_cover, r_cover, diameter, t_cover, bentLength, bentAngle, rounding, amount_spacing_check, amount_spacing_value, orientation = "Bottom Left", structure = None, facename = None):
201  """ makeBentShapeRebar(FrontCover, BottomCover, LeftCover, RightCover, Diameter, TopCover, BentLength, BentAngle, Rounding,
202  AmountSpacingCheck, AmountSpacingValue, Orientation, Structure, Facename): Adds the Bent-Shape reinforcement bar to the
203  selected structural object.
204  It takes four different orientations input i.e. 'Bottom', 'Top', 'Left', 'Right'.
205  """
206  if not structure and not facename:
207  selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
208  structure = selected_obj.Object
209  facename = selected_obj.SubElementNames[0]
210  face = structure.Shape.Faces[getFaceNumber(facename) - 1]
211  #StructurePRM = getTrueParametersOfStructure(structure)
212  FacePRM = getParametersOfFace(structure, facename)
213  if not FacePRM:
214  FreeCAD.Console.PrintError("Cannot identified shape or from which base object sturctural element is derived\n")
215  return
216  # Get points of L-Shape rebar
217  points = getpointsOfBentShapeRebar(FacePRM, l_cover, r_cover, b_cover, t_cover, bentLength, bentAngle, orientation)
218  import Part
219  import Arch
220  sketch = FreeCAD.activeDocument().addObject('Sketcher::SketchObject', 'Sketch')
221  sketch.MapMode = "FlatFace"
222  sketch.Support = [(structure, facename)]
223  FreeCAD.ActiveDocument.recompute()
224  sketch.addGeometry(Part.LineSegment(points[0], points[1]), False)
225  sketch.addGeometry(Part.LineSegment(points[1], points[2]), False)
226  sketch.addGeometry(Part.LineSegment(points[2], points[3]), False)
227  sketch.addGeometry(Part.LineSegment(points[3], points[4]), False)
228  sketch.addGeometry(Part.LineSegment(points[4], points[5]), False)
229  import Sketcher
230  if amount_spacing_check:
231  rebar = Arch.makeRebar(structure, sketch, diameter, amount_spacing_value, f_cover)
232  FreeCAD.ActiveDocument.recompute()
233  else:
234  size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length
235  rebar = Arch.makeRebar(structure, sketch, diameter, int((size - diameter) / amount_spacing_value), f_cover)
236  rebar.Rounding = rounding
237  # Adds properties to the rebar object
238  rebar.ViewObject.addProperty("App::PropertyString", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar")).RebarShape = "BentShapeRebar"
239  rebar.ViewObject.setEditorMode("RebarShape", 2)
240  rebar.addProperty("App::PropertyDistance", "FrontCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar")).FrontCover = f_cover
241  rebar.setEditorMode("FrontCover", 2)
242  rebar.addProperty("App::PropertyDistance", "LeftCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Left Side cover of rebar")).LeftCover = l_cover
243  rebar.setEditorMode("LeftCover", 2)
244  rebar.addProperty("App::PropertyDistance", "RightCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Right Side cover of rebar")).RightCover = r_cover
245  rebar.setEditorMode("RightCover", 2)
246  rebar.addProperty("App::PropertyDistance", "BottomCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bottom cover of rebar")).BottomCover = b_cover
247  rebar.setEditorMode("BottomCover", 2)
248  rebar.addProperty("App::PropertyBool", "AmountCheck", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked")).AmountCheck
249  rebar.setEditorMode("AmountCheck", 2)
250  rebar.addProperty("App::PropertyDistance", "TopCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar")).TopCover = t_cover
251  rebar.setEditorMode("TopCover", 2)
252  rebar.addProperty("App::PropertyDistance", "TrueSpacing", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars")).TrueSpacing = amount_spacing_value
253  rebar.addProperty("App::PropertyString", "Orientation", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar")).Orientation = orientation
254  rebar.setEditorMode("Orientation", 2)
255  rebar.setEditorMode("TrueSpacing", 2)
256  rebar.addProperty("App::PropertyDistance", "BentLength", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "BentLength cover of rebar")).BentLength = bentLength
257  rebar.setEditorMode("BentLength", 2)
258  rebar.addProperty("App::PropertyDistance", "BentAngle", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bent Angle of rebar")).BentAngle = bentAngle
259  rebar.setEditorMode("BentAngle", 2)
260 
261  if amount_spacing_check:
262  rebar.AmountCheck = True
263  else:
264  rebar.AmountCheck = False
265  rebar.TrueSpacing = amount_spacing_value
266  rebar.Label = "BentShapeRebar"
267  FreeCAD.ActiveDocument.recompute()
268  return rebar
269 
def getFaceNumber(s)
Definition: Rebarfunc.py:72
def getpointsOfBentShapeRebar(FacePRM, l_cover, r_cover, b_cover, t_cover, bentLength, bentAngle, orientation)
def makeBentShapeRebar(f_cover, b_cover, l_cover, r_cover, diameter, t_cover, bentLength, bentAngle, rounding, amount_spacing_check, amount_spacing_value, orientation="Bottom Left", structure=None, facename=None)
def getParametersOfFace(structure, facename, sketch=True)
Definition: Rebarfunc.py:126

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

string BentShapeRebar.__author__ = "Amritpal Singh"
private

Definition at line 25 of file BentShapeRebar.py.

string BentShapeRebar.__title__ = "BentShapeRebar"
private

Definition at line 24 of file BentShapeRebar.py.

string BentShapeRebar.__url__ = "https://www.freecadweb.org"
private

Definition at line 26 of file BentShapeRebar.py.