当前位置:首页>python>HyperMesh Python二次开发-自动修改Property属性

HyperMesh Python二次开发-自动修改Property属性

  • 2026-10-11 08:36:58
HyperMesh Python二次开发-自动修改Property属性

「CAE仿真记」

愿与您一同,用代码提升效率!


基于dyna求解器,批量修改*section_shell参数。
Default按钮默认全选四个参数,也可依据自己需求单选四个参数中的某几个。
代码如下:
import hm
import hm.entities as ent
from hwx import gui
#
def modify_property():
    model = hm.Model()
    col = hm.CollectionByInteractiveSelection(model, ent.Property)
    for property in col:
        if property.cardimage == "SectShll":
            if checkbutton_elform.value:
                property.LSD_ELFORM = lineedit_elform.text
            else:
                property.LSD_ELFORM = 2
            if checkbutton_SHRF.value:
                property.LSD_SHRF = lineedit_shrf.text
            else:
                property.LSD_SHRF = 1
            if checkbutton_NIP.value:
                property.LSD_NIP = lineedit_nip.text
            else:
                property.LSD_NIP = 3
            if checkbutton_TItle.value:
                property.LSD_TitleOpt = 1
            else:
                property.LSD_TitleOpt = 0
        else:
            continue        
def default_property():
    lineedit_elform.text = 16
    lineedit_shrf.text = 0.8333
    lineedit_nip.text = 5
    checkbutton_elform.value = True
    checkbutton_SHRF.value = True
    checkbutton_NIP.value = True
    checkbutton_TItle.value = True
# GUI
labelproperty = gui.Label(text="Shell Property Option")
checkbutton_elform = gui.CheckBox('ELFORM')
checkbutton_SHRF = gui.CheckBox('SHRF')
checkbutton_NIP = gui.CheckBox('NIP')
checkbutton_TItle = gui.CheckBox('Title')
#
lineedit_elform = gui.LineEdit()
lineedit_shrf = gui.LineEdit()
lineedit_nip = gui.LineEdit()
#
button_default = gui.Button("Default", command=default_property)
button = gui.Button("Modify", command=modify_property)
#
mainFrame = gui.VFrame(
    (labelproperty),
    (checkbutton_elform,"<->",lineedit_elform),
    (checkbutton_SHRF,"<->",lineedit_shrf),
    (checkbutton_NIP,"<->",lineedit_nip),
    (checkbutton_TItle),
    (button_default,button)
)
#
dialog = gui.Dialog(caption="Modify Property", width=300, height=200)
dialog.addChildren(mainFrame)
dialog.show()

💡提示

代码复制可用

如有问题,欢迎留言指正与交流。 本文已收录进合集,进入文末合集可查看更多笔记。

往期文章

HyperView 基于Tcl 二次开发常用功能合集

HyperMesh Python二次开发-自动修改Component名字

HyperView Python 二次开发 自动测量座椅靠背动态角度

10分钟快速了解HyperMesh Python 二次开发(附源码-创建一个4节点shell单元)

HyperView Pthon 二次开发之控制动画播放工具栏按钮(animation toolbar)

最新文章

随机文章