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


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()💡提示
代码复制可用
如有问题,欢迎留言指正与交流。 本文已收录进合集,进入文末合集可查看更多笔记。
往期文章
HyperMesh Python二次开发-自动修改Component名字
HyperView Python 二次开发 自动测量座椅靠背动态角度