Dev logs of Rebar Addon for FreeCAD - GSoC project

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
thschrader
Posts: 1167
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby thschrader » Sun Jul 23, 2017 2:16 pm

amrit3701 wrote:
Sun Jul 23, 2017 10:54 am
thschrader wrote:
Sun Jul 23, 2017 8:58 am
Yes sir !
playwithrebartool.JPG
Can you share the .fcstd file too?

Regards,
Amritpal, heres the file.
Congredulations to your and chakkrees work from me too :)
rahmen.FCStd
(251.68 KiB) Downloaded 9 times
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11622 (Git)
Build type: Release
Branch: master
Hash: 5ffe17153d84e5b361ba4c41e56c62977619f589
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: German/Germany (de_DE)
chakkree
Posts: 258
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby chakkree » Tue Jul 25, 2017 7:53 am

Test create rebars in footing with 3 types of rebars.

TestFooting01.png
TestFooting01.png (468.56 KiB) Viewed 667 times
TestFooting01.FCStd
(80.2 KiB) Downloaded 6 times

Code: Select all

#-*- coding=utf8 -*-
"""
   TestFooting1.py
"""
import FreeCAD
import Draft
import Arch


from FreeCAD import Vector
from math import cos, radians

# BS8666
def shape21(A=300, B=1000, C=300):
    points=[Vector(0,0,A),
            Vector(0,0,0),
            Vector(B,0,0),
            Vector(B,0,C),
    ]
    line = Draft.makeWire(points,closed=False,face=False,support=None)
    return line

def shape41(A=100, B=300, C=1000, D=300, E=100):
    points=[Vector(A,0,B),
            Vector(0,0,B),
            Vector(0,0,0),
            Vector(C,0,0),
            Vector(C,0,D),
            Vector(C-E,0,D),
    ]
    line = Draft.makeWire(points,closed=False,face=False,support=None)
    return line

def shape47(A=300, B=100, C=2*12+5*12, D=2*12+5*12, R=2*12):
    points=[Vector(2*R,0,A-C),
            Vector(2*R,0,A),
            Vector(0,0,A),
            Vector(0,0,0),
            Vector(B,0,0),
            Vector(B,0,A),
            Vector(B-2*R,0,A),
            Vector(B-2*R,0,A-D),
    ]
    line = Draft.makeWire(points,closed=False,face=False,support=None)
    return line

def makeFooting1(rebarType=1):
    B = 1000
    L = B
    t = 300
    covering = 50
    dia = 12

    
    footing1 = Arch.makeStructure(length=L,width=B,height=t,name='Footing1')
    footing1.Placement.Base=Vector(+L/2., 0 , +t/2.)
    footing1.ViewObject.Transparency = 80
    R = 2*dia
    if rebarType==1:
        A1 = t-2*covering-dia/2.
        B1 = L-2*covering-dia
        line1 = shape21(A=A1 , B=B1  , C=A1)
        line1.Support = [footing1,'Face1']
        Draft.move(line1, Vector(-B1/2  ,-B/2,+covering+dia/2.))
    elif rebarType==2:
        A1 = R+6*dia
        B1 = t-2*covering-dia
        C1 = L-2*covering-dia
        line1 = shape41(A=A1, B=B1, C=C1, D=B1, E=A1)
        line1.Support = [footing1,'Face1']
        Draft.move(line1, Vector(-C1/2  ,-B/2,+covering+dia/2.))
    elif rebarType==3:
        A1 = t-2*covering-dia
        B1 = L-2*covering-dia
        line1 = shape47(A=A1, B=B1, C=2*12+5*12, D=2*12+5*12, R=2*12)
        line1.Support = [footing1,'Face1']
        Draft.move(line1, Vector(-B1/2  ,-B/2,+covering+dia/2.))

    line1.ViewObject.Visibility = False
    rebar1 = Arch.makeRebar(diameter = dia)
    rebar1.Base = line1
    rebar1.Label = 'CustomRebar_bar_No_1'
    rebar1.Host = footing1
    rebar1.Amount = 8
    rebar1.OffsetStart = covering + 2*R
    rebar1.OffsetEnd = covering + 2*R
    rebar1.Direction = (0.0, 1.0, 0.0)
    rebar1.Rounding = 2
    rebar1.ViewObject.ShapeColor = (0.0,0.0,1.0)
    
    if rebarType==1:
        A2 = t-2*covering-dia/2. - dia
        B2 = B-2*covering-dia
        line2 = shape21(A=A2 , B=B2  , C=A2)
        line2.Support = [footing1,'Face1']
        Draft.rotate(line2,90 ,  Vector(0,0,0) , Vector(0,0,1) )
        Draft.move(line2, Vector(-L/2  ,-B1/2 ,+covering+dia/2.+dia))
    elif rebarType==2:
        A2 = R+6*dia
        B2 = t-2*covering-dia - dia
        C2 = B-2*covering-dia
        line2 = shape41(A=A1, B=B1, C=C1, D=B1, E=A1)
        line2.Support = [footing1,'Face1']
        Draft.rotate(line2,90 ,  Vector(0,0,0) , Vector(0,0,1) )
        Draft.move(line2, Vector(-L/2  ,-C2/2,+covering+dia/2.+dia))
    elif rebarType==3:
        A1 = t-2*covering-dia
        B1 = L-2*covering-dia
        line2 = shape47(A=A1, B=B1, C=2*12+5*12, D=2*12+5*12, R=2*12)
        line2.Support = [footing1,'Face1']
        Draft.rotate(line2,90 ,  Vector(0,0,0) , Vector(0,0,1) )
        Draft.move(line2, Vector(-L/2  ,-B1/2,+covering+dia/2.+dia))

    line2.ViewObject.Visibility = False
    rebar2 = Arch.makeRebar(diameter = dia)
    rebar2.Base = line2
    rebar2.Label = 'CustomRebar_bar_No_2'
    rebar2.Host = footing1
    rebar2.Amount = 8
    rebar2.OffsetStart = covering + 2*R
    rebar2.OffsetEnd = covering + 2*R
    rebar2.Direction = (1.0, 0.0, 0.0)
    rebar2.Rounding = 2
    rebar2.ViewObject.ShapeColor = (0.0,1.0,0.0)

if __name__=='__main__':
    makeFooting1(rebarType=1)
    Msg('Done!!\n\n')
    FreeCAD.ActiveDocument.recompute()
----------------------------
Rebar Addon: Commits on Jul 24, 2017(81 commits)
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11654 (Git)
Build type: Release
Branch: master
Hash: 81bdb1f276540427872c72d2033c3f400a89a626
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: English/UnitedStates (en_US)
User avatar
amrit3701
Posts: 172
Joined: Mon Jun 13, 2016 5:37 pm

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby amrit3701 » Tue Jul 25, 2017 4:07 pm

chakkree wrote:
Thu Jul 20, 2017 3:28 am
I think stirrup should be separate side cover in four parts.(Example in attached picture)


TestColumn02.png
TestColumn02.FCStd

Code: Select all

#-*- coding=utf8 -*-
"""
   TestColumn02.py
   20 Jul 2017
"""
import FreeCAD
import Arch
import Draft

from FreeCAD import Vector
from math import cos, radians

# Custom DWire
# *** Prototype ***
class StirrupShape(Draft._Wire):
    def __init__(self,obj):
        Draft._Wire.__init__(self,obj)
        obj.addProperty("App::PropertyLength", "A",    "Rebar Shape", "The Length A of Stirrup rebar").A = 200
        obj.addProperty("App::PropertyLength", "B",    "Rebar Shape", "The Length B of Stirrup rebar").B=400
        obj.addProperty("App::PropertyLength", "dia",    "Rebar Shape", "The diameter of Stirrup rebar").dia = 6
        obj.addProperty("App::PropertyEnumeration","Type","Rebar Shape","The Type of hook rebar")
        obj.Type = ['1','2','3']

    def execute(self,obj):
        A = obj.A; B = obj.B; dia = obj.dia
        R = 4*obj.dia /2.
        Rcos = R*cos(radians(45))
        l_hookcos = 6*obj.dia*cos(radians(45))
        pointslist = []
        if obj.Type=='1': # แบบงอฉาก
            
            pointslist.append(Vector(-A/2.,+B/2.-R-12*dia,0))
            pointslist.append(Vector(-A/2.,+B/2.,0))
            pointslist.append(Vector(+A/2.,+B/2.,0))
            pointslist.append(Vector(+A/2.,-B/2.,0))                
            pointslist.append(Vector(-A/2.,-B/2.,+dia))
            pointslist.append(Vector(-A/2.,+B/2.,+dia))
            pointslist.append(Vector(-A/2.+R+12*dia,+B/2.,+dia))
        elif obj.Type=='2': # แบบงอขอ
            #Msg('Type=2\n')
            x = -A/2.; y =+B/2.
            dy = R + R* cos(radians(45))
            x1 = x + R - R* cos(radians(45))
            y1 = y - dy
            l_hook = 6*obj.dia*cos(radians(45))
            pointslist.append(Vector(x1+l_hook ,y1-l_hook,0))
            pointslist.append(Vector(x1-dy,y,0))
            
            #points.append(Vector(-A/2.,+B/2.,0))
            pointslist.append(Vector(+A/2.,+B/2.,0))
            pointslist.append(Vector(+A/2.,-B/2.,0))                
            pointslist.append(Vector(-A/2.,-B/2.,+dia))
            
            x1 = x + R + R* cos(radians(45))
            y1 = y - R + R* cos(radians(45))
            pointslist.append(Vector(x,y1+dy,+dia))
            pointslist.append(Vector(x1+l_hook,y1-l_hook,+dia))
            
        elif obj.Type=='3': # แบบงอข้าม
            
            x = -obj.A/2.; y =-obj.B/2.
            dx = R + R* cos(radians(45))
            dy = dx
            x1 = x + dx
            y1 = y + R - R* cos(radians(45))
            l_hook = 6*obj.dia*cos(radians(45))
            
            pointslist.append(FreeCAD.Vector(x1+l_hook,y1+l_hook,0))
            pointslist.append(FreeCAD.Vector(x,y1-dy,0))
            x = -obj.A/2.; y =+obj.B/2.
            pointslist.append(FreeCAD.Vector(x,y,0))
            
            pointslist.append(FreeCAD.Vector(+obj.A/2.,+obj.B/2.,0))
            pointslist.append(FreeCAD.Vector(+obj.A/2.,-obj.B/2.,0))                
            pointslist.append(FreeCAD.Vector(-obj.A/2.,-obj.B/2.,+obj.dia))
            
            x1 = x + R + R* cos(radians(45))
            y1 = y - R + R* cos(radians(45))
            pointslist.append(FreeCAD.Vector(x,y1+dy,+obj.dia))
            pointslist.append(FreeCAD.Vector(x1+l_hook,y1-l_hook,+obj.dia))
            
        obj.Points = pointslist
        obj.Closed = False
        obj.MakeFace = False
        obj.Support = None
        
        Draft._Wire.execute(self,obj)


def makeTestColumn02():
    doc =FreeCAD.ActiveDocument
    b = 300
    t = b
    covering = 20
    dia = 15
    dia_stir = 6
    
    concrete = Arch.makeStructure(length=b,width=t,height=500.0)
    
    h_mainRebar = 750

    x = +b/2 
    total_covering = covering + dia_stir + dia/2.
    gap = (b - 2*total_covering - dia*2 )/3.
    line1 = Draft.makeLine((x,x-total_covering,0) , (x,x-total_covering,h_mainRebar))
    rebar1 = Arch.makeRebar(diameter = dia)
    rebar1.Base = line1
    rebar1.Label = 'CustomRebar'
    rebar1.Host = concrete
    rebar1.Amount = 4
    rebar1.Direction = (-1., 0., 0.)
    rebar1.Rounding = 2
    rebar1.OffsetStart =total_covering ; rebar1.OffsetEnd =total_covering
    rebar1.Role = u"Rebar"
    
    line2 = Draft.makeLine((x,-x+total_covering,0) , (x,-x+total_covering,h_mainRebar))
    rebar2 = Arch.makeRebar(diameter = dia)
    rebar2.Base = line2
    rebar2.Label = 'CustomRebar'
    rebar2.Host = concrete
    rebar2.Amount = 4
    rebar2.Direction = (-1., 0., 0.)
    rebar2.Rounding = 2
    rebar2.OffsetStart =total_covering ; rebar2.OffsetEnd =total_covering
    rebar2.Role = u"Rebar"

    y = +b/2.-total_covering-gap-dia/2.
    line3 = Draft.makeLine((x,y,0) , (x,y,h_mainRebar))
    rebar3 = Arch.makeRebar(diameter = dia)
    rebar3.Base = line3    
    rebar3.Label = 'CustomRebar'
    rebar3.Host = concrete
    rebar3.Amount = 2
    rebar3.Direction = (-1., 0., 0.)
    rebar3.Rounding = 2
    rebar3.OffsetStart =total_covering ; rebar3.OffsetEnd =total_covering
    rebar3.Role = u"Rebar"
    
    y = -b/2.+total_covering+gap+dia/2.
    line4 = Draft.makeLine((x,y,0) , (x,y,h_mainRebar))
    rebar4 = Arch.makeRebar(diameter = dia)
    rebar4.Base = line4    
    rebar4.Label = 'CustomRebar'
    rebar4.Host = concrete
    rebar4.Amount = 2
    rebar4.Direction = (-1., 0., 0.)
    rebar4.Rounding = 2
    rebar4.OffsetStart =total_covering ; rebar4.OffsetEnd =total_covering
    rebar4.Role = u"Rebar"
    
    line5= doc.addObject("Part::Part2DObjectPython",'stirrup1')
    StirrupShape(line5)
    line5.Type = '2'
    line5.dia = dia_stir
    line5.Placement.Base = Vector(0,0,500+50)
    Draft._ViewProviderWire(line5.ViewObject)
    line5.A = b- 2*covering - dia_stir 
    line5.B = b- 2*covering - dia_stir 
    line5.MakeFace = False
    line5.FilletRadius = 2*dia_stir 
    rebar5 = Arch.makeRebar(diameter = dia_stir)
    rebar5.Base = line5    
    rebar5.Label = 'CustomRebar'
    rebar5.Host = concrete
    rebar5.Amount = 1
    rebar5.Direction = (-1., 0., 0.)
    rebar5.Rounding = 0
    rebar5.OffsetStart =0 ; rebar5.OffsetEnd =0
    rebar5.Role = u"Rebar"
    rebar5.ViewObject.ShapeColor = (0.667,0.000,0.000)
    
    line6= doc.addObject("Part::Part2DObjectPython",'stirrup2')
    StirrupShape(line6)
    line6.Type = '2'
    line6.dia = dia_stir
    line6.Placement.Base = Vector(0,0,500+50+dia_stir*2)
    line6.Placement.Rotation.Axis= Vector(0.,0.,1.)
    line6.Placement.Rotation.Angle= radians(-90)
    Draft._ViewProviderWire(line6.ViewObject)
    #Draft.rotate([line6], -90.0 ,Vector(0.,0.,0.),axis=Vector(0.,0.,1.),copy=False)
    line6.A = b- 2*covering - dia_stir -dia - 2*gap - dia_stir/2
    line6.B = b- 2*covering - dia_stir 
    line6.MakeFace = False
    line6.FilletRadius = 2*dia_stir 
    rebar6 = Arch.makeRebar(diameter = dia_stir)
    rebar6.Base = line6    
    rebar6.Label = 'CustomRebar'
    rebar6.Host = concrete
    rebar6.Amount = 1
    rebar6.Direction = (-1., 0., 0.)
    rebar6.Rounding = 0
    rebar6.OffsetStart =0 ; rebar6.OffsetEnd =0
    rebar6.Role = u"Rebar"
    rebar6.ViewObject.ShapeColor = (0.667,0.000,0.000)
    
    line7= doc.addObject("Part::Part2DObjectPython",'stirrup3')
    StirrupShape(line7)
    line7.Type = '2'
    line7.dia = dia_stir
    line7.Placement.Base = Vector(0,0,500+50+dia_stir*4)
    line7.Placement.Rotation.Axis= Vector(0.,0.,1.)
    line7.Placement.Rotation.Angle= radians(180)
    Draft._ViewProviderWire(line7.ViewObject)
    line7.A = b- 2*covering - dia_stir -dia - 2*gap - dia_stir/2
    line7.B = b- 2*covering - dia_stir 
    line7.MakeFace = False
    line7.FilletRadius = 2*dia_stir 
    rebar7 = Arch.makeRebar(diameter = dia_stir)
    rebar7.Base = line7    
    rebar7.Label = 'CustomRebar'
    rebar7.Host = concrete
    rebar7.Amount = 1
    rebar7.Direction = (-1., 0., 0.)
    rebar7.Rounding = 0
    rebar7.OffsetStart =0 ; rebar7.OffsetEnd =0
    rebar7.Role = u"Rebar"
    rebar7.ViewObject.ShapeColor = (0.667,0.000,0.000)

if __name__=='__main__':
    makeTestColumn02()
    Msg('Done!!\n\n')
    FreeCAD.ActiveDocument.recompute()
-------------------
Rebar Addon: Commits on Jul 20, 2017
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11616 (Git)
Build type: Release
Branch: master
Hash: aba4338808178b508f3170237f205e0066a5b437
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: English/UnitedStates (en_US)

Hi @chakkree,

I have found a bug present in the above stirrup code.
rebarbug.png
rebarbug.png (226.61 KiB) Viewed 626 times

This bug is coming when I change a diameter(dia property of the stirrup1) of the stirrup. However, I found a reason behind why this bug came. Actually, you have not trigger obj.FilletRadius = 2*obj.dia code in the execute function. Given below is the correct code:

Code: Select all

#-*- coding=utf8 -*-
"""
   TestColumn02.py
   20 Jul 2017
"""
import FreeCAD
import Arch
import Draft

from FreeCAD import Vector
from math import cos, radians

# Custom DWire
# *** Prototype ***
class StirrupShape(Draft._Wire):
    def __init__(self,obj):
        Draft._Wire.__init__(self,obj)
        obj.addProperty("App::PropertyLength", "A",    "Rebar Shape", "The Length A of Stirrup rebar").A = 200
        obj.addProperty("App::PropertyLength", "B",    "Rebar Shape", "The Length B of Stirrup rebar").B=400
        obj.addProperty("App::PropertyLength", "dia",    "Rebar Shape", "The diameter of Stirrup rebar").dia = 6
        obj.addProperty("App::PropertyEnumeration","Type","Rebar Shape","The Type of hook rebar")
        obj.Type = ['1','2','3']

    def execute(self,obj):
        A = obj.A; B = obj.B; dia = obj.dia
        R = 4*obj.dia /2.
        Rcos = R*cos(radians(45))
        l_hookcos = 6*obj.dia*cos(radians(45))
        pointslist = []
        if obj.Type=='1': # แบบงอฉาก
            
            pointslist.append(Vector(-A/2.,+B/2.-R-12*dia,0))
            pointslist.append(Vector(-A/2.,+B/2.,0))
            pointslist.append(Vector(+A/2.,+B/2.,0))
            pointslist.append(Vector(+A/2.,-B/2.,0))                
            pointslist.append(Vector(-A/2.,-B/2.,+dia))
            pointslist.append(Vector(-A/2.,+B/2.,+dia))
            pointslist.append(Vector(-A/2.+R+12*dia,+B/2.,+dia))
        elif obj.Type=='2': # แบบงอขอ
            #Msg('Type=2\n')
            x = -A/2.; y =+B/2.
            dy = R + R* cos(radians(45))
            x1 = x + R - R* cos(radians(45))
            y1 = y - dy
            l_hook = 6*obj.dia*cos(radians(45))
            pointslist.append(Vector(x1+l_hook ,y1-l_hook,0))
            pointslist.append(Vector(x1-dy,y,0))
            
            #points.append(Vector(-A/2.,+B/2.,0))
            pointslist.append(Vector(+A/2.,+B/2.,0))
            pointslist.append(Vector(+A/2.,-B/2.,0))                
            pointslist.append(Vector(-A/2.,-B/2.,+dia))
            
            x1 = x + R + R* cos(radians(45))
            y1 = y - R + R* cos(radians(45))
            pointslist.append(Vector(x,y1+dy,+dia))
            pointslist.append(Vector(x1+l_hook,y1-l_hook,+dia))
            
        elif obj.Type=='3': # แบบงอข้าม
            
            x = -obj.A/2.; y =-obj.B/2.
            dx = R + R* cos(radians(45))
            dy = dx
            x1 = x + dx
            y1 = y + R - R* cos(radians(45))
            l_hook = 6*obj.dia*cos(radians(45))
            
            pointslist.append(FreeCAD.Vector(x1+l_hook,y1+l_hook,0))
            pointslist.append(FreeCAD.Vector(x,y1-dy,0))
            x = -obj.A/2.; y =+obj.B/2.
            pointslist.append(FreeCAD.Vector(x,y,0))
            
            pointslist.append(FreeCAD.Vector(+obj.A/2.,+obj.B/2.,0))
            pointslist.append(FreeCAD.Vector(+obj.A/2.,-obj.B/2.,0))                
            pointslist.append(FreeCAD.Vector(-obj.A/2.,-obj.B/2.,+obj.dia))
            
            x1 = x + R + R* cos(radians(45))
            y1 = y - R + R* cos(radians(45))
            pointslist.append(FreeCAD.Vector(x,y1+dy,+obj.dia))
            pointslist.append(FreeCAD.Vector(x1+l_hook,y1-l_hook,+obj.dia))
            
        obj.Points = pointslist
        obj.Closed = False
        obj.MakeFace = False
        obj.Support = None
        obj.FilletRadius = 2*obj.dia
        Draft._Wire.execute(self,obj)


def makeTestColumn02():
    doc =FreeCAD.ActiveDocument
    b = 300
    t = b
    covering = 20
    dia = 15
    dia_stir = 6
    
    concrete = Arch.makeStructure(length=b,width=t,height=500.0)
    
    h_mainRebar = 750

    x = +b/2 
    total_covering = covering + dia_stir + dia/2.
    gap = (b - 2*total_covering - dia*2 )/3.
    line1 = Draft.makeLine((x,x-total_covering,0) , (x,x-total_covering,h_mainRebar))
    rebar1 = Arch.makeRebar(diameter = dia)
    rebar1.Base = line1
    rebar1.Label = 'CustomRebar'
    rebar1.Host = concrete
    rebar1.Amount = 4
    rebar1.Direction = (-1., 0., 0.)
    rebar1.Rounding = 2
    rebar1.OffsetStart =total_covering ; rebar1.OffsetEnd =total_covering
    rebar1.Role = u"Rebar"
    
    line2 = Draft.makeLine((x,-x+total_covering,0) , (x,-x+total_covering,h_mainRebar))
    rebar2 = Arch.makeRebar(diameter = dia)
    rebar2.Base = line2
    rebar2.Label = 'CustomRebar'
    rebar2.Host = concrete
    rebar2.Amount = 4
    rebar2.Direction = (-1., 0., 0.)
    rebar2.Rounding = 2
    rebar2.OffsetStart =total_covering ; rebar2.OffsetEnd =total_covering
    rebar2.Role = u"Rebar"

    y = +b/2.-total_covering-gap-dia/2.
    line3 = Draft.makeLine((x,y,0) , (x,y,h_mainRebar))
    rebar3 = Arch.makeRebar(diameter = dia)
    rebar3.Base = line3    
    rebar3.Label = 'CustomRebar'
    rebar3.Host = concrete
    rebar3.Amount = 2
    rebar3.Direction = (-1., 0., 0.)
    rebar3.Rounding = 2
    rebar3.OffsetStart =total_covering ; rebar3.OffsetEnd =total_covering
    rebar3.Role = u"Rebar"
    
    y = -b/2.+total_covering+gap+dia/2.
    line4 = Draft.makeLine((x,y,0) , (x,y,h_mainRebar))
    rebar4 = Arch.makeRebar(diameter = dia)
    rebar4.Base = line4    
    rebar4.Label = 'CustomRebar'
    rebar4.Host = concrete
    rebar4.Amount = 2
    rebar4.Direction = (-1., 0., 0.)
    rebar4.Rounding = 2
    rebar4.OffsetStart =total_covering ; rebar4.OffsetEnd =total_covering
    rebar4.Role = u"Rebar"
    
    line5= doc.addObject("Part::Part2DObjectPython",'stirrup1')
    StirrupShape(line5)
    line5.Type = '2'
    line5.dia = dia_stir
    line5.Placement.Base = Vector(0,0,500+50)
    Draft._ViewProviderWire(line5.ViewObject)
    line5.A = b- 2*covering - dia_stir 
    line5.B = b- 2*covering - dia_stir 
    line5.MakeFace = False
    line5.FilletRadius = 2*dia_stir 
    rebar5 = Arch.makeRebar(diameter = dia_stir)
    rebar5.Base = line5    
    rebar5.Label = 'CustomRebar'
    rebar5.Host = concrete
    rebar5.Amount = 1
    rebar5.Direction = (-1., 0., 0.)
    rebar5.Rounding = 0
    rebar5.OffsetStart =0 ; rebar5.OffsetEnd =0
    rebar5.Role = u"Rebar"
    rebar5.ViewObject.ShapeColor = (0.667,0.000,0.000)
    
    line6= doc.addObject("Part::Part2DObjectPython",'stirrup2')
    StirrupShape(line6)
    line6.Type = '2'
    line6.dia = dia_stir
    line6.Placement.Base = Vector(0,0,500+50+dia_stir*2)
    line6.Placement.Rotation.Axis= Vector(0.,0.,1.)
    line6.Placement.Rotation.Angle= radians(-90)
    Draft._ViewProviderWire(line6.ViewObject)
    #Draft.rotate([line6], -90.0 ,Vector(0.,0.,0.),axis=Vector(0.,0.,1.),copy=False)
    line6.A = b- 2*covering - dia_stir -dia - 2*gap - dia_stir/2
    line6.B = b- 2*covering - dia_stir 
    line6.MakeFace = False
    line6.FilletRadius = 2*dia_stir 
    rebar6 = Arch.makeRebar(diameter = dia_stir)
    rebar6.Base = line6    
    rebar6.Label = 'CustomRebar'
    rebar6.Host = concrete
    rebar6.Amount = 1
    rebar6.Direction = (-1., 0., 0.)
    rebar6.Rounding = 0
    rebar6.OffsetStart =0 ; rebar6.OffsetEnd =0
    rebar6.Role = u"Rebar"
    rebar6.ViewObject.ShapeColor = (0.667,0.000,0.000)
    
    line7= doc.addObject("Part::Part2DObjectPython",'stirrup3')
    StirrupShape(line7)
    line7.Type = '2'
    line7.dia = dia_stir
    line7.Placement.Base = Vector(0,0,500+50+dia_stir*4)
    line7.Placement.Rotation.Axis= Vector(0.,0.,1.)
    line7.Placement.Rotation.Angle= radians(180)
    Draft._ViewProviderWire(line7.ViewObject)
    line7.A = b- 2*covering - dia_stir -dia - 2*gap - dia_stir/2
    line7.B = b- 2*covering - dia_stir 
    line7.MakeFace = False
    line7.FilletRadius = 2*dia_stir 
    rebar7 = Arch.makeRebar(diameter = dia_stir)
    rebar7.Base = line7    
    rebar7.Label = 'CustomRebar'
    rebar7.Host = concrete
    rebar7.Amount = 1
    rebar7.Direction = (-1., 0., 0.)
    rebar7.Rounding = 0
    rebar7.OffsetStart =0 ; rebar7.OffsetEnd =0
    rebar7.Role = u"Rebar"
    rebar7.ViewObject.ShapeColor = (0.667,0.000,0.000)

if __name__=='__main__':
    makeTestColumn02()
    Msg('Done!!\n\n')
    FreeCAD.ActiveDocument.recompute()
However, I like your approach. :) You first round the wire then pass it to the rebar object but I create a wire without rounding and then pass it to the rebar. The main difference in my and your's approach is that I have used rounding property of the rebar object. Below is the wire shape of the stirrup created with my approach.

rebarshape1.png
rebarshape1.png (257.23 KiB) Viewed 626 times

Can you tell which approach is better one?


Thanks,
User avatar
regis
Posts: 417
Joined: Sun Jul 12, 2015 8:17 am
Contact:

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby regis » Tue Jul 25, 2017 8:50 pm

A new round of testing, mostly looking at application on stairs.
github file link:
https://github.com/chopinregis/Youtube- ... 517f54c816
phpBB [video]
Attachments
stair rebar test.fcstd
(508.34 KiB) Downloaded 9 times
Screenshot from 2017-07-25 16-48-22.png
Screenshot from 2017-07-25 16-48-22.png (777.03 KiB) Viewed 603 times
chakkree
Posts: 258
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby chakkree » Wed Jul 26, 2017 2:34 am

amrit3701 wrote:
Tue Jul 25, 2017 4:07 pm

Can you tell which approach is better one?

That class is an old class from ArchRebar2. The class not clear for new ArchRebar, but I want to know that concept still can be used in new ArchRebar. Now, I'm not sure what is better. The main objective of Rebar is can get length property and total length property from creating report of rebar(rebar schedule or bar-cut list)
User avatar
amrit3701
Posts: 172
Joined: Mon Jun 13, 2016 5:37 pm

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby amrit3701 » Wed Jul 26, 2017 12:04 pm

regis wrote:
Tue Jul 25, 2017 8:50 pm
A new round of testing, mostly looking at application on stairs.
Hi @regis,

You are doing great. :) I have fixed a bug of expanded stirrup direction which only came on selecting the side face of a stirrup. I also noticed that your rebar add-on is not the latest one. Try to update it from addon manager because many new features you are missing ;).

solvedstirrupbug.png
solvedstirrupbug.png (431.02 KiB) Viewed 538 times

Thanks,
User avatar
Kunda1
Posts: 2943
Joined: Thu Jan 05, 2017 9:03 pm

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby Kunda1 » Wed Jul 26, 2017 12:07 pm

amrit3701 wrote:
Wed Jul 26, 2017 12:04 pm
I also noticed that your rebar add-on is not the latest one.
Maybe we should list the addon versions in the About FreeCAD dialogue ?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
thschrader
Posts: 1167
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby thschrader » Wed Jul 26, 2017 3:26 pm

@amritpal
@chakkree
In the link you will find a german company specialized on developing rebar tools.
Maybe you can find something for your "inspiration".
regards thomas
http://www.dicad.de/dicad_eng/news/2014 ... anung.html
User avatar
sgrogan
Posts: 4495
Joined: Wed Oct 22, 2014 5:02 pm

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby sgrogan » Wed Jul 26, 2017 9:09 pm

Kunda1 wrote:
Wed Jul 26, 2017 12:07 pm
Maybe we should list the addon versions in the About FreeCAD dialogue ?
This should be handled by the add-ons installer. Either from meta-data in the package (in case it is installed with the .zip fallback) or using git-python.
chakkree
Posts: 258
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Dev logs of Rebar Addon for FreeCAD - GSoC project

Postby chakkree » Thu Jul 27, 2017 7:34 am

Test create footing using dialog.
My first dialog. :D

TestFooting02.png
TestFooting02.png (425.62 KiB) Viewed 447 times

Code: Select all

"""
  TestFooting2.py
  27 Jul 2017
  https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/TemplatePyMod/TaskPanel.py
"""
import FreeCAD
import Draft
import Arch

from FreeCAD import Vector
from PySide import QtGui,QtCore

import  UShapeRebar , Stirrup



class SquareFootingTaskPanel:
    def __init__(self):
        widget1 = QtGui.QWidget()
        widget1.setWindowTitle("Square Footing")
        
        
        self.lengthLabel = QtGui.QLabel(u"Lenght")
        self.Length = QtGui.QDoubleSpinBox()
        self.Length.setRange(1, 10000000.00)
        self.Length.setValue(1000)
        self.Length.setDecimals(0)
        self.Length.setSuffix(' mm')
        """
        self.widthLabel = QtGui.QLabel(u"Width")
        self.Width = QtGui.QDoubleSpinBox()
        self.Width.setRange(1, 10000000.00)
        self.Width.setValue(1000)
        self.Width.setDecimals(0)
        self.Width.setSuffix('mm')
        """
        self.heightLabel = QtGui.QLabel(u"Height")
        self.Height = QtGui.QDoubleSpinBox()
        self.Height.setRange(1, 10000000.00)
        self.Height.setValue(300)
        self.Height.setDecimals(0)
        self.Height.setSuffix(' mm')
        
        grid = QtGui.QGridLayout()
        grid.addWidget(self.lengthLabel, 1, 0) 
        grid.addWidget(self.Length, 1, 1)
        #grid.addWidget(self.widthLabel, 2, 0) 
        #grid.addWidget(self.Width, 2, 1)
        grid.addWidget(self.heightLabel, 3, 0) 
        grid.addWidget(self.Height, 3, 1)
        widget1.setLayout(grid)
        
        widget2 = QtGui.QWidget()
        widget2.setWindowTitle("Reinforcement")
        grid2 = QtGui.QGridLayout()
        
        self.numRebarLabel = QtGui.QLabel(u"Num of Rebar")
        self.diaLabel = QtGui.QLabel(u"diameter")
        self.coveringLabel = QtGui.QLabel(u"Covering")
        grid2.addWidget(self.numRebarLabel, 1, 0)
        grid2.addWidget(self.diaLabel, 2, 0)
        grid2.addWidget(self.coveringLabel, 3, 0)
        
        self.numRebar = QtGui.QSpinBox()
        self.numRebar.setRange(1, 1000)
        self.numRebar.setValue(5)
        grid2.addWidget(self.numRebar, 1, 1)
        
        self.dia = QtGui.QDoubleSpinBox()
        self.dia.setRange(1, 100)
        self.dia.setValue(12)
        self.dia.setDecimals(1)
        self.dia.setSuffix(' mm')
        grid2.addWidget(self.dia, 2, 1)
        
        self.covering = QtGui.QDoubleSpinBox()
        self.covering.setRange(0, 300)
        self.covering.setValue(50)
        self.covering.setDecimals(1)
        self.covering.setSuffix(' mm')
        grid2.addWidget(self.covering, 3, 1)
        
        widget2.setLayout(grid2)
        
        self.form = [widget1,widget2]
    
    def accept(self):
        length = self.Length.value()
        height = self.Height.value()
        L,B,t = length,length,height
        footing1 = Arch.makeStructure(length=L,width=B,height=t,name='Footing1')
        footing1.Placement.Base=Vector(+L/2., 0 , +t/2.)
        footing1.ViewObject.Transparency = 80
        FreeCAD.ActiveDocument.recompute()
        
        num = self.numRebar.value()
        covering = self.covering.value()
        dia = self.dia.value()
        roundFactor = 2
        R = roundFactor*dia
        rebar1 = UShapeRebar.makeUShapeRebar(f_cover=covering+dia/2.+R, \
              b_cover=covering+dia/2.,  t_cover=covering, \
              r_cover=covering+dia/2., l_cover=covering+dia/2., diameter=dia,  \
              rounding=2, amount_spacing_check=True, amount_spacing_value=num, \
              orientation = "Bottom", structure = footing1, facename = 'Face1')
        rebar2 = UShapeRebar.makeUShapeRebar(f_cover=covering+dia/2.+R, \
              b_cover=covering+dia/2.+dia,  t_cover=covering, \
              r_cover=covering+dia/2., l_cover=covering+dia/2., diameter=dia,  \
              rounding=roundFactor, amount_spacing_check=True, amount_spacing_value=num, \
              orientation = "Bottom", structure = footing1, facename = 'Face6')
        FreeCAD.ActiveDocument.recompute()
        return True


if __name__=='__main__':
    FreeCADGui.Control.showDialog(SquareFootingTaskPanel())

-----------------------
Rebar Addon: Commits on Jul 26, 2017(83 commits)
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11659 (Git)
Build type: Release
Branch: master
Hash: 37258b918def361c8f80b3e82a6a420904af1229
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: English/UnitedStates (en_US)