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

Classes

class  _LShapeRebarTaskPanel
 

Functions

def getpointsOfLShapeRebar (FacePRM, l_cover, r_cover, b_cover, t_cover, orientation)
 
def makeLShapeRebar (f_cover, b_cover, l_cover, r_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation="Bottom Left", structure=None, facename=None)
 
def editLShapeRebar (Rebar, f_cover, b_cover, l_cover, r_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None)
 
def editDialog (vobj)
 
def CommandLShapeRebar ()
 

Variables

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

Function Documentation

def LShapeRebar.CommandLShapeRebar ( )

Definition at line 300 of file LShapeRebar.py.

301  selected_obj = check_selected_face()
302  if selected_obj:
303  FreeCADGui.Control.showDialog(_LShapeRebarTaskPanel())

Here is the call graph for this function:

Here is the caller graph for this function:

def LShapeRebar.editDialog (   vobj)

Definition at line 278 of file LShapeRebar.py.

278 def editDialog(vobj):
279  FreeCADGui.Control.closeDialog()
280  obj = _LShapeRebarTaskPanel(vobj.Object)
281  obj.form.frontCover.setText(str(vobj.Object.FrontCover))
282  obj.form.l_sideCover.setText(str(vobj.Object.LeftCover))
283  obj.form.r_sideCover.setText(str(vobj.Object.RightCover))
284  obj.form.bottomCover.setText(str(vobj.Object.BottomCover))
285  obj.form.diameter.setText(str(vobj.Object.Diameter))
286  obj.form.topCover.setText(str(vobj.Object.TopCover))
287  obj.form.rounding.setValue(vobj.Object.Rounding)
288  obj.form.orientation.setCurrentIndex(obj.form.orientation.findText(str(vobj.Object.Orientation)))
289  if vobj.Object.AmountCheck:
290  obj.form.amount.setValue(vobj.Object.Amount)
291  else:
292  obj.form.amount_radio.setChecked(False)
293  obj.form.spacing_radio.setChecked(True)
294  obj.form.amount.setDisabled(True)
295  obj.form.spacing.setEnabled(True)
296  obj.form.spacing.setText(str(vobj.Object.TrueSpacing))
297  #obj.form.PickSelectedFace.setVisible(False)
298  FreeCADGui.Control.showDialog(obj)
299 
def editDialog(vobj)
Definition: LShapeRebar.py:278
def LShapeRebar.editLShapeRebar (   Rebar,
  f_cover,
  b_cover,
  l_cover,
  r_cover,
  diameter,
  t_cover,
  rounding,
  amount_spacing_check,
  amount_spacing_value,
  orientation,
  structure = None,
  facename = None 
)

Definition at line 230 of file LShapeRebar.py.

230 def editLShapeRebar(Rebar, f_cover, b_cover, l_cover, r_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation, structure = None, facename = None):
231  sketch = Rebar.Base
232  if structure and facename:
233  sketch.Support = [(structure, facename)]
234  # Check if sketch support is empty.
235  if not sketch.Support:
236  showWarning("You have checked remove external geometry of base sketchs when needed.\nTo unchecked Edit->Preferences->Arch.")
237  return
238  # Assigned values
239  facename = sketch.Support[0][1][0]
240  structure = sketch.Support[0][0]
241  face = structure.Shape.Faces[getFaceNumber(facename) - 1]
242  #StructurePRM = getTrueParametersOfStructure(structure)
243  # Get parameters of the face where sketch of rebar is drawn
244  FacePRM = getParametersOfFace(structure, facename)
245  # Get points of L-Shape rebar
246  points = getpointsOfLShapeRebar(FacePRM, l_cover, r_cover, b_cover, t_cover, orientation)
247  sketch.movePoint(0, 1, points[0], 0)
248  FreeCAD.ActiveDocument.recompute()
249  sketch.movePoint(0, 2, points[1], 0)
250  FreeCAD.ActiveDocument.recompute()
251  sketch.movePoint(1, 1, points[1], 0)
252  FreeCAD.ActiveDocument.recompute()
253  sketch.movePoint(1, 2, points[2], 0)
254  FreeCAD.ActiveDocument.recompute()
255  Rebar.OffsetStart = f_cover
256  Rebar.OffsetEnd = f_cover
257  if amount_spacing_check:
258  Rebar.Amount = amount_spacing_value
259  FreeCAD.ActiveDocument.recompute()
260  Rebar.AmountCheck = True
261  else:
262  size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length
263  Rebar.Amount = int((size - diameter) / amount_spacing_value)
264  FreeCAD.ActiveDocument.recompute()
265  Rebar.AmountCheck = False
266  Rebar.Diameter = diameter
267  Rebar.FrontCover = f_cover
268  Rebar.LeftCover = l_cover
269  Rebar.RightCover = r_cover
270  Rebar.BottomCover = b_cover
271  Rebar.TopCover = t_cover
272  Rebar.Rounding = rounding
273  Rebar.TrueSpacing = amount_spacing_value
274  Rebar.Orientation = orientation
275  FreeCAD.ActiveDocument.recompute()
276  return Rebar
277 
def editLShapeRebar(Rebar, f_cover, b_cover, l_cover, r_cover, diameter, t_cover, rounding, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None)
Definition: LShapeRebar.py:230
def getFaceNumber(s)
Definition: Rebarfunc.py:72
def getpointsOfLShapeRebar(FacePRM, l_cover, r_cover, b_cover, t_cover, orientation)
Definition: LShapeRebar.py:40
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 LShapeRebar.getpointsOfLShapeRebar (   FacePRM,
  l_cover,
  r_cover,
  b_cover,
  t_cover,
  orientation 
)
getpointsOfLShapeRebar(FacePRM, LeftCover, RightCover, BottomCover, TopCover, Orientation):
Return points of the LShape rebar in the form of array for sketch.
It takes four different orientations input i.e. 'Bottom Left', 'Bottom Right ', 'Top Left', 'Top Right'.

Definition at line 40 of file LShapeRebar.py.

40 def getpointsOfLShapeRebar(FacePRM, l_cover, r_cover, b_cover, t_cover, orientation):
41  """ getpointsOfLShapeRebar(FacePRM, LeftCover, RightCover, BottomCover, TopCover, 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 Left', 'Bottom Right ', 'Top Left', 'Top Right'.
44  """
45  if orientation == "Bottom Left":
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  elif orientation == "Bottom Right":
53  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
54  y1 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
55  x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
56  y2 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
57  x3 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
58  y3 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
59  elif orientation == "Top Left":
60  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
61  y1 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
62  x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
63  y2 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
64  x3 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
65  y3 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
66  elif orientation == "Top Right":
67  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
68  y1 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover
69  x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - r_cover
70  y2 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
71  x3 = FacePRM[1][0] - FacePRM[0][0] / 2 + l_cover
72  y3 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover
73  return [FreeCAD.Vector(x1, y1, 0), FreeCAD.Vector(x2, y2, 0),\
74  FreeCAD.Vector(x3, y3, 0)]
75 
def getpointsOfLShapeRebar(FacePRM, l_cover, r_cover, b_cover, t_cover, orientation)
Definition: LShapeRebar.py:40

Here is the caller graph for this function:

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

Definition at line 169 of file LShapeRebar.py.

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

Definition at line 25 of file LShapeRebar.py.

string LShapeRebar.__title__ = "LShapeRebar"
private

Definition at line 24 of file LShapeRebar.py.

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

Definition at line 26 of file LShapeRebar.py.