CATIA macro from python

跟風遠走 提交于 2019-12-07 08:15:25

The StartCommand method can (as far as I know) only start macros assigned to toolbar buttons. I advise you to instead use the SystemService.ExecuteScript method, which allows you to run the script directly. Your example would then be modified to look something like this:

import win32com.client
catapp = win32com.client.Dispatch("CATIA.Application")
catapp.SystemService.ExecuteScript(
    # Macro library name/path
    r"C:\Path\To\Directory\Containing\The\Script",
    # Type of macro library (document/directory/VBA project)
    1,  # directory
    # Macro name
    "Macro_schweller_model_lsopt.CATScript",
    # Function name
    "CATMain",
    # Arguments
    tuple(),
)

More information on the SystemService.ExecuteScript method is available at http://catiadoc.free.fr/online/interfaces/interface_SystemService.htm#ExecuteScript.

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