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

Classes

class  _UShapeRebarTaskPanel
 

Functions

def getpointsOfUShapeRebar (FacePRM, r_cover, l_cover, b_cover, t_cover, orientation)
 
def makeUShapeRebar (f_cover, b_cover, r_cover, l_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation="Bottom", structure=None, facename=None)
 
def editUShapeRebar (Rebar, f_cover, b_cover, r_cover, l_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None)
 
def editDialog (vobj)
 
def CommandUShapeRebar ()
 

Variables

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

Function Documentation

def UShapeRebar.CommandUShapeRebar ( )

Definition at line 313 of file UShapeRebar.py.

314  selected_obj = check_selected_face()
315  if selected_obj:
316  FreeCADGui.Control.showDialog(_UShapeRebarTaskPanel())

Here is the call graph for this function:

Here is the caller graph for this function:

def UShapeRebar.editDialog (   vobj)

Definition at line 291 of file UShapeRebar.py.

291 def editDialog(vobj):
292  FreeCADGui.Control.closeDialog()
293  obj = _UShapeRebarTaskPanel(vobj.Object)
294  obj.form.frontCover.setText(str(vobj.Object.FrontCover))
295  obj.form.r_sideCover.setText(str(vobj.Object.RightCover))
296  obj.form.l_sideCover.setText(str(vobj.Object.LeftCover))
297  obj.form.bottomCover.setText(str(vobj.Object.BottomCover))
298  obj.form.diameter.setText(str(vobj.Object.Diameter))
299  obj.form.topCover.setText(str(vobj.Object.TopCover))
300  obj.form.rounding.setValue(vobj.Object.Rounding)
301  obj.form.orientation.setCurrentIndex(obj.form.orientation.findText(str(vobj.Object.Orientation)))
302  if vobj.Object.AmountCheck:
303  obj.form.amount.setValue(vobj.Object.Amount)
304  else:
305  obj.form.amount_radio.setChecked(False)
306  obj.form.spacing_radio.setChecked(True)
307  obj.form.amount.setDisabled(True)
308  obj.form.spacing.setEnabled(True)
309  obj.form.spacing.setText(str(vobj.Object.TrueSpacing))
310  #obj.form.PickSelectedFace.setVisible(False)
311  FreeCADGui.Control.showDialog(obj)
312 
def editDialog(vobj)
Definition: UShapeRebar.py:291
def UShapeRebar.editUShapeRebar (   Rebar,
  f_cover,
  b_cover,
  r_cover,
  l_cover,
  diameter,
  t_cover,
  rounding,
  amount_spacing_check,
  amount_spacing_value,
  orientation,
  structure = None,
  facename = None 
)

Definition at line 239 of file UShapeRebar.py.

239 def editUShapeRebar(Rebar, f_cover, b_cover, r_cover, l_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation, structure = None, facename = None):
240  sketch = Rebar.Base
241  if structure and facename:
242  sketch.Support = [(structure, facename)]
243  # Check if sketch support is empty.
244  if not sketch.Support:
245  showWarning("You have checked remove external geometry of base sketchs when needed.\nTo unchecked Edit->Preferences->Arch.")
246  return
247  # Assigned values
248  facename = sketch.Support[0][1][0]
249  structure = sketch.Support[0][0]
250  face = structure.Shape.Faces[getFaceNumber(facename) - 1]
251  #StructurePRM = getTrueParametersOfStructure(structure)
252  # Get parameters of the face where sketch of rebar is drawn
253  FacePRM = getParametersOfFace(structure, facename)
254  # Get points of U-Shape rebar
255  points = getpointsOfUShapeRebar(FacePRM, r_cover, l_cover, b_cover, t_cover, orientation)
256  sketch.movePoint(0, 1, points[0], 0)
257  FreeCAD.ActiveDocument.recompute()
258  sketch.movePoint(0, 2, points[1], 0)
259  FreeCAD.ActiveDocument.recompute()
260  sketch.movePoint(1, 1, points[1], 0)
261  FreeCAD.ActiveDocument.recompute()
262  sketch.movePoint(1, 2, points[2], 0)
263  FreeCAD.ActiveDocument.recompute()
264  sketch.movePoint(2, 1, points[2], 0)
265  FreeCAD.ActiveDocument.recompute()
266  sketch.movePoint(2, 2, points[3], 0)
267  FreeCAD.ActiveDocument.recompute()
268  Rebar.OffsetStart = f_cover
269  Rebar.OffsetEnd = f_cover
270  if amount_spacing_check:
271  Rebar.Amount = amount_spacing_value
272  FreeCAD.ActiveDocument.recompute()
273  Rebar.AmountCheck = True
274  else:
275  size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length
276  Rebar.Amount = int((size - diameter) / amount_spacing_value)
277  FreeCAD.ActiveDocument.recompute()
278  Rebar.AmountCheck = False
279  Rebar.Diameter = diameter
280  Rebar.FrontCover = f_cover
281  Rebar.RightCover = r_cover
282  Rebar.LeftCover = l_cover
283  Rebar.BottomCover = b_cover
284  Rebar.TopCover = t_cover
285  Rebar.Rounding = rounding
286  Rebar.TrueSpacing = amount_spacing_value
287  Rebar.Orientation = orientation
288  FreeCAD.ActiveDocument.recompute()
289  return Rebar
290 
def getFaceNumber(s)
Definition: Rebarfunc.py:72
def getpointsOfUShapeRebar(FacePRM, r_cover, l_cover, b_cover, t_cover, orientation)
Definition: UShapeRebar.py:40
def showWarning(message)
Definition: Rebarfunc.py:293
def editUShapeRebar(Rebar, f_cover, b_cover, r_cover, l_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None)
Definition: UShapeRebar.py:239
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 UShapeRebar.getpointsOfUShapeRebar (   FacePRM,
  r_cover,
  l_cover,
  b_cover,
  t_cover,
  orientation 
)
getpointsOfUShapeRebar(FacePRM, RightCover, LeftCover, BottomCover, TopCover, Orientation):
Return points of the UShape 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 UShapeRebar.py.

40 def getpointsOfUShapeRebar(FacePRM, r_cover, l_cover, b_cover, t_cover, orientation):
41  """ getpointsOfUShapeRebar(FacePRM, RightCover, LeftCover, BottomCover, TopCover, Orientation):
42  Return points of the UShape 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 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
49  y2 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
50  x3 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
51  y3 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
52  x4 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
53  y4 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
54  elif orientation == "Top":
55  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
56  y1 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
57  x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
58  y2 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
59  x3 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
60  y3 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
61  x4 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
62  y4 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
63  elif orientation == "Left":
64  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
65  y1 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
66  x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
67  y2 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
68  x3 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
69  y3 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
70  x4 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
71  y4 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
72  elif orientation == "Right":
73  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
74  y1 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
75  x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
76  y2 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
77  x3 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
78  y3 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
79  x4 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
80  y4 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
81  return [FreeCAD.Vector(x1, y1, 0), FreeCAD.Vector(x2, y2, 0),\
82  FreeCAD.Vector(x3, y3, 0), FreeCAD.Vector(x4, y4, 0)]
83 
def getpointsOfUShapeRebar(FacePRM, r_cover, l_cover, b_cover, t_cover, orientation)
Definition: UShapeRebar.py:40

Here is the caller graph for this function:

def UShapeRebar.makeUShapeRebar (   f_cover,
  b_cover,
  r_cover,
  l_cover,
  diameter,
  t_cover,
  rounding,
  amount_spacing_check,
  amount_spacing_value,
  orientation = "Bottom",
  structure = None,
  facename = None 
)
makeUShapeRebar(FrontCover, BottomCover, RightCover, LeftCover, Diameter, Topcover, Rounding, AmountSpacingCheck, AmountSpacingValue,
Orientation, Structure, Facename): Adds the U-Shape reinforcement bar to the selected structural object.
It takes four different types of orientations as input i.e 'Bottom', 'Top', 'Right', 'Left'.

Definition at line 177 of file UShapeRebar.py.

177 def makeUShapeRebar(f_cover, b_cover, r_cover, l_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation = "Bottom", structure = None, facename = None):
178  """ makeUShapeRebar(FrontCover, BottomCover, RightCover, LeftCover, Diameter, Topcover, Rounding, AmountSpacingCheck, AmountSpacingValue,
179  Orientation, Structure, Facename): Adds the U-Shape reinforcement bar to the selected structural object.
180  It takes four different types of orientations as input i.e 'Bottom', 'Top', 'Right', 'Left'.
181  """
182  if not structure and not facename:
183  selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
184  structure = selected_obj.Object
185  facename = selected_obj.SubElementNames[0]
186  face = structure.Shape.Faces[getFaceNumber(facename) - 1]
187  #StructurePRM = getTrueParametersOfStructure(structure)
188  FacePRM = getParametersOfFace(structure, facename)
189  if not FacePRM:
190  FreeCAD.Console.PrintError("Cannot identified shape or from which base object sturctural element is derived\n")
191  return
192  # Get points of U-Shape rebar
193  points = getpointsOfUShapeRebar(FacePRM, r_cover, l_cover, b_cover, t_cover, orientation)
194  import Part
195  import Arch
196  sketch = FreeCAD.activeDocument().addObject('Sketcher::SketchObject', 'Sketch')
197  sketch.MapMode = "FlatFace"
198  sketch.Support = [(structure, facename)]
199  FreeCAD.ActiveDocument.recompute()
200  sketch.addGeometry(Part.LineSegment(points[0], points[1]), False)
201  sketch.addGeometry(Part.LineSegment(points[1], points[2]), False)
202  import Sketcher
203  sketch.addGeometry(Part.LineSegment(points[2], points[3]), False)
204  if amount_spacing_check:
205  rebar = Arch.makeRebar(structure, sketch, diameter, amount_spacing_value, f_cover)
206  FreeCAD.ActiveDocument.recompute()
207  else:
208  size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length
209  rebar = Arch.makeRebar(structure, sketch, diameter, int((size - diameter) / amount_spacing_value), f_cover)
210  rebar.Rounding = rounding
211  # Adds properties to the rebar object
212  rebar.ViewObject.addProperty("App::PropertyString", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar")).RebarShape = "UShapeRebar"
213  rebar.ViewObject.setEditorMode("RebarShape", 2)
214  rebar.addProperty("App::PropertyDistance", "FrontCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar")).FrontCover = f_cover
215  rebar.setEditorMode("FrontCover", 2)
216  rebar.addProperty("App::PropertyDistance", "RightCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Right Side cover of rebar")).RightCover = r_cover
217  rebar.setEditorMode("RightCover", 2)
218  rebar.addProperty("App::PropertyDistance", "LeftCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Left Side cover of rebar")).LeftCover = l_cover
219  rebar.setEditorMode("LeftCover", 2)
220  rebar.addProperty("App::PropertyDistance", "BottomCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bottom cover of rebar")).BottomCover = b_cover
221  rebar.setEditorMode("BottomCover", 2)
222  rebar.addProperty("App::PropertyBool", "AmountCheck", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked")).AmountCheck
223  rebar.setEditorMode("AmountCheck", 2)
224  rebar.addProperty("App::PropertyDistance", "TopCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar")).TopCover = t_cover
225  rebar.setEditorMode("TopCover", 2)
226  rebar.addProperty("App::PropertyDistance", "TrueSpacing", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars")).TrueSpacing = amount_spacing_value
227  rebar.setEditorMode("TrueSpacing", 2)
228  rebar.addProperty("App::PropertyString", "Orientation", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar")).Orientation = orientation
229  rebar.setEditorMode("Orientation", 2)
230  if amount_spacing_check:
231  rebar.AmountCheck = True
232  else:
233  rebar.AmountCheck = False
234  rebar.TrueSpacing = amount_spacing_value
235  rebar.Label = "UShapeRebar"
236  FreeCAD.ActiveDocument.recompute()
237  return rebar
238 
def makeUShapeRebar(f_cover, b_cover, r_cover, l_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation="Bottom", structure=None, facename=None)
Definition: UShapeRebar.py:177
def getFaceNumber(s)
Definition: Rebarfunc.py:72
def getpointsOfUShapeRebar(FacePRM, r_cover, l_cover, b_cover, t_cover, orientation)
Definition: UShapeRebar.py:40
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 UShapeRebar.__author__ = "Amritpal Singh"
private

Definition at line 25 of file UShapeRebar.py.

string UShapeRebar.__title__ = "UShapeRebar"
private

Definition at line 24 of file UShapeRebar.py.

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

Definition at line 26 of file UShapeRebar.py.