rebar based on wire
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
rebar based on wire
attached some screen of a stirrup and a FreeCAD file. This rebar is based on a wire. But I could not found a GUI tool to make a rebar based on a Draft-Wire. Did I miss something?
Is there a Python method to make a Rebar out of a wire?
bernd
Is there a Python method to make a Rebar out of a wire?
bernd
Re: rebar based on wire
I use pivy.coin to represent rebar shape. This code for create U-Shape rebar.
Code: Select all
'''
Test Create rebars by pivy.coin
24 Apr 2019
Version: 0.19.16502 (Git)
Python version: 3.6.8
'''
import os
from pivy import coin
from math import sin,cos ,pi
def creteRebarU(dia = 12, A= 300, B=1000 , num = 1 , spacing = 100):
Switch = coin.SoSwitch()
Switch.whichChild = 1
Group1 = coin.SoGroup()
Switch.addChild(Group1)
myNode = coin.SoSeparator()
Group1.addChild(myNode)
myNode.setName('RebarU1')
material = coin.SoMaterial()
material.diffuseColor.setValue(0.667, 0.000,0.000)
material.specularColor.setValue(1,1,1)
rebar = coin.SoVRMLExtrusion()
rebar.beginCap = True
rebar.endCap = True
n = 3*4
r = dia/2.0
points = []
for i in range(0,n+1):
x = r * cos(2*pi/n*i); y = r * sin(2*pi/n*i)
points.append( coin.SbVec2f( x , y) )
crossSection = coin.SoMFVec2f()
crossSection.setValues(points)
rebar.crossSection=crossSection
R = 2.0*dia
points = []
points.append( coin.SbVec3f( 0 , -B/2 , A) )
points.append( coin.SbVec3f( 0 , -B/2 , R) )
n = 6
for i in range(0,n):
dx = R * cos(pi/2/n*i); dy = R * sin(pi/2/n*i)
x = -B/2 + R-dx ; y = +R-dy
points.append( coin.SbVec3f( 0 , x , y) )
points.append( coin.SbVec3f( 0 , -B/2+R , 0) )
points.append( coin.SbVec3f( 0 , +B/2-R , 0) )
for i in range(0,n):
dx = R * cos(pi/2/n*i); dy = R * sin(pi/2/n*i)
x = +B/2-R + dy ; y = +R-dx
points.append( coin.SbVec3f( 0 , x , y) )
points.append( coin.SbVec3f( 0 , +B/2 , R) )
points.append( coin.SbVec3f( 0 , +B/2 , A) )
rebar.spine.setValues(points )
myNode.addChild(material)
myNode.addChild(rebar)
Group2 = coin.SoGroup()
Switch.addChild(Group2)
tr = coin.SoTransform()
tr.translation.setValue(0,0,0)
tr.rotation.setValue(0,0,1 , 0.00 )
Group2.addChild(tr)
array1 = coin.SoArray()
Group2.addChild(array1)
array1.origin = 'CENTER'
array1.numElements1 = num
array1.separation1.setValue(spacing,0,0)
array1.addChild(myNode)
return Switch
if __name__=='__main__':
B = 1500; L = B
t = 300
numRebar = 10
dia = 12
'''
B = 5000; L = B
t = 800
numRebar = 48
dia = 19
'''
covering = 50
R = 2*dia
spacing1 = (B-2*covering - dia - 2*R)/float(numRebar-1)
rebarA = t-2*covering - dia
rebarB = B-2*covering - dia
rebarSet1 = creteRebarU(A= rebarA , B=rebarB ,dia = dia, num=numRebar , spacing = spacing1)
rebarSet2 = creteRebarU(A= rebarA-dia , B=rebarB ,dia = dia, num=numRebar , spacing = spacing1)
footingSep = coin.SoSeparator()
group1 = rebarSet1.getChildren()[1]
tr = group1.getChildren()[0]
tr.translation.setValue(0,0,covering+dia/2.0)
group2 = rebarSet2.getChildren()[1]
tr = group2.getChildren()[0]
tr.translation.setValue(0,0,dia)
tr.rotation.setValue(coin.SbRotation(coin.SbVec3f(0.0, 0.0, 1.0), pi/2.0))
material = coin.SoMaterial()
material.transparency.setValue(0.55)
material.diffuseColor.setValue(0.000,0.667,1.000)
tr = coin.SoTransform()
tr.translation.setValue(0,0,+t/2)
"""
concSep = coin.SoSeparator()
concrete = coin.SoCube()
concrete.width = L
concrete.height=B
concrete.depth = t
concSep.addChild(material)
concSep.addChild(tr)
concSep.addChild(concrete)
"""
#footingSep.addChild(concSep)
footingSep.addChild(rebarSet1)
footingSep.addChild(rebarSet2)
sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
sg.addChild(footingSep)
"""
filePath, fileName = os.path.split(__file__)
out=coin.SoOutput()
out.openFile(filePath+os.sep+'Rebar_U_temp.iv')
wa = coin.SoWriteAction(out)
wa.apply(footingSep)
#wa.apply(rebarSet2)
#wa.apply(concSep)
out.closeFile()
"""
Msg('Done!!\n\n')
Re: rebar based on wire
Very interesting? Is there any specific reason for using pivy.coin for this ?
Re: rebar based on wire
Code: Select all
import FreeCAD, Arch, Draft
myh = 3000
Structure = Arch.makeStructure(None, length=1000, width=1000, height=myh)
Structure.ViewObject.Transparency = 80
FreeCAD.ActiveDocument.recompute()
p1 = FreeCAD.Vector(0, 0, 0)
p2 = FreeCAD.Vector(0, 0, myh)
Wire1 = Draft.makeWire([p1, p2])
FreeCAD.ActiveDocument.recompute()
Rebar = Arch.makeRebar(Structure, Wire1, diameter=30, amount=1, offset=0)
FreeCAD.ActiveDocument.recompute()
Re: rebar based on wire
But somehow it seams not possible to make rebar without a structure object? This should be possible IMHO.
Re: rebar based on wire
I think you are right.. But indeed there is no real need, I think it would be easy to change
Re: rebar based on wire
When I use python macro to create rebar in all beam, it takes a long time to generate rebars, and it has a file's size about 5.05 MB.(Not included rebars in columns, footings, and slab)
Re: rebar based on wire
I like the coin idea. Especially if I think of the reinforcement we do on work ... But I would not move all to coin. Might it be a good idea to leave the wire as a real shape and only make the solid a pivy.coin node. With this all rebar operation could be done with the wire, like material bill, place rebare against each other etc.
- ebrahim raeyat
- Posts: 625
- Joined: Sun Sep 09, 2018 7:00 pm
- Location: Iran
- Contact:
Re: rebar based on wire
It is good idea. we must set the wire shape default for rebars and if user want to view reality we can set a render option. because it is time consuming process for real structures.bernd wrote: ↑Thu Apr 25, 2019 8:26 pm I like the coin idea. Especially if I think of the reinforcement we do on work ... But I would not move all to coin. Might it be a good idea to leave the wire as a real shape and only make the solid a pivy.coin node. With this all rebar operation could be done with the wire, like material bill, place rebare against each other etc.