我一直在研究从python 3.6 运行CATIA v5的.CATScript的代码。简而言之,目标是从python模块运行.CATScript。通过从python控制台运行以下脚本,CATIA界面将打开,但脚本未运行。打开的CATIA GUI用于新产品,但不用于脚本。有人可以帮我解决这个问题吗?
python代码看起来像
import os;
import sys;
import shutil;
import win32com.client
os.startfile("C:/FK-Programme/Dassault Systemes/B24/win_b64/code/bin/CNEXT.exe")
os.system("D:\Macro_python\Macro_cylinder.CATScript")
print ("Normal Termination")
而.CATScript看起来像
Sub CATMain()
CATIA.DisplayFileAlerts = False
Dim FileToOpen as String
Dim partDocument1 As Document
Dim part1 As Part
Dim LengthPara As Parameter
Dim parameters1 As Parameters
Dim RadiusPara As Parameter
FileToOpen = "D:\Macro_python\Cylinder.CATPart"
Set partDocument1 = CATIA.Documents.Open(FileToOpen)
Set part1 = partDocument1.Part
Set parameters1 = part1.Parameters
Set LengthPara = parameters1.RootParameterSet.DirectParameters.Item("Length")
LengthPara.Value = 50
Set RadiusPara = parameters1.RootParameterSet.DirectParameters.Item("Radius")
RadiusPara.Value = 10
partDocument1.Part.Update
partDocument1.ExportData "D:\Macro_python\Cylinder.CATPart\cylinder.stp", "stp"
End Sub
任何帮助将不胜感激。
谢谢