Using ExecuteScriptV6 method to launch VSTA project in 3Dx

Mike Berry

Using ExecuteScriptV6 method to launch VSTA project in 3Dx

As the title says, I am trying to launch a VSTA project in 3Dx from a VBScript using the PLMScriptService.ExecuteScriptV6 API but I haven't had any success.  I have looked at the help docs and searched online but I have only found examples for launching CATScript or VBA, nothing for a VSTA project.  VSTA is definitely supported because the iType enumeration has a value for it (see below).  I suspect my issue might be the iProgramName argument but I'm not sure what to pass for VSTA (I have tried passing the Assembly, the ThisApplication class, a new public module name, etc but nothing works)

Has anyone successfully used this?  If so, please share how you did it or maybe a code snippet.   

Thanks!

Mike

 

Function ExecuteScriptV6(iPLMEntity As PLMEntity, iType As CatScriptLibraryType, iProgramName As String, iFunctionName As String, iParameters() As Variant)

 

Enum CatScriptLibraryType

Const catScriptLibraryTypeDirectory = 1

Const catScriptLibraryTypeDocument = 0

Const catScriptLibraryTypeVBAProject = 2

Const catScriptLibraryTypeVSTAProject = 3

 

Mike Berry

RE: Using ExecuteScriptV6 method to launch VSTA project in 3Dx
(in response to Mike Berry)

My co-worker, Lalaso Pingale gets credit for figuring this out!  I am posting back in case anyone else faces this problem since it is NOT untuitive and not documented.

So the key is to pass the name of the sub you are trying to run (ie "Macro_Test") as the iProgramName argument and then pass an empty string as the iFunctionName argument.  This doesn't match the arguments pattern when you are launching CATScript or VBA so it isn't obvious.  In both those cases the iFunctionName is the name of the sub you are calling so its odd that VSTA works like this.  You would think they would have expected the iProgramName to be an empty string and the iFunctionName to be the sub you are calling.

 

Procedure Signature:

Function ExecuteScriptV6(iPLMEntity As PLMEntity, iType As CatScriptLibraryType, iProgramName As String, iFunctionName As String, iParameters() As Variant)

 

Example:

objScriptSrv.ExecuteScriptV6 objPLMEntity, catScriptLibraryTypeVSTAProject, "Macro_Test", "", params

Little Cthulhu

RE: Using ExecuteScriptV6 method to launch VSTA project in 3Dx
(in response to Mike Berry)

Thanks for sharing.

 

What version of 3dX does this apply to?

Mike Berry

RE: Using ExecuteScriptV6 method to launch VSTA project in 3Dx
(in response to Little Cthulhu)

This was in 2019x.  If it changed in a later release that would be troubling too. 

Mike