So is your problem that the instance returned by the repository for your Model is just an uninitalized COM object i.e., if you went:
model = m_Repository.Models.GetAt(0) help(model) Do you end up seeing something like: Help on __ComObject in module System in mscorlib, Version=2.0.0.0, Culture=neutr al, PublicKeyToken=b77a5c561934e089 | CreateObjRef(...) | ObjRef CreateObjRef(self, Type requestedType) | Equals(...) | bool Equals(self, object obj) | Finalize(...) | Finalize(self) | GetHashCode(...) | int GetHashCode(self) | GetLifetimeService(...) | object GetLifetimeService(self) | GetType(...) | Type GetType(self) | InitializeLifetimeService(...) | object InitializeLifetimeService(self) | MemberwiseClone(...) | MarshalByRefObject MemberwiseClone(self, bool cloneIdentity) | object MemberwiseClone(self) | ToString(...) | str ToString(self) | __init__(...) | x.__init__(...) initializes x; see x.__class__.__doc__ for signature | x.__init__(...) initializes x; see x.__class__.__doc__ for signature With none of the additional members you expected that Model to expose...? -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nenad Sent: Thursday, 9 November 2006 10:23 a.m. To: [email protected] Subject: [IronPython] COM Question Hello everybody, I'm using IronPython to automate Enterprise Architect (an UML Tool) via COM. I've translated the VB.Net code from their examples to Python, in order to get hold of some objects (diagrams and elements in diagrams etc.). from System import Console, Object import clr clr.AddReference("EA.dll") from EA import AppClass def RunAll(): App = AppClass() m_Repository = App.Repository m_Repository.OpenFile(r"d:\Projekti\UML\Automotive Testing Exploration.eap") #use the Repository in any way required DumpModel(m_Repository) m_Repository.Exit() m_Repository = None def DumpModel(m_Repository): for idx in range (0, m_Repository.Models.Count): DumpPackage("",m_Repository.Models.GetAt(idx)) Console.WriteLine("" + m_Repository.Models.GetAt(idx).Name) def DumpPackage(Indent, Package): """output package name, then element contents, then process child packages""" Console.WriteLine(Indent + Package.Name) DumpElements(Indent + " ", Package) for idx in range(0,Package.Packages.Count): DumpPackage(Indent + " ", Package.Packages.GetAt(idx)) ..... I get the following error: File C:\IronPython-1.0\Tutorial\ea_go.py, line 35, in Initialize File C:\IronPython-1.0\Tutorial\ea_go.py, line 11, in RunAll File C:\IronPython-1.0\Tutorial\ea_go.py, line 18, in DumpModel File C:\IronPython-1.0\Tutorial\ea_go.py, line 23, in DumpPackage SystemError: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt. So basically it says, m_Repository.Models.GetAt(idx) is not Object, because m_Repository.Models is not initialized. Uuups. It seems IronPython doesn't cope with all COM nuances as well as VB.Net does? I'd bee greatefull for a clue. Thanks to all in advance! Nenad P.S. The corresponding VB.Net code works just fine: Module Module1 Dim f As Object Sub Main() Call Run() End Sub ''class level variable for Repository Public m_Repository As Object Public Sub Run() 'Microsoft.VisualBasic.FileOpen(1, "c:\Temp\ea_mdl.txt", OpenMode.Append) ''create the repository object m_Repository = CreateObject("EA.Repository") ''open an EAP file m_Repository.OpenFile("d:\Projekti\UML\Automotive Testing Exploration.eap") ''use the Repository in any way required DumpModel() ''close the repository and tidy up m_Repository.Exit() m_Repository = Nothing Console.WriteLine("Wir sind durch") End Sub Sub DumpModel() Dim idx As Integer For idx = 0 To m_Repository.Models.Count - 1 DumpPackage("", m_Repository.Models.GetAt(idx)) Next End Sub 'output package name, then element contents, then process child packages Sub DumpPackage(ByVal Indent As String, ByVal Package As Object) Dim idx As Integer Console.WriteLine(Indent + Package.Name) 'WriteLine(Indent + Package.Name) DumpElements(Indent + " ", Package) For idx = 0 To Package.Packages.Count - 1 DumpPackage(Indent + " ", Package.Packages.GetAt(idx)) Next End Sub ..... End Module _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
