Stirrup used rebar-addon's function to get DWire.
Code: Select all
"""
TestSimpleBeam2.py
13 Jul 2017
"""
import Arch
from FreeCAD import Vector
from Stirrup import getTrueParametersOfStructure, getParametersOfFace ,getpointsOfStirrup
def makeSimpleBeam2():
L = 4000.0
b = 200
h = 400
col_width = 200
Ln = L-2*(col_width/2.)
concrete = Arch.makeStructure(length=Ln,width=b,height=h)
concrete.Placement.Base = Vector(L-col_width/2., 0 , -h/2.)
concrete.ViewObject.Transparency = 80
FreeCAD.ActiveDocument.recompute()
covering = 20
dia = 19 # Main
diameter = 9 # Stirrup
dx = covering+dia/2
y = -b/2
points=[Vector(-100-dx,y,-dx-2*dia-6*dia),
Vector(-100-dx,y,-dx-diameter/2.),
Vector(+100 + Ln +200-dx,y,-dx-diameter/2),
Vector(+100 + Ln +200-dx,y,-dx-2*dia-6*dia),]
line = Draft.makeWire(points,closed=False,face=False,support=None)
line.ViewObject.Visibility = False
rebar1 = Arch.makeRebar(diameter = 12)
rebar1.Base = line
rebar1.Label = 'TopMain'
rebar1.Host = concrete
rebar1.Amount = 3
rebar1.Rounding = 2.000
rebar1.MoveWithHost = True
rebar1.Direction = (0.000,1 , 0.000)
#rebar1.Spacing = b-2*dx
rebar1.OffsetStart =dx+diameter/2. ; rebar1.OffsetEnd =dx+diameter/2.
rebar1.Role = u"Rebar"
points=[Vector(-100-dx,y,-h +dx+2*dia+6*dia),
Vector(-100-dx,y,-h+dx+diameter/2.),
Vector(+100 + Ln +200-dx,y,-h+dx+diameter/2.),
Vector(+100 + Ln +200-dx,y,-h+dx+2*dia+6*dia),]
line2 = Draft.makeWire(points,closed=False,face=False,support=None)
line2.ViewObject.Visibility = False
rebar2 = Arch.makeRebar(diameter = 12)
rebar2.Base = line2
rebar2.Label = 'BottomMain'
rebar2.Host = concrete
rebar2.Amount = 3
rebar2.Rounding = 2.000
rebar2.MoveWithHost = True
rebar2.Direction = (0.000,1 , 0.000)
#rebar2.Spacing = b-2*dx
rebar2.OffsetStart =dx+ diameter/2. ; rebar1.OffsetEnd =dx+ diameter/2.
rebar2.Role = u"Rebar"
# Double Stirrup
b1 = b/2+dia/2+20
concreteDummy = Arch.makeStructure(length=Ln,width=b1 ,height=h)
concreteDummy.Placement.Base = Vector(L-col_width/2., +(b-b1)/2 , -h/2.)
concreteDummy.Label = 'Dummy1'
concreteDummy.ViewObject.Transparency = 70
FreeCAD.ActiveDocument.recompute()
#selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
structure = concreteDummy
facename = 'Face6' #selected_obj.SubElementNames[0]
#facename
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)
s_cover = 20 #b -(b/2.0-20-dia/2.0)/2.0
bentAngle = 135
bentFactor = 6
rounding=2
spacing = 175
num = int(L/spacing)+1
amount_spacing_value = num
f_cover = ( L-((num-1)*spacing) )/2.0
points = getpointsOfStirrup(FacePRM, s_cover, bentAngle, bentFactor, diameter, rounding, FaceNormal)
line = Draft.makeWire(points, closed = False, face = True, support = None)
line.Support = [(structure, facename)]
stir = Arch.makeRebar(structure, line, diameter, amount_spacing_value, f_cover)
stir.Direction = FaceNormal.negative()
stir.Rounding = rounding
stir.Role = u"Rebar"
stir.Label = 'Stirrups1'
stir.MoveWithHost = True
# -------------------
concreteDummy2 = Arch.makeStructure(length=Ln,width=b1 ,height=h)
concreteDummy2.Placement.Base = Vector(L-col_width/2., -(b-b1)/2 , -h/2.)
concreteDummy2.Label = 'Dummy2'
concreteDummy2.ViewObject.Transparency = 70
FreeCAD.ActiveDocument.recompute()
#selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
structure = concreteDummy2
facename = 'Face6' #selected_obj.SubElementNames[0]
#facename
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)
f_cover = ( L-((num-1)*spacing) )/2.0+diameter*1.5
points = getpointsOfStirrup(FacePRM, s_cover, bentAngle, bentFactor, diameter, rounding, FaceNormal)
line = Draft.makeWire(points, closed = False, face = True, support = None)
line.Support = [(structure, facename)]
stir2 = Arch.makeRebar(structure, line, diameter, amount_spacing_value, f_cover)
stir2.Direction = FaceNormal.negative()
stir2.Rounding = rounding
stir2.Role = u"Rebar"
stir2.Label = 'Stirrups2'
stir2.MoveWithHost = True
#stir2.OffsetEnd =57.
concreteDummy.ViewObject.Visibility=False
concreteDummy2.ViewObject.Visibility=False
FreeCAD.ActiveDocument.recompute()
stir2.OffsetEnd = 61. # fake
if __name__=="__main__":
makeSimpleBeam2()
FreeCAD.ActiveDocument.recompute()
Msg('Done!!\n\n')
Rebar Addon: Commits on Jul 12, 2017
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11570 (Git)
Build type: Release
Branch: master
Hash: a68940340747d3f18818fc7b0bc72eb59e7a0f25
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0