这是人家的程序,我转载过来,供参考
;----------------------------建立水平支撑与立柱桩交点处节点间的刚性link----------------------
def merge_link
node_num=0
node_pnt1 = nd_head
loop while node_pnt1 # null ;寻找总节点数,注:不能自己任生成node,程序缺省的方式为连续生成无不连续
node_num = node_num+1
node_pnt1 = nd_next(node_pnt1)
endloop
node_num_minus1 = node_num-1
link_id=30000
loop ii (1,node_num_minus1)
node_pnt1 = nd_find(ii)
xx1 = nd_pos(node_pnt1,2,1)
yy1 = nd_pos(node_pnt1,2,2)
zz1 = nd_pos(node_pnt1,2,3)
ii_plus1 = ii+1
loop jj (ii_plus1,node_num)
node_pnt2 = nd_find(jj)
xx2 = nd_pos(node_pnt2,2,1)
yy2 = nd_pos(node_pnt2,2,2)
zz2 = nd_pos(node_pnt2,2,3)
node_dist = sqrt((xx1-xx2)^2+(yy1-yy2)^2+(zz1-zz2)^2)
dist_tol = 1e-3
if node_dist < dist_tol then
link_pnt1 = nd_link(node_pnt1)
link_pnt2 = nd_link(node_pnt2)
if link_pnt1 # null then
temp1 = lk_delete(link_pnt1)
endif
if link_pnt2 # null then
temp2 = lk_delete(link_pnt2)
endif
link_id = link_id+1
command ;生成新link(6自由度全固结) ,大的node的id作为target node,小的node的id作为source node,需注意不同情况下的灵活调整
sel set link node_tol=dist_tol
sel link id=link_id ii target = node tgt_num = jj ;指定link的ID
;sel link ii target = node tgt_num = jj ;不指定link的id,自动生成
sel link attach xdir=rigid ydir=rigid zdir=rigid xrdir=rigid yrdir=rigid zrdir=rigid range id=link_id
endcommand
endif
endloop
endloop
end
merge_link