2. Unzip and find "cba.exe" then copy to folder "FreeCAD_0.1x.xxx/bin".
3. Create floder to save temp file, and assign to variable "data_PATH "
4. Run Macro for test 2 span continuous beam example. using Plot module to display Bending Moment Diagram and Shear Force Diagram.
Code: Select all
"""
SPANS 5.8 4.2
INERTIA 3.69e-5 3.69e-5
ELASTICITY 2.1e8
CONSTRAINTS -1 0 -1 0 -1 0
LOAD 1 1 10.0 5.0 0 0
LOAD 2 1 10.0 5.0 0 0
FACTORS 1.35 1.5
"""
import Plot
import subprocess
data_PATH = "D:\\your_data_path\\cba\\"
ContBeam1 = {
'SPANS': [ 5.8 , 4.2] ,
'INERTIA' : [3.69e-5,3.69e-5 ],
'ELASTICITY' : 2.1e8 ,
'CONSTRAINTS' : [ [-1,0] , [-1,0] ,[-1,0] ] ,
'LOAD' : [
[ 1 , 1 , 10.0 , 5.0 , 0 , 0] ,
[ 2 , 1 , 10.0 , 5.0 , 0 , 0]
] ,
'FACTORS' : { 'DL':1.35 , 'LL':1.5 }
}
def make_cba_inputTextFile(contBeam):
text1 = "SPANS"
for L in contBeam['SPANS']:
text1 += ' {}'.format(L)
text1 += '\n'
text1 += "INERTIA"
for I in contBeam['INERTIA']:
text1 += ' {}'.format(I)
text1 += '\n'
text1 += "INERTIA {}".format(contBeam['ELASTICITY'])
text1 += '\n'
text1 += "CONSTRAINTS"
for retrain in contBeam['CONSTRAINTS']:
text1 += ' {} {}'.format( retrain[0] , retrain[1])
text1 += '\n'
for Load in contBeam['LOAD']:
text1 += "LOAD"
#text1 += ' {} {} {} {} {} {}' .format( Load[0] , Load[1] )
for i in Load:
text1 += ' {}'.format(i)
text1 += '\n'
text1 += "FACTORS {} {}".format( contBeam['FACTORS']['DL'] , contBeam['FACTORS']['LL'])
text1 += '\n'
return text1
#txt1 = make_cba_inputTextFile(ContBeam1)
inputFile = data_PATH + 'tempCBA.cba'
outputFile = data_PATH + 'tempCBA.out'
plotFile = data_PATH + 'tempCBA.plt'
f = open(inputFile, 'w')
f.write(make_cba_inputTextFile(ContBeam1))
f.close()
subprocess.call( ['cba.exe' , '-i' , inputFile , '-o' , outputFile , '-p' , plotFile ] , shell=True )
f = open(plotFile)
lines =f.read().split('\n')
f.close()
lines.pop(0); lines.pop(0); lines.pop(-1) ## delete 2 first rows
#x Mdmax Mdmin Vdmax Vdmin dmax dmin
x = []
Mdmax = []
Mdmin = []
Vdmax = []
Vdmin = []
dmax = []
dmin = []
for i in lines:
data=i.split()
x.append( float (data[0]) )
Mdmax.append( float (data[1]) ); Mdmin.append( float (data[2]) )
Vdmax.append( float (data[3]) ); Vdmin.append( float (data[4]) )
dmax.append( float (data[5]) ); dmin.append( float (data[6]) )
#Plot.figure("Continuous Beam Analysis Result")
Plot.figure("BMD")
Plot.plot(x,Mdmax) ; Plot.plot(x,Mdmin)
Plot.figure("SFD")
Plot.plot(x,Vdmax) ; Plot.plot(x,Vdmin)
Plot.figure("Deflections")
Plot.plot(x,dmax) ; Plot.plot(x,dmin)
OS: Windows 8
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6668 (Git)
Python version: 2.7.8