From: Ed B. <kit...@ya...> - 2008-08-25 16:37:58
|
Looks like you need to file a bug report with the AutoPLANT people. Of course anything you can do to narrow down the problem will increase the likelihood of it getting fixed. Unfortunately unless you are using the latest version, and whoever makes AutoPLANT releases frequent patches, you wont get any short term benefits. Isn't proprietary software great! In the mean time - if you can figure out what part specifically is causing the error, and how it is getting loaded - you can just check for it and temporarily unload that part before accessing the document. There is an Application.UnloadARX function for those, and I think you can kill VBA and Lisp scripts too. Good luck! Ed Blake --- On Fri, 8/22/08, Anthony Tuininga <ant...@gm...> wrote: > From: Anthony Tuininga <ant...@gm...> > Subject: Re: [comtypes-users] No such interface supported? > To: com...@li... > Date: Friday, August 22, 2008, 9:37 PM > On Fri, Aug 22, 2008 at 3:01 AM, Thomas Heller > <th...@ct...> wrote: > > Anthony Tuininga schrieb: > >> > >> The traceback doesn't produce anything useful, > unfortunately. > >> > >> Traceback (most recent call last): > >> File "CreateSchedule.py", line 17, in > <module> > >> modelSpace = app.ActiveDocument.ModelSpace > >> _ctypes.COMError: (-2147467262, 'No such > interface supported', (None, > >> None, None, 0, None)) > >> > >> I've tried and app.ActiveDocument returns > something but any attempt to > >> reference ModelSpace or anything else that looks > like an object > >> doesn't appear to work. > >> > >> As for debugging, what sort of debugger were you > referring to? I'm not > >> familiar with the comtypes architecture yet so > some pointers as to > >> where to look would be helpful. I already saw the > "QueryInterface" > >> call but didn't notice anything calling that > before the exception took > >> place. Any suggestions on where to look next would > be helpful. Thanks! > > > > I debug with pdb from the command line; other > debuggers may work as well. > > Here is an commented example stepping through > app.Documents where app is > > a com pointer to MS word: > > > > C:\sf\comtypes>py25 > > Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC > v.1310 32 bit (Intel)] on win32 > > Type "help", "copyright", > "credits" or "license" for more > information. > >>>> from comtypes.client import CreateObject > >>>> word = > CreateObject("Word.Application") > >>>> word.Documents > > <POINTER(Documents) ptr=0x254c4c at b8ca30> > >>>> type(word).Documents > > <property object at 0x030928A0> > >>>> type(word).Documents.fget > > <COM method offset 11: WinFunctionType at > 0x0304C5D0> > >>>> type(word).Documents.fget.restype > > <class 'ctypes.HRESULT'> > >>>> type(word).Documents.fget.argtypes > > (<class > 'ctypes.LP_POINTER(Documents)'>,) > >>>> > > > > So, 'word.Documents' is a property, and its > fget function is a WinFunctionType > > (a ctypes implemented 'callback' function) > that wraps the native COM call. > > We can call the fget function with the word object to > retrieve the 'Documents' > > attribute; this is what happens internally in Python > when 'word.Documents' is > > evaluated: > > > >>>> type(word).Documents.fget(word) > > <POINTER(Documents) ptr=0x271994 at b8ca30> > >>>> > > > > Now stepping through this with pdb. We cannot step > through the actual WinFunctionType > > call with the Python debugger since this is > implemented in C, but we see the processing > > in Python to retrieve the return value. > > > >>>> pdb.run("word.Documents") > >> <string>(1)<module>() > > (Pdb) s > > --Call-- > >> > c:\sf\comtypes\comtypes\client\__init__.py(38)wrap_outparam() > > -> def wrap_outparam(punk): > > (Pdb) l > > 33 import comtypes.gen > > 34 > > 35 ### for testing > > 36 ##gen_dir = None > > 37 > > 38 -> def wrap_outparam(punk): > > 39 > logger.debug("wrap_outparam(%s)", punk) > > 40 if not punk: > > 41 return None > > 42 if punk.__com_interface__ == > comtypes.automation.IDispatch: > > 43 return GetBestInterface(punk) > > (Pdb) > > 44 return punk > > 45 > > 46 def GetBestInterface(punk): > > 47 """Try to QueryInterface a > COM pointer to the 'most useful' > > 48 interface. > > 49 > > 50 Get type information for the provided > object, either via > > 51 IDispatch.GetTypeInfo(), or via > IProvideClassInfo.GetClassInfo(). > > 52 Generate a wrapper module for the typelib, > and QI for the > > 53 interface found. > > 54 """ > > (Pdb) > > > > Now we can single-step through the code in the > wrap_outparam() function. > > Hope that helps, > > It helps demonstrate that the problem is much deeper. :-) I > tried > using pdb as specified and app.ActiveDocument works as you > suggested > with wrap_outparam() being shown in the trace. When I use > app.ActiveDocument.ModelSpace then it jumps immediately to > the __del__ > method since the pointer in question is being destroyed. > > FYI, I uninstalled AutoCAD and AutoPLANT entirely and then > reinstalled > both and all worked -- until I installed AutoPLANT > Structural (an > addon to AutoPLANT which I require) and things broke again. > So its > something deep inside COM that is not working as expected. > I'll keep > poking about to see if I can figure out more. > > Anthony > > > -- > > Thanks, > > Thomas > > > > > ------------------------------------------------------------------------- > > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > > Build the coolest Linux based applications with Moblin > SDK & win great prizes > > Grand prize is a trip for two to an Open Source event > anywhere in the world > > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > comtypes-users mailing list > > com...@li... > > > https://lists.sourceforge.net/lists/listinfo/comtypes-users > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > Build the coolest Linux based applications with Moblin SDK > & win great prizes > Grand prize is a trip for two to an Open Source event > anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > comtypes-users mailing list > com...@li... > https://lists.sourceforge.net/lists/listinfo/comtypes-users |