hypermesh 小工具之合并 多個類似component

在hypermesh 中導入幾何模型之后,通常component 會比較多,用戶通常需要進行對component 進行一些篩選,對相同的component進行合并,本人也常為此苦惱,通過編寫一個工具,成功實現了將名稱相近的component 部件進行合并的功能。該程序是基于相同類型的component 通常命名為 XXX ,XXX.1, XXX.2, XXX.n,利用名稱之間的公共因子XXX,將所有含有該因子的component 移動到名稱為XXX 的component中。

程序很簡單,僅僅是我學習tcl 語言 的一個見證。

效果: 一個包含456個component的模型,程序運行之后僅存198個componnet 。

核心代碼是" string last  XXX XXX.1", 判斷 一個component是否包含另一個compoent 的名稱,然后依次分別將該XXX.1 中 Solid 和Surface 移動到 XXX, 然后刪除 XXX.1。

此外,可以設定一個componnet Solid 體積的閾值,將所有小于該體積的component(通常是螺釘) 移動到一個一個component, 本文中命名為small part ,同樣可以合并component。

分享component 體積的代碼

proc getVolume {comps} {

*clearmarkall

*createmark solids 1 "by component" $comps

if { [hm_marklength solids 1] == 0 } {

set volume "no value"

} else {

hm_marktotable solids 1 table2

set solid_ID [hm_getmarkfromtable table2 ]

#puts [llength $solid_ID]

set volume 0

foreach id $solid_ID {

#puts $id

set volume [expr {$volume +[hm_getvolumeofsolid solids $id ]}]

#puts $volume

*clearmarkall

}

}

return $volume

}

以下內容為付費內容,請購買后觀看

   12人購買

hypermesh 自動合并component

App下載
技術鄰APP
工程師必備
  • 項目客服
  • 培訓客服
  • 平臺客服

TOP

3
8
2