HyperView 基于Python Tcl二次开发之 模型分组并配色

发布时间:2026/5/19 2:08:26

HyperView 基于Python  Tcl二次开发之 模型分组并配色 更多HyperView Python Tcl二次开发笔记 关注公众号CAE仿真记CAE仿真分析一般情况前期建模已将模型分成不同的组每个组都对应自己独立的ID区间基于此ID区间可将模型分组并配色有助于后处理过程中快速选择部件报告截图美观。基于Python语言实现此功能的方法如下def group_and_color (group_name,color,*args): import hw import hw.hv as hv sess hw.Session() # 获取当前激活的page page sess.get(hw.Page) # 获取当前激活的window win sess.get(hw.Window) # 获取当前激活的model model win.getActiveModel() # #col1 hv.Collection(hv.Part,modelmodel,populateFalse) #col1.addByID(hv.Part,74000000-74000020) # 创建 part set set1 hv.Set(hv.Part,modelmodel,populateFalse) # 按id 范围将需要的pid放入 set中 if len(args) 1: set1.addByID(hv.Part,{args[0]}) if len(args) 2: set1.addByID(hv.Part,f{args[0]}-{args[1]}) if len(args) 2: args_str ,.join(str(arg) for arg in args) set1.addByID(hv.Part,args_str) # 设置set 名 颜色等属性 set1.setAttributes(labelgroup_name) set1.setAttributes(drawStyleshaded) set1.setAttributes(colorcolor) # True 显示 False 隐藏 set1.setAttributes(visibilityTrue) # def part_and_color (color,pid): import hw import hw.hv as hv sess hw.Session() # 获取当前激活的page page sess.get(hw.Page) # 获取当前激活的window win sess.get(hw.Window) # 获取当前激活的model model win.getActiveModel() part model.get(hv.Part,pid) part.setAttributes(colorcolor) part.setAttributes(meshModetransparent) # def refresh_window (): import hw import hw.hv as hv sess hw.Session() page sess.get(hw.Page) win sess.get(hw.Window) win.draw()

相关新闻