python catia,使用python脚本运行Catia宏

I was looking for some help with handling Catia V5 with a python script from the windows PowerShell. I need help building a script that tells Catia to run a macro which I already recorded.

Also, some help to find a command that closes or doesn't let message boxes appear would be greatly appreciated.

解决方案

If I understand correctly, you're trying to run a recorded CATIA macro (.catvba?) and call it from Python which is called by PowerShell. I'll assume your PowerShell calling Python is working as intended.

Here's one way to bridge the gap between Python and CATIA VBA:

Bind your CATIA macro to a custom toolbar icon, you'll notice when you hover your mouse over the icon that the name of the macro will appear in the bottom right corner of CATIA, e.g. "c:Your_macro_name".

Once you are at this stage you can call the macro from Python with:

import win32com.client

catapp = win32com.client.Dispatch('CATIA.Application')

catapp.StartCommand('Your_macro_name')

This should call your CATIA macro (under its toolbar name).

Also, to suppress some of the messages that come up in CATIA, try starting your VBA code with:

CATIA.RefreshDisplay = False

CATIA.DisplayFileAlerts = False

Hope this helps!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值