rebar based on wire

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

rebar based on wire

Post by bernd »

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

rebar-based-on-wire.FCStd
(13.96 KiB) Downloaded 30 times

screen4.jpg
screen4.jpg (175.28 KiB) Viewed 1601 times
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: rebar based on wire

Post by chakkree »

bernd wrote: Tue Apr 23, 2019 1:43 pm Is there a Python method to make a Rebar out of a wire?
I use pivy.coin to represent rebar shape. This code for create U-Shape rebar.
Rebar_PivyCoin_01.png
Rebar_PivyCoin_01.png (122.54 KiB) Viewed 1561 times
TestRebarPivy01.py
(3.87 KiB) Downloaded 23 times

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')
    
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: rebar based on wire

Post by bernd »

Very interesting? Is there any specific reason for using pivy.coin for this ?
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: rebar based on wire

Post by bernd »

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()
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: rebar based on wire

Post by bernd »

But somehow it seams not possible to make rebar without a structure object? This should be possible IMHO.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: rebar based on wire

Post by bernd »

bernd wrote: Wed Apr 24, 2019 10:44 am But somehow it seams not possible to make rebar without a structure object? This should be possible IMHO.
it only needs a small change in rebar code. I my go for a PR.
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: rebar based on wire

Post by yorik »

bernd wrote: Wed Apr 24, 2019 10:44 am But somehow it seams not possible to make rebar without a structure object? This should be possible IMHO.
I think you are right.. But indeed there is no real need, I think it would be easy to change
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: rebar based on wire

Post by chakkree »

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)

Rebar_in_Home01.png
Rebar_in_Home01.png (1011.33 KiB) Viewed 1502 times
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: rebar based on wire

Post by bernd »

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.
User avatar
ebrahim raeyat
Posts: 625
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: rebar based on wire

Post by ebrahim raeyat »

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.
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.
Post Reply