I have been working on a code to run a .CATScript of CATIA v5 from python 3.6. In short, the objective is to run the .CATScript from python module. By running the following script from python console, the CATIA interface opens but the script is not running. The GUI of CATIA which opens is for a new product but not for the script. Could someone please help me with this problem?
The python code looks as
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")
whereas the .CATScript looks like
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
Any help will be greatly appreciated.
Thank you