1、快速创建RBE蜘蛛
1.1、用set存放主从节点号,计算节点对应圆柱面内的节点号,存入相应的set
set nodeIdSource [hm_getvalue sets name=set_s dataname=ids]
set nodeNumSource [llength $nodeIdSource]
for {set i 0} {$i<$nodeNumSource} {incr i} {
set nodeIdi [lindex $nodeIdSource $i]
set x [hm_getvalue nodes id=$nodeIdi dataname=x]
set y [hm_getvalue nodes id=$nodeIdi dataname=y]
set z [hm_getvalue nodes id=$nodeIdi dataname=z]
set nodeSource($i,0) $x
set nodeSource($i,1) $y
set nodeSource($i,2) $z
set nodeSource($i,3) $nodeIdi
}
set r 12.0
set listv {0 0 1}
set listL {-10.0 10.0}
set v(0) [lindex $listv 0]
set v(1) [lindex $listv 1]
set v(2) [lindex $listv 2]
set L(0) [lindex $listL 0]
set L(1) [lindex $listL 1]
set nodeId [hm_getvalue sets name=set_1 dataname=ids]
set nodeNum [llength $nodeId]
for {set i 0} {$i<$nodeNum} {incr i} {
set nodeIdi [lindex $nodeId $i]
set x0 [hm_getvalue nodes id=$nodeIdi dataname=x]
set y0 [hm_getvalue nodes id=$nodeIdi dataname=y]
set z0 [hm_getvalue nodes id=$nodeIdi dataname=z]
set nodeIdFind {}
for {set j 0} {$j<$nodeNumSource} {incr j} {
set x $nodeSource($j,0)
set y $nodeSource($j,1)
set z $nodeSource($j,2)
set x [expr $x-$x0]
set y [expr $y-$y0]
set z [expr $z-$z0]
set NodeID $nodeSource($j,3)
set La [expr $x*$v(0)+$y*$v(1)+$z*$v(2)]
set Ra [expr sqrt($x**2+$y**2+$z**2-$La**2)]
if {$La>=$L(0) & $La<=$L(1) & $Ra<=$r} {
lappend nodeIdFind $NodeID
}
}
eval *createmark nodes 1 $nodeIdFind;
*entitysetcreate set_1_$i nodes 1
}
1.2、自动创建RBE2
set nodeId [hm_getvalue sets name=set_1 dataname=ids]
set nodeNum [llength $nodeId]
for {set i 0} {$i<$nodeNum} {incr i} {
set nodeIdi [lindex $nodeId $i]
set nodeIdLink [hm_getvalue sets name=set_1_$i dataname=ids]
eval *createmark nodes 2 $nodeIdLink
eval *rigidlink $nodeIdi 2 123456
}
2、tcl读写csv文件
set csvFile C:/Users/li/Documents/nodes.csv
set csv [open $csvFile]
set data [split [read $csv] '\n']
close $csv
set dataNum [llength $data]
incr dataNum -1
for {set i 0} {$i<$dataNum} {incr i} {
set datai [split [lindex $data $i] ',']
set dataiNum [llength $datai]
for {set j 0} {$j<$dataiNum} {incr j} {
set aData($i,$j) [lindex $datai $j]
}
}
set wrFile [open nodes2.csv w]
puts $wrFile $aData(0,3),[expr $aData(0,3)+10000]
puts $wrFile $aData(1,3),[expr $aData(1,3)+10000]
puts $wrFile 4,5
close $wrFile
*createnode $aData(0,0) $aData(0,1) $aData(0,2) 0 0 0
*createnode $aData(1,0) $aData(1,1) $aData(1,2) 0 0 0
*createmark nodes 1 "all"
*numbersmark nodes 1 1
*numbersmark nodes 1 0
*createmark nodes 1 2 1
*entitysetcreate "boy_R_nodes" nodes 1
set nodeId [hm_getvalue sets name=boy_R_nodes dataname=ids]
set nodeNum [llength $nodeId]
set wrFile [open nodes3.csv w]
for {set i 0} {$i<$nodeNum} {incr i} {
set nodeIdi [lindex $nodeId $i]
set x [hm_getvalue nodes id=$nodeIdi dataname=x]
set y [hm_getvalue nodes id=$nodeIdi dataname=y]
set z [hm_getvalue nodes id=$nodeIdi dataname=z]
puts $wrFile $x,$y,$z,$nodeIdi
}
close $wrFile
*createmark nodes 1 200
*renumbersolverid nodes 1 2 1 0 0 0 0 0
*createmark nodes 1 100
*renumbersolverid nodes 1 1 1 0 0 0 0 0
for {set i 0} {$i<2} {incr i} {
*createmark nodes 1 $aData($i,3)
*renumbersolverid nodes 1 $aData($i,4) 1 0 0 0 0 0
}
3、将计算有问题的单元ID保存在set中
3.1、将计算有问题的单元ID拷贝到csv文件中

3.2、tcl程序
set csvFile C:/Users/lijil/Documents/elements.csv
set csv [open $csvFile]
set data [split [read $csv] '\n']
close $csv
set dataNum [llength $data]
incr dataNum -1
for {set i 0} {$i<$dataNum} {incr i} {
set datai [split [lindex $data $i] ',']
set dataiNum [llength $datai]
for {set j 0} {$j<$dataiNum} {incr j} {
set aData($i,$j) [lindex $datai $j]
}
}
set elementsId {}
for {set i 0} {$i<$dataNum} {incr i} {
lappend elementsId $aData($i,0)
}
eval *createmark elements 1 $elementsId
*entitysetcreate set_error elements 1
4、手动选取部件,预览并输出材料的各项参数
4.1、用hypermesh的Matrix Browser查询材料的dataname关键字

4.2、tcl程序
set csvFile C:/Users/lijil/Documents/material.csv
set wrFile [open $csvFile w]
*createmarkpanel components 1 'Select Components'
*reviewentitybymark 1 0 1 0
set compList [hm_getmark components 1]
foreach comp $compList {
set nameComp [hm_getvalue comps id=$comp dataname=name]
set material [hm_getvalue comps id=$comp dataname=property.materialid]
set nameMaterial [hm_getvalue mats id=$material dataname=name]
set density [hm_getvalue comps id=$comp dataname=property.material.Density]
set young [hm_getvalue comps id=$comp dataname=property.material.Young]
set poiss [hm_getvalue comps id=$comp dataname=property.material.Poiss]
set mass [hm_getvalue comps id=$comp dataname=mass]
set dataiNum [llength $datai]
puts $wrFile $nameComp,$nameMaterial,$density,$young,$young,$poiss,$mass
}
close $wrFile