当前位置:首页>python>HyperView Python 二次开发 自动调整曲线legend字体大小

HyperView Python 二次开发 自动调整曲线legend字体大小

  • 2026-10-11 08:44:31
HyperView Python 二次开发 自动调整曲线legend字体大小

CAE仿真记

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


日常报告截图前,一般都会调整曲线图列legend字体大小,图线数量较多时候,每个图列legend都点击调整一次浪费大量时间,还不能保证每次设置的字体大小相同,使用二次开发脚本1秒搞定。

此篇是学会怎样在hyperview中使用二次开发功能自动调整曲线图列legend字体大小。

HyperView基于Python语言实现方法:

def modify_curve_legend_font (fontsize):# 模块导入    import hw    import hw.hg as hg#========================# 依据RGB值 创建color #========================    color = hw.Color(rgb=(255,0,0))#========================# 创建字体#========================    font = hw.Font(size=fontsize,style="bold",family="Noto Sans")#    ses = hw.Session()    win = ses.get(hw.Window)    legend = ses.get(hg.Legend)# 设置legend 位置# insideLeftTopCorner, insideLeftBottomCorner, # insideRightTopCorner, insideRightBottomCorner, outsideTop, # outsideBottom, outsideLeft, outsideRight, insideUserDefined.    legend.placement = "insideLeftTopCorner"# 设置字体和颜色    legend.font = font# 显示标题 True or False    legend.visibility = True    win.update()modify_curve_legend_font(50)
往期文章
HyperView 基于Tcl 二次开发常用功能合集
HyperView Python 二次开发 自动测量座椅靠背动态角度
HyperMesh Python二次开发-自动修改Component名字
HyperMesh Python二次开发-自动修改Property属性
10分钟快速了解HyperMesh Python 二次开发(附源码-创建一个4节点shell单元)

💡提示

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

最新文章

随机文章