473,473 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

win32com problem

I'm interacting with a third party application using python and com.
However having problems and don't know what to look at next to resolve
the issue.

The app. can be driven by VBS. The following VBS code works:

Set Synergy = CreateObject("synergy.Synergy")
Synergy.OpenProject "D:/temp/project.mpi"
Synergy.Project.OpenItemByName "test_bar_3d_6l_pc1", "Study"
Set Tet = Synergy.StudyDoc.GetFirstTet()
While Not Tet Is Nothing
Str = Tet.ConvertToString() + " "
Set Tet = Synergy.StudyDoc.GetNextTet(Tet)
MsgBox Str
WEnd

This prints "TE1" "TE2" etc
The "same" code in python returns <COMObject <unknown>with each call
to the GetNextTet method.

import win32com.client
from win32com.client import Dispatch
Synergy = win32com.client.Dispatch("synergy.Synergy")
Synergy.OpenProject("D:/temp/project.mpi")
Synergy.Project.OpenItemByName("test_bar_3d_6l_pc1 ", "Study")
tet = Synergy.StudyDoc.GetFirstTet
while tet:
print str(tet)
tet = Synergy.StudyDoc.GetNextTet(tet)

Any clues on what I'm doing wrong, or how to investigate whether there
is a bug in win32com or in the third party apps com implementation.

Oct 25 '06 #1
7 4792
cf********@gmail.com wrote:
I'm interacting with a third party application using python and com.
However having problems and don't know what to look at next to resolve
the issue.

The app. can be driven by VBS. The following VBS code works:

Set Synergy = CreateObject("synergy.Synergy")
Synergy.OpenProject "D:/temp/project.mpi"
Synergy.Project.OpenItemByName "test_bar_3d_6l_pc1", "Study"
Set Tet = Synergy.StudyDoc.GetFirstTet()
While Not Tet Is Nothing
Str = Tet.ConvertToString() + " "
Set Tet = Synergy.StudyDoc.GetNextTet(Tet)
MsgBox Str
WEnd

This prints "TE1" "TE2" etc
The "same" code in python returns <COMObject <unknown>with each call
to the GetNextTet method.

import win32com.client
from win32com.client import Dispatch
Synergy = win32com.client.Dispatch("synergy.Synergy")
Synergy.OpenProject("D:/temp/project.mpi")
Synergy.Project.OpenItemByName("test_bar_3d_6l_pc1 ", "Study")
tet = Synergy.StudyDoc.GetFirstTet
tet = Synergy.StudyDoc.GetFirstTet(), perhaps?
while tet:
print str(tet)
tet = Synergy.StudyDoc.GetNextTet(tet)

Any clues on what I'm doing wrong, or how to investigate whether there
is a bug in win32com or in the third party apps com implementation.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Oct 25 '06 #2
tet = Synergy.StudyDoc.GetFirstTet(), perhaps?

com_error: (-2147352573, 'Member not found.', None, None)

Sorry, should have mentioned that I tried that already. Any thoughts on
how to establish if the problem is with win32com or the 3rd party app?

Oct 25 '06 #3
Have you tried late binding? Does late binding produce the same error?

Regards,

Aries

cf********@gmail.com wrote:
I'm interacting with a third party application using python and com.
However having problems and don't know what to look at next to resolve
the issue.

The app. can be driven by VBS. The following VBS code works:

Set Synergy = CreateObject("synergy.Synergy")
Synergy.OpenProject "D:/temp/project.mpi"
Synergy.Project.OpenItemByName "test_bar_3d_6l_pc1", "Study"
Set Tet = Synergy.StudyDoc.GetFirstTet()
While Not Tet Is Nothing
Str = Tet.ConvertToString() + " "
Set Tet = Synergy.StudyDoc.GetNextTet(Tet)
MsgBox Str
WEnd

This prints "TE1" "TE2" etc
The "same" code in python returns <COMObject <unknown>with each call
to the GetNextTet method.

import win32com.client
from win32com.client import Dispatch
Synergy = win32com.client.Dispatch("synergy.Synergy")
Synergy.OpenProject("D:/temp/project.mpi")
Synergy.Project.OpenItemByName("test_bar_3d_6l_pc1 ", "Study")
tet = Synergy.StudyDoc.GetFirstTet
while tet:
print str(tet)
tet = Synergy.StudyDoc.GetNextTet(tet)

Any clues on what I'm doing wrong, or how to investigate whether there
is a bug in win32com or in the third party apps com implementation.
Oct 25 '06 #4
At Tuesday 24/10/2006 22:15, cf********@gmail.com wrote:
>Set Tet = Synergy.StudyDoc.GetFirstTet()
tet = Synergy.StudyDoc.GetFirstTet
Can you see the difference...?
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ˇgratis!
ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar
Oct 25 '06 #5
At Tuesday 24/10/2006 23:20, cf********@gmail.com wrote:
tet = Synergy.StudyDoc.GetFirstTet(), perhaps?

com_error: (-2147352573, 'Member not found.', None, None)

Sorry, should have mentioned that I tried that already. Any thoughts on
how to establish if the problem is with win32com or the 3rd party app?
Run it on the debugger step by step, and inspect all the intermediate objects.
Synergy.StudyDoc might be a function, by example, so you should add
another pair of ().
This is not obvious looking at the VB code.
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ˇgratis!
ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar
Oct 25 '06 #6

Gabriel Genellina wrote:
Run it on the debugger step by step, and inspect all the intermediate objects.
Synergy.StudyDoc might be a function, by example, so you should add
another pair of ().
This is not obvious looking at the VB code.
(Sorry, tied up this arvo so I could respond to your suggestion
earlier.)

Here's part of a debug session.

(Pdb) type(Synergy.StudyDoc)
<type 'instance'>

(Pdb) type(Synergy.StudyDoc.GetFirstTet)
<type 'instance'>

(Pdb) Synergy.StudyDoc.GetFirstTet
<COMObject <unknown>>

(Pdb) dir (Synergy.StudyDoc)
['_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum',
'_Release_', '__A
ttrToID__', '__LazyMap__', '__call__', '__cmp__', '__doc__',
'__getattr__', '__g
etitem__', '__init__', '__int__', '__len__', '__module__',
'__nonzero__', '__rep
r__', '__setattr__', '__setitem__', '__str__', '_builtMethods_',
'_enum_', '_fin
d_dispatch_type_', '_get_good_object_', '_get_good_single_object_',
'_lazydata_'
, '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_',
'_print_details_
', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_']

(Pdb) dir (Synergy.StudyDoc.GetFirstTet)
['_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum',
'_Release_', '__A
ttrToID__', '__LazyMap__', '__call__', '__cmp__', '__doc__',
'__getattr__', '__g
etitem__', '__init__', '__int__', '__len__', '__module__',
'__nonzero__', '__rep
r__', '__setattr__', '__setitem__', '__str__', '_builtMethods_',
'_enum_', '_fin
d_dispatch_type_', '_get_good_object_', '_get_good_single_object_',
'_lazydata_'
, '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_',
'_print_details_
', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_']

I'm pretty green with this kind of introspection (but willing to dig in
and learn). With the VBS code seems like GetFirstTet is a method of
StudyDoc that returns a variable which converted to string yields "TE1"
etc. But that doesn't seem to be true for python.

Is there any other way I can find out what attributes etc are available
to the GetFirstTet instance?

The type library is not supplied with the app. so if my basic
understanding is correct, I can't early bind.

Oct 25 '06 #7
Problem solved.

Turns out it was a problem of mistranslating VBS code to Python.

The PYTHON line "print str(tet)" casts tet to a string and prints. This
is what I thought the VBS line "Str = Tet.ConvertToString()" was doing.
But of course "ConvertToString()" is a method of a Tet instance. So in
python the correct line should have been "print tet.ConvertToString".

Learning all the time.

Oct 25 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Justin Stockton | last post by:
I recently upgraded from ActivePython 2.2.2 to ActivePython 2.3.2 and I'm running into an issue importing the win32com.client module. Before installing the new version, I made sure to properly...
3
by: RJ | last post by:
Hi, I've been going over the Quick Start to Client side COM and Python and many other sources, but cannot find an example that will get my com/ActiveX .ocx USB device driver imported. The Excel...
1
by: Cristian Hasbun from Chile | last post by:
I need a win32com guru please... i'm not python expert, but i understand mi trouble... Requirements: Hook EyesWeb 3.2.0 (http://www.eyesweb.org) COM Module with Python 2.0.1 i used win32com...
1
by: Patrick | last post by:
I am investigating a web-based app wherein I wanted to provide html form frontends to an Excel spreadsheet sitting on a MS Windows server; with each authenticated HTTP user having thier own...
0
by: goermezer | last post by:
Hello, I have some problems to automate a CAD (computer aided design) Software called CATIA V5 from Dassault Systemes. CATIA V5 has a builtin VB-Editor like Word, Excel, … and registers itself...
0
by: mb3242 | last post by:
Hello, I'm trying to use win32com to call a method in a COM object. I'm having a problem with Python choosing the wrong type when wrapping up lists into VARIANTs. The function I'm trying to call...
2
by: Sibylle Koczian | last post by:
Hello, I've installed Python 2.4 and the win32 extensions, using administrator rights, under Windows XP in "C:\Programme". As this is a directory without spaces I didn't expect any problems. But...
1
by: koia | last post by:
Hi, I have a problem with adding attributes to a Line in an Excel drawing using the Python win32com interface. From recording in Excel I get the Macro: Sub Makro1()...
3
by: tyler.schlosser | last post by:
Hi there, I am trying to launch a program called AmiBroker using the command: AB = win32com.client.Dispatch("Broker.Application") However, I have a dual-core CPU and would like to launch two...
1
by: SPJ | last post by:
Sorry, forgot to mention Subject in my earlier post, hence reposting. ------------ I am writing a script which need's to convert an excel file to csv (text) format. For that I am using the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.