sudeepjd Posted January 16, 2021 Share Posted January 16, 2021 (edited) I am looking for a way to interface AutoIT and PTC Creo using the Creo VB API COM object. I am able to do this with VBScript and in theory should also be able to replicate the same into AutoIT as well. However, For some reason, the connection does not seem be made from the Autoit script but is able to be made with VBScript. Below is my working VBScript. Dim asynconn, conn, session Set asynconn = CreateObject("pfcls.pfcAsyncConnection") MsgBox TypeName(asynconn), 0, "COM Type" Set conn = asynconn.Connect("", "", ".", 5) 'Set conn = asynconn.Start("C:\Program Files\PTC\Creo 4.0\M090\Parametric\bin\parametric.exe",".") MsgBox TypeName(conn), 0, "Connection Type" Set sess = conn.session MsgBox TypeName(sess), 0, "Session Type" It opens a connection to the COM object in Creo, and message box outputs the variable types. Below is my NOT working AutoIT Script: Local $asynconn, $conn, $session $asynconn = ObjCreate("pfcls.pfcAsyncConnection") MsgBox(0, "COM Type",ObjName($asynconn)) $conn = $asynconn.Connect("", "", ".", 5) ;$conn = $asynconn.Start("C:\Program Files\PTC\Creo 4.0\M090\Parametric\bin\parametric.exe", ".") MsgBox(0, "Connection Type", ObjName($conn)) $session = $conn.Session Msgbox(0, "Session Type", ObjName($session)) The connection on the $conn object is not being made, even if I start Creo or try connecting to an existing session. I know that there is probably a very few people who would be able to replicate this (those who have access to Creo), but would really appreciate help if someone has any ideas as to why this could be happening. Thanks. Sudeep. Edited January 16, 2021 by sudeepjd Link to comment Share on other sites More sharing options...
Werty Posted January 16, 2021 Share Posted January 16, 2021 First, wait for more skilled members to chime in before listening to me Second, shouldnt there be () behind the $session = $conn.Session() (this is the point where you should listen to others 😛 ) Third, COM is broken in later versions of AutoIt (above version 3.3.12,) i have scripts that doesnt work in 3.3.14.5, i have to revert autoit back to version 3.3.12 or 3.3.10 before they work, though many scripts involving COM does work in newer versions, but some dont. Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
sudeepjd Posted January 16, 2021 Author Share Posted January 16, 2021 @Werty Thanks for taking a look. Session is a property and not a method per the documentation.. I did try both though.. Thanks for the tip on trying an older version of AutoIT. Will check and see if I can get that to work. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 16, 2021 Share Posted January 16, 2021 @sudeepjd Since you are working with COM, you should insert a COM error handler (AutoIt.Error) to see if something went wrong during the connection with Creo Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
sudeepjd Posted January 16, 2021 Author Share Posted January 16, 2021 @FrancescoDiMuro I am executing with the SCite editor. It should give me a COM error on the Console right if there is one.. But this justs returns the $conn as a String instead of an Object.. Whereas on the VBScript it returns the Object. Even if I hardcode the $conn as a Boolean it converts it to a String.. which is weird since I am expecting an Object. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 16, 2021 Share Posted January 16, 2021 @sudeepjd If you don't set a COM error handler in your script, than your script just fails and tells you that a particular variable is not an object, for example. Did you trying to pass Null values instead of blank strings to the .Connect() function? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
MDP Posted November 14, 2023 Share Posted November 14, 2023 @sudeepjd - Did you ever find a resolution to this issue? I'm currently working on the same problem (trying to connect AutoIT scripts to Creo Parametric). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now