Trouble calling CatScript from VB.Net

Cornell Chamberlain

Trouble calling CatScript from VB.Net
Hello,
Has anyone had experience with calling a CatScript from VB.Net? I have several existing CatScripts to perform various functions within CATIA and I would like to use them "as is" if possible and simply call them from my VB.Net form. Below is the code I am trying but, I keep getting a COMException: {"ExecuteScript(C:\temp, Test.CATScript, CATMain) Unknown macro library "C:\temp" "} Not sure where I am going wrong? I even made sure that I had that library loaded in CATIA.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim catScriptLibraryTypeDirectory As CatScriptLibraryType

Dim aParam(0)
aParam(0) = "Nothing"

Dim aScript

aScript = CATIA.SystemService
aScript.ExecuteScript("C:\temp", catScriptLibraryTypeDirectory, "Test.CATScript", "CATMain", aParam)

End Sub

Any help would be appreciated!

C-

Little Cthulhu

RE: Trouble calling CatScript from VB.Net
(in response to Cornell Chamberlain)
Hi.

Literally, you've gone wrong with this statement:

Dim catScriptLibraryTypeDirectory As CatScriptLibraryType

The thing is that catScriptLibraryTypeDirectory is a pre-defined constant (an "alias" in CatScriptLibraryType enumeration to be exact) and you do not need to redefine it in any way. Just use it "as is":

aScript.ExecuteScript("C:\temp", INFITF.CatScriptLibraryType.catScriptLibraryTypeDirectory, "Test.CATScript", "CATMain", aParam)

Cornell Chamberlain

RE: Trouble calling CatScript from VB.Net
(in response to Cornell Chamberlain)
Thank you! That was what I was missing...INFITF.CatScriptLibraryType.

I should have known it was something simple...just sailing in un-charted waters for me and I missed it. Everything is working great now, this will save me a ton of time.

Thanks,

C-