当前位置: 首页 > news >正文

CST Studio Suite Python自动化学习笔记

前言

这CST Studio Suite 2026版给加了个Python自动化的教程,算是能学了。然而CST的底层全部基于VBA,Python的文档里的方法都写不全,还得去看VBA的文档,鉴定为不如PyAEDT。

基础调用

按照教程安装完成后,可以直接在VS Code里面调用cst库。

使用cst.interface.get_current_project()方法,可以直接获取到当前打开项目对应的Project类,不知道为什么教程把这个写在CST内部的Python解释器的一节中。

创建立方体

只能通过向History List中添加VBA命令来创建物体。文档中给了以下代码。

# define a String holding the VBA code for creating a Brick
vba_code = """
With Brick.Reset.Name "solid1".Component "component1".Material "PEC".Xrange "0", "3".Yrange "0", "4".Zrange "0", "5".Create
End With
"""# add the VBA code to the History List
prj.model3d.add_to_history("create brick", vba_code)

修改其中的值,就能添加不同位置的立方体/矩形面片。

add_to_history方法的第一个参数是显示在History List中的名称,可以用中文。

删除物体

参考文档中的代码。

def get_components_including(name: str, prj: cst.interface.Project) -> Iterator[str]:"""Create iterator to iterate over all 3D Components, whose name includes `name`."""for item in prj.model3d.get_tree_items():# split the pathsplit_item = item.split("\\")# make sure we are only deleting shapes or componentsif "Components" == split_item[0]:# search for our components (item-names are in last item of split_item)if name in split_item[-1]:# get componentscomponents = split_item[1:]# join components to the component path and appendcomponent_path = "/".join(components)# check if found item is a Componentif prj.model3d.Component.DoesExist(component_path):yield component_pathto_be_removed = "undefined_"for shape_path in get_shapes_including(to_be_removed, prj):# define the VBA code_examples & add to the history listdelete_vba = f'Solid.Delete "{shape_path}"'prj.model3d.add_to_history(f"delete shape: {shape_path}", delete_vba)

会在History List中添加一项删除。
看起来要彻底删除的话还是得研究一下VBA文档,只能先手动了。

http://www.jsqmd.com/news/262626/

相关文章:

  • 详细介绍:【040-安全开发篇】JavaEE应用SpringBoot框架JWT身份鉴权打包部署JARWAR
  • 机械行业如何利用百度UE的JS截屏功能优化设计文档导入?
  • CSS盒子模型:网页布局的基石与艺术
  • 射频-驻波比的理解
  • Gemini CLI快速运维
  • Linux 基础开发工具详解(Yum, Vim, GCC, Make, GDB, Git) - 指南
  • 组合螺丝专业供应商靠谱吗,东层紧固件有哪些信任背书? - 工业品牌热点
  • 复合式分板机国内选哪个厂家的产品好? - 工业品牌热点
  • Godot Win32
  • 芯片制造企业网页如何集成百度开源上传组件实现文件夹上传?
  • 极端天气数据集 恶劣天气数据集 雾天道路行驶数据集 黑夜情境下的交通数据集 红绿灯检测数据集 疲劳驾驶检测数据集 交通路锥检测数据集 路面标识交通引导线 车道线检测数据集]
  • 14.2 去中心化协同与导航:基于LIVEPOINT框架的无死锁多机器人系统
  • 机械制造行业网页如何用html5实现文件夹上传?
  • 14.3 任务分配与协同操作:从市场拍卖到分布式优化的多机器人协作
  • 基于SpringBoot+Vue网络办公自动化系统的设计与实现
  • 15.1 机器人控制的伦理、安全与社会影响:技术成熟度伴随的责任审视
  • hadoop集群搭建 (超详细) 接入Impala、Hive,AI 大模型的数据底座 - 教程
  • 仓库管理软件哪个好用,有没有最简单的出入库系统
  • 15.2 技术融合与未来展望:AI、新材料与生物交叉驱动下的新形态与新能力
  • 研究生必看:导师让改AI率?这份超全攻略帮你顺利过关
  • skill-creator详细且实用的教程
  • 2010-2025年上市公司数字化迎合指标数据
  • 保姆级教程:5分钟学会用工具降低论文AIGC检测率
  • 2002-2024年上市公司供应链数字化转型数据+代码
  • 1985.1-2026.1世界各国经济政策不确定性指数
  • 知网AIGC检测标准更新后,这3款降AI工具依然有效
  • 【多无人机路径规划】基于K均值聚类与遗传算法的无人机路径规划,对任务区域进行划分,并优化每个区域内的访问路径研究(Matlab代码实现)
  • 【多无人机协同目标运输任务】多无人机协同目标运输任务中的路径规划与动态控制研究(Matlab代码实现)
  • py每日spider案例之music搜索接口
  • py每日spider案例之music搜索接口