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

Classes

class  _StraightRebarTaskPanel
 

Functions

def getpointsOfStraightRebar (FacePRM, rt_cover, lb_cover, coverAlong, orientation)
 
def makeStraightRebar (f_cover, coverAlong, rt_cover, lb_cover, diameter, amount_spacing_check, amount_spacing_value, orientation="Horizontal", structure=None, facename=None)
 
def editStraightRebar (Rebar, f_cover, coverAlong, rt_cover, lb_cover, diameter, amount_spacing_check, amount_spacing_value, orientation, structure=None, facename=None)
 
def editDialog (vobj)
 
def CommandStraightRebar ()
 

Variables

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

Function Documentation

def StraightRebar.CommandStraightRebar ( )

Definition at line 320 of file StraightRebar.py.

321  selected_obj = check_selected_face()
322  if selected_obj:
323  FreeCADGui.Control.showDialog(_StraightRebarTaskPanel())

Here is the call graph for this function:

Here is the caller graph for this function:

def StraightRebar.editDialog (   vobj)

Definition at line 299 of file StraightRebar.py.

299 def editDialog(vobj):
300  FreeCADGui.Control.closeDialog()
301  obj = _StraightRebarTaskPanel(vobj.Object)
302  obj.form.frontCover.setText(str(vobj.Object.FrontCover))
303  obj.form.r_sideCover.setText(str(vobj.Object.RightTopCover))
304  obj.form.l_sideCover.setText(str(vobj.Object.LeftBottomCover))
305  obj.form.bottomCover.setText(str(vobj.Object.Cover))
306  obj.form.diameter.setText(str(vobj.Object.Diameter))
307  obj.form.orientation.setCurrentIndex(obj.form.orientation.findText(str(vobj.Object.Orientation)))
308  obj.form.coverAlong.setCurrentIndex(obj.form.coverAlong.findText(str(vobj.Object.CoverAlong)))
309  if vobj.Object.AmountCheck:
310  obj.form.amount.setValue(vobj.Object.Amount)
311  else:
312  obj.form.amount_radio.setChecked(False)
313  obj.form.spacing_radio.setChecked(True)
314  obj.form.amount.setDisabled(True)
315  obj.form.spacing.setEnabled(True)
316  obj.form.spacing.setText(str(vobj.Object.TrueSpacing))
317  #obj.form.PickSelectedFace.setVisible(False)
318  FreeCADGui.Control.showDialog(obj)
319 
def editDialog(vobj)
def StraightRebar.editStraightRebar (   Rebar,
  f_cover,
  coverAlong,
  rt_cover,
  lb_cover,
  diameter,
  amount_spacing_check,
  amount_spacing_value,
  orientation,
  structure = None,
  facename = None 
)

Definition at line 255 of file StraightRebar.py.

255 def editStraightRebar(Rebar, f_cover, coverAlong, rt_cover, lb_cover, diameter, amount_spacing_check, amount_spacing_value, orientation, structure = None, facename = None):
256  sketch = Rebar.Base
257  if structure and facename:
258  sketch.Support = [(structure, facename)]
259  FreeCAD.ActiveDocument.recompute()
260  # Check if sketch support is empty.
261  if not sketch.Support:
262  showWarning("You have checked remove external geometry of base sketchs when needed.\nTo unchecked Edit->Preferences->Arch.")
263  return
264  # Assigned values
265  facename = sketch.Support[0][1][0]
266  structure = sketch.Support[0][0]
267  face = structure.Shape.Faces[getFaceNumber(facename) - 1]
268  #StructurePRM = getTrueParametersOfStructure(structure)
269  # Get parameters of the face where sketch of rebar is drawn
270  FacePRM = getParametersOfFace(structure, facename)
271  # Get points of Striaght rebar
272  points = getpointsOfStraightRebar(FacePRM, rt_cover, lb_cover, coverAlong, orientation)
273  sketch.movePoint(0, 1, points[0], 0)
274  FreeCAD.ActiveDocument.recompute()
275  sketch.movePoint(0, 2, points[1], 0)
276  FreeCAD.ActiveDocument.recompute()
277  Rebar.OffsetStart = f_cover
278  Rebar.OffsetEnd = f_cover
279  if amount_spacing_check:
280  Rebar.Amount = amount_spacing_value
281  FreeCAD.ActiveDocument.recompute()
282  Rebar.AmountCheck = True
283  else:
284  size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length
285  Rebar.Amount = int((size - diameter) / amount_spacing_value)
286  FreeCAD.ActiveDocument.recompute()
287  Rebar.AmountCheck = False
288  Rebar.FrontCover = f_cover
289  Rebar.RightTopCover = rt_cover
290  Rebar.LeftBottomCover = lb_cover
291  Rebar.CoverAlong = coverAlong[0]
292  Rebar.Cover = coverAlong[1]
293  Rebar.TrueSpacing = amount_spacing_value
294  Rebar.Diameter = diameter
295  Rebar.Orientation = orientation
296  FreeCAD.ActiveDocument.recompute()
297  return Rebar
298 
def getpointsOfStraightRebar(FacePRM, rt_cover, lb_cover, coverAlong, orientation)
def getFaceNumber(s)
Definition: Rebarfunc.py:72
def showWarning(message)
Definition: Rebarfunc.py:293
def editStraightRebar(Rebar, f_cover, coverAlong, rt_cover, lb_cover, diameter, amount_spacing_check, amount_spacing_value, orientation, 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:

def StraightRebar.getpointsOfStraightRebar (   FacePRM,
  rt_cover,
  lb_cover,
  coverAlong,
  orientation 
)
getpointsOfStraightRebar(FacePRM, RightTopcover, LeftBottomcover, CoverAlong, Orientation):
Return points of the Straight rebar in the form of array for sketch.

Case I: When Orientation is 'Horizontal':
    We have two option in CoverAlong i.e. 'Bottom Side' or 'Top Side'
Case II: When Orientation is 'Vertical':
    We have two option in CoverAlong i.e. 'Left Side' or 'Right Side'

Definition at line 40 of file StraightRebar.py.

40 def getpointsOfStraightRebar(FacePRM, rt_cover, lb_cover, coverAlong, orientation):
41  """ getpointsOfStraightRebar(FacePRM, RightTopcover, LeftBottomcover, CoverAlong, Orientation):
42  Return points of the Straight rebar in the form of array for sketch.
43 
44  Case I: When Orientation is 'Horizontal':
45  We have two option in CoverAlong i.e. 'Bottom Side' or 'Top Side'
46  Case II: When Orientation is 'Vertical':
47  We have two option in CoverAlong i.e. 'Left Side' or 'Right Side'
48  """
49  if orientation == "Horizontal":
50  if coverAlong[0] == "Bottom Side":
51  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + lb_cover
52  y1 = FacePRM[1][1] - FacePRM[0][1] / 2 + coverAlong[1]
53  x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - rt_cover
54  y2 = FacePRM[1][1] - FacePRM[0][1] / 2 + coverAlong[1]
55  elif coverAlong[0] == "Top Side":
56  cover = FacePRM[0][1] - coverAlong[1]
57  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + lb_cover
58  y1 = FacePRM[1][1] - FacePRM[0][1] / 2 + cover
59  x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - rt_cover
60  y2 = FacePRM[1][1] - FacePRM[0][1] / 2 + cover
61  elif orientation == "Vertical":
62  if coverAlong[0] == "Left Side":
63  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + coverAlong[1]
64  y1 = FacePRM[1][1] - FacePRM[0][1] / 2 + lb_cover
65  x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + coverAlong[1]
66  y2 = FacePRM[1][1] - FacePRM[0][1] / 2 + FacePRM[0][1] - rt_cover
67  elif coverAlong[0] == "Right Side":
68  cover = FacePRM[0][0] - coverAlong[1]
69  x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + cover
70  y1 = FacePRM[1][1] - FacePRM[0][1] / 2 + lb_cover
71  x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + cover
72  y2 = FacePRM[1][1] - FacePRM[0][1] / 2 + FacePRM[0][1] - rt_cover
73  return [FreeCAD.Vector(x1, y1, 0), FreeCAD.Vector(x2, y2, 0)]
74 
def getpointsOfStraightRebar(FacePRM, rt_cover, lb_cover, coverAlong, orientation)

Here is the caller graph for this function:

def StraightRebar.makeStraightRebar (   f_cover,
  coverAlong,
  rt_cover,
  lb_cover,
  diameter,
  amount_spacing_check,
  amount_spacing_value,
  orientation = "Horizontal",
  structure = None,
  facename = None 
)
Adds the straight reinforcement bar to the selected structural object.

Case I: When orientation of straight rebar is 'Horizontal':
    makeStraightRebar(FrontCover, CoverAlong, RightCover, LeftCover, Diameter, AmountSpacingCheck, AmountSpacingValue, Orientation = "Horizontal",
    Structure, Facename)
    Note: Type of CoverAlong argument is a tuple. Syntax: (<Along>, <Value>). Here we have horizontal orientation so we can pass Top Side
    and Bottom Side to <Along> arguments.
    For eg. ("Top Side", 20) and ("Bottom Side", 20)

Case II: When orientation of straight rebar is 'Vertical':
    makeStraightRebar(FrontCover, CoverAlong, TopCover, BottomCover, Diameter, AmountSpacingCheck, AmountSpacingValue, Orientation = "Horizontal",
    Structure, Facename)
    Note: Type of CoverAlong argument is a tuple. Syntax: (<Along>, <Value>). Here we have vertical orientation so we can pass Left Side
    and Right Side to <Along> arguments.
    For eg. ("Left Side", 20) and ("Right Side", 20)

Definition at line 185 of file StraightRebar.py.

185 def makeStraightRebar(f_cover, coverAlong, rt_cover, lb_cover, diameter, amount_spacing_check, amount_spacing_value, orientation = "Horizontal", structure = None, facename = None):
186  """ Adds the straight reinforcement bar to the selected structural object.
187 
188  Case I: When orientation of straight rebar is 'Horizontal':
189  makeStraightRebar(FrontCover, CoverAlong, RightCover, LeftCover, Diameter, AmountSpacingCheck, AmountSpacingValue, Orientation = "Horizontal",
190  Structure, Facename)
191  Note: Type of CoverAlong argument is a tuple. Syntax: (<Along>, <Value>). Here we have horizontal orientation so we can pass Top Side
192  and Bottom Side to <Along> arguments.
193  For eg. ("Top Side", 20) and ("Bottom Side", 20)
194 
195  Case II: When orientation of straight rebar is 'Vertical':
196  makeStraightRebar(FrontCover, CoverAlong, TopCover, BottomCover, Diameter, AmountSpacingCheck, AmountSpacingValue, Orientation = "Horizontal",
197  Structure, Facename)
198  Note: Type of CoverAlong argument is a tuple. Syntax: (<Along>, <Value>). Here we have vertical orientation so we can pass Left Side
199  and Right Side to <Along> arguments.
200  For eg. ("Left Side", 20) and ("Right Side", 20)
201  """
202  if not structure and not facename:
203  selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
204  structure = selected_obj.Object
205  facename = selected_obj.SubElementNames[0]
206  face = structure.Shape.Faces[getFaceNumber(facename) - 1]
207  #StructurePRM = getTrueParametersOfStructure(structure)
208  FacePRM = getParametersOfFace(structure, facename)
209  if not FacePRM:
210  FreeCAD.Console.PrintError("Cannot identified shape or from which base object sturctural element is derived\n")
211  return
212  # Get points of Striaght rebar
213  points = getpointsOfStraightRebar(FacePRM, rt_cover, lb_cover, coverAlong, orientation)
214  import Part
215  import Arch
216  sketch = FreeCAD.activeDocument().addObject('Sketcher::SketchObject', 'Sketch')
217  sketch.MapMode = "FlatFace"
218  sketch.Support = [(structure, facename)]
219  FreeCAD.ActiveDocument.recompute()
220  sketch.addGeometry(Part.LineSegment(points[0], points[1]), False)
221  if amount_spacing_check:
222  rebar = Arch.makeRebar(structure, sketch, diameter, amount_spacing_value, f_cover)
223  FreeCAD.ActiveDocument.recompute()
224  else:
225  size = (ArchCommands.projectToVector(structure.Shape.copy(), face.normalAt(0, 0))).Length
226  rebar = Arch.makeRebar(structure, sketch, diameter, int((size - diameter) / amount_spacing_value), f_cover)
227  # Adds properties to the rebar object
228  rebar.ViewObject.addProperty("App::PropertyString", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar")).RebarShape = "StraightRebar"
229  rebar.ViewObject.setEditorMode("RebarShape", 2)
230  rebar.addProperty("App::PropertyDistance", "FrontCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar")).FrontCover = f_cover
231  rebar.setEditorMode("FrontCover", 2)
232  rebar.addProperty("App::PropertyDistance", "RightTopCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Right/Top Side cover of rebar")).RightTopCover = rt_cover
233  rebar.setEditorMode("RightTopCover", 2)
234  rebar.addProperty("App::PropertyDistance", "LeftBottomCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Left/Bottom Side cover of rebar")).LeftBottomCover = lb_cover
235  rebar.setEditorMode("LeftBottomCover", 2)
236  rebar.addProperty("App::PropertyString", "CoverAlong", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Cover along")).CoverAlong = coverAlong[0]
237  rebar.setEditorMode("CoverAlong", 2)
238  rebar.addProperty("App::PropertyDistance", "Cover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Cover of rebar along user selected side")).Cover = coverAlong[1]
239  rebar.setEditorMode("Cover", 2)
240  rebar.addProperty("App::PropertyBool", "AmountCheck", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked")).AmountCheck
241  rebar.setEditorMode("AmountCheck", 2)
242  rebar.addProperty("App::PropertyDistance", "TrueSpacing", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars")).TrueSpacing = amount_spacing_value
243  rebar.setEditorMode("TrueSpacing", 2)
244  rebar.addProperty("App::PropertyString", "Orientation", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar")).Orientation = orientation
245  rebar.setEditorMode("Orientation", 2)
246  if amount_spacing_check:
247  rebar.AmountCheck = True
248  else:
249  rebar.AmountCheck = False
250  rebar.TrueSpacing = amount_spacing_value
251  rebar.Label = "StraightRebar"
252  FreeCAD.ActiveDocument.recompute()
253  return rebar
254 
def getpointsOfStraightRebar(FacePRM, rt_cover, lb_cover, coverAlong, orientation)
def getFaceNumber(s)
Definition: Rebarfunc.py:72
def getParametersOfFace(structure, facename, sketch=True)
Definition: Rebarfunc.py:126
def makeStraightRebar(f_cover, coverAlong, rt_cover, lb_cover, diameter, amount_spacing_check, amount_spacing_value, orientation="Horizontal", structure=None, facename=None)

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

string StraightRebar.__author__ = "Amritpal Singh"
private

Definition at line 25 of file StraightRebar.py.

string StraightRebar.__title__ = "StraightRebar"
private

Definition at line 24 of file StraightRebar.py.

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

Definition at line 26 of file StraightRebar.py.