cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Using VB API with Python

sndong-mefane
5-Regular Member

Using VB API with Python

I am trying to use the VB API using Python, but I have trouble importing the IpfcAsyncConnection module.

the PRO_COMM_MSG_EXE environment variable is correctly set, and I ran "vb_api_register.bat" already.

As a result It works perfectly with the excel vb.application and vb.net.

The Python code is as follows:

 

import win32com.client as win32

asyncconn = win32.gencache.EnsureDispatch("pfcls.pfcAsyncConnection")

conn = asyncconn.Connect(None,None,None,None)

session = conn.Session

mdlname = session.CurrentModel.FileName;

print mdlname

 

but I get the following error:

 

File "C:\Anaconda\lib\site-packages\win32com\client\makepy.py", line 320, in

GenerateChildFromTypeLibSpec

__import__("win32com.gen_py." + dir_name + "." + child)

ImportError: No module named IpfcAsyncConnection

 

Anything?Anyone???

 

Stephane

2 REPLIES 2

Adding a picture

Really late, but here is a small example how I did it.


from win32com.client.dynamic import Dispatch as dynDis

cAC = dynDis('pfcls.pfcAsyncConnection')

aC = cAC.Connect("", "", ".", 5)

Top Tags