2006年12月5日星期二
一段绘制空间扭网壳的ANSYS代码(APDL)
!下面一段话是在ANSYS中绘制空间扭网壳的APDL代码
!华南理工大学 建筑学院 qjchen
!http://chenqj.blogspot.com
!虽然到现在杂乱地学了10来种语言,也考过什么程序员的,但发现许多时候的计算机编程应用经
!常集中在文本格式转换,简单的循环,数列通项公式的查找方面,都是最简单的东西。
!不过也不算白学,好歹大部分语言现在硬着头皮都能看懂,也不错
/prep7
Rad=30000
num=11
pi=atan(1)*4
!draw the control point
k,1,0,-Rad,0.2*Rad
k,num,Rad*sin(30*pi/180),-Rad*cos(30*pi/180),-0.1*Rad
k,num*num-num+1,-Rad*sin(30*pi/180),-Rad*cos(30*pi/180),-0.1*Rad
k,num*num,0,0,0.1*Rad
!draw the four edge point
kfill,1,num,,,1
kfill,num*num-num+1,num*num,,,1
kfill,1,num*num-num+1,num-2,,num
kfill,num,num*num,num-2,,num
!draw the other point
*do,j,2,num-1,1
kfill,(j-1)*num+1,(j-1)*num+num,,,1
*enddo
!draw the 45 deg line
lnumbef=lsinqr(0,14)+1
*do,j,1,num,1
*do,i,1,num-1,1
lstr,(j-1)*num+i,(j-1)*num+i+1
*enddo
*enddo
lnumaft=lsinqr(0,14)
lsel,r,,,lnumbef,lnumaft,1
cm,lineup45,line
!draw the 135 deg line
lnumbef=lsinqr(0,14)+1
*do,i,1,num,1
*do,j,1,num-1,1
lstr,(j-1)*num+i,(j-1)*num+i+num
*enddo
*enddo
lnumaft=lsinqr(0,14)
lsel,r,,,lnumbef,lnumaft,1
cm,lineup135,line
!draw the 90 deg line
lnumbef=lsinqr(0,14)+1
*do,j,1,num-1,1
*do,i,1,num-1,1
lstr,(j-1)*num+i,j*num+i+1
*enddo
*enddo
!copy up to down keypoint
kplot
allsel
kgen,2,1,num*num,1,,,-0.2*Rad,10000
!copy up to down line
lplot
allsel
dd=lsinqr(0,14)
lgen,2,1,dd,1,,,-0.2*Rad,10000
KSEL,ALL
kplot
!draw all the ver member
*do,j,1,num,1
*do,i,1,num,1
lstr,(j-1)*num+i,(j-1)*num+i+10000
*enddo
*enddo
/vup,1,z
!draw the 45 deg lean member
*do,j,1,num,1
*do,i,1,0.5*(num-1),1
lstr,(j-1)*num+i,(j-1)*num+i+1+10000
*enddo
*enddo
*do,j,1,num,1
*do,i,0.5*(num+1),num-1,1
lstr,(j-1)*num+i+10000,(j-1)*num+i+1
*enddo
*enddo
!draw the 135 deg lean member
*do,i,1,num,1
*do,j,1,0.5*(num-1),1
lstr,(j-1)*num+i,(j-1)*num+i+num+10000
*enddo
*enddo
*do,i,1,num,1
*do,j,0.5*(num+1),num-1,1
lstr,(j-1)*num+i+10000,(j-1)*num+i+num
*enddo
*enddo
!draw the 90 deg lean member
*do,i,1,num-1,1
*do,h,1,num-i,1
*if,h,LE,0.5*(num-i),Then
lstr,i+(h-1)*(num+1),i+h*(num+1)+10000
*else
lstr,i+(h-1)*(num+1)+10000,i+h*(num+1)
*endif
*enddo
*enddo
*do,i,2,num-1,1
*do,h,1,num-i,1
*if,h,LE,0.5*(num-i),Then
lstr,i+(h-1)*(num+1)+(num-1)*(i-1),i+h*(num+1)+10000+(num-1)*(i-1)
*else
lstr,i+(h-1)*(num+1)+10000+(num-1)*(i-1),i+h*(num+1)+(num-1)*(i-1)
*endif
*enddo
*enddo
!draw the area
*do,i,1,num-1,1
*do,j,1,num-1,1
a,(j-1)*num+i,(j-1)*num+i+1,(j-1)*num+i+num+1
a,(j-1)*num+i,(j-1)*num+i+num,(j-1)*num+i+num+1
*enddo
*enddo