×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Executing/Calling a CATScript from another CATScript

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:

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

RE: Executing/Calling a CATScript from another CATScript

(OP)
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!

RE: Executing/Calling a CATScript from another CATScript

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources