Executing/Calling a CATScript from another CATScript
Executing/Calling a CATScript from another CATScript
(OP)
Hello,
I am trying to execute an existing CATscript from a new one.
- The existing script operates on the active document to save it into a database.
- It is written by someone else, I want to use it as it is.
The sample code I have written is:
However, I get the following error for the ExecuteScript line: Cannot use paranthesis when calling a sub
Although I checked the language reference, I am not sure if I used the correct syntax. How could it be written without paranthesis? Probably, the problem must be something else.
Thanks in advance...
FPeng - a fresh enthusiast in CATIA Scripting
I am trying to execute an existing CATscript from a new one.
- The existing script operates on the active document to save it into a database.
- It is written by someone else, I want to use it as it is.
The sample code I have written is:
CODE
Sub CATMain()
scpath = "D:\tmp"
MsgBox "CATIman Save Operation will be executed on the active document!"
CATIA.SystemService.ExecuteScript(scpath, catScriptLibraryTypeDocument, "Save.CATScript")
End Sub
scpath = "D:\tmp"
MsgBox "CATIman Save Operation will be executed on the active document!"
CATIA.SystemService.ExecuteScript(scpath, catScriptLibraryTypeDocument, "Save.CATScript")
End Sub
However, I get the following error for the ExecuteScript line: Cannot use paranthesis when calling a sub
Although I checked the language reference, I am not sure if I used the correct syntax. How could it be written without paranthesis? Probably, the problem must be something else.
Thanks in advance...
FPeng - a fresh enthusiast in CATIA Scripting





RE: Executing/Calling a CATScript from another CATScript
Trying something else, I realized that the error meant exactly what it says: CATIA does not want paranthesis around the arguments.
Now I have got a runtime error stating: Wrong number of arguments or invalid property assignment 'CATIA.SystemService.ExecuteScript'
Digging the thick ice!
RE: Executing/Calling a CATScript from another CATScript
I realized some problems and corrected them:
- the library type must be catScriptLibraryTypeDirectory because I give a directory path as a library.
- the name of the function must be provided even if it is CATMain
- the parameters to the called function must be provided even if there is no parameters.
The Correct Code:
CODE
Dim EmptyPar()
Dim ScPath
ScPath = "D:\tmp"
MsgBox "Save Operation will be executed on the active document!"
CATIA.SystemService.ExecuteScript scpath, catScriptLibraryTypeDirectory, "Save.CATScript", "CATMain", EmptyPar
End Sub
It became a kind of monologue... but I hope these information will help somebody else.
FPeng