Hello, Our team uses Visual Basic for Rhapsody Automation,
but we now would like to use Python. But it seems to be IMPOSSIBLE.
Indeed, it seems that there is no Polymorphism in Python so that when i get
back
a daughter instance Class, it does not not work, i continue to have the
corresponding Mother Class.
Exemple:
Here is my code:
The Application used is "Rhapsody"
import pythoncom # Window word wrapper for Rhapsody
import win32com.client # Window word wrapper for Rhapsody
import sys
class TestRhapsody(object):
def connectRhapsody(self):
print "connecting to Rhapsody.."
self.rhapsody =
win32com.client.gencache.EnsureDispatch("Rhapsody.Application")
self.project = self.rhapsody.activeProject()
if self.project == None :
raise Exception("Load a Rhapsody project!")
print "OK"
def listAllLanguageTypes(self):
theIRPModelElement =
self.project.findNestedElementRecursive("T_Boolean", "Type")
print theIRPModelElement.getFullPathName()
print theIRPModelElement.name
# HERE IS THE ERROR: The theIRPModelElement is a "IRPType" which is
# a specialization of a IRPModelElement, but Python continue to see it
like an IRPModelElement
print "Declaration : %s\n" % (theIRPModelElement.declaration)
def test():
try:
thePatch = TestRhapsody()
thePatch.connectRhapsody()
thePatch.listAllLanguageTypes()
except Exception ,err:
print "ERROR ! \n %s"%( str (err))
if __name__ == '__main__':
test()
I got the following message:
'<win32com.gen_py.47DBF9D5-F318-11D2-B825-00104B3E6572x0x1x0.IRPModelElement
instance at 0x59532032>'
object has no attribute 'declaration'
>>>
Here is the Py32Com Wrapper extract:
class IRPModelElement(DispatchBaseClass):
"""IRPModelElement Interface"""
CLSID = IID('{57DBF9EF-F318-11D2-B825-00104B3E6572}')
coclass_clsid = IID('{57DBF9F0-F318-11D2-B825-00104B3E6572}')
class IRPType(DispatchBaseClass):
"""IRPType Interface"""
CLSID = IID('{EB754AE3-0D76-11D3-8E4D-0060080B70BC}')
coclass_clsid = IID('{EB754AE4-0D76-11D3-8E4D-0060080B70BC}')
# Result is of type IRPFlowchart
def addActivityDiagram(self):
"""method addActivi
_prop_map_get_ = {
...
"currentDirectory": (110, 2, (8, 0), (), "currentDirectory", None),
"declaration": (803, 2, (8, 0), (), "declaration", None),
...
---------------------------------
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail _______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32