Run a Catia macro with a python script

♀尐吖头ヾ 提交于 2019-12-06 14:13:34

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:

  1. 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".

  2. 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')
    

(code credit to Automate CATIA V5 with Python)

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!