Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing/Calling a CATScript from another CATScript

Status
Not open for further replies.

flyingpenguin

New member
Mar 22, 2004
7
0
0
TR
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:

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


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
 
Replies continue below

Recommended for you

I am suffering "being a fool apprentice"!
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!

 
Eventually, I did! Reached the fresh icy water full of fish!

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:
Sub CATMain()

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
 
Status
Not open for further replies.
Back
Top