Hello ----- Original Message ----- From: "bob gailer" <[EMAIL PROTECTED]> To: "Albert Strasheim" <[EMAIL PROTECTED]> Cc: <python-win32@python.org> Sent: Friday, January 04, 2008 11:15 AM Subject: Re: [python-win32] COM automation: problem accessing property of derived object obtained from collection
> Albert Strasheim wrote: >> Hello all >> >> I'm new to the world of COM automation with Python, so please bear with >> me. >> >> I'm trying to automate Golden Software's Surfer 8 [1] using Python. >> >> The basics seems to be working fine, but I'm running into a problem when >> dealing with a collection containing instances of an object derived from >> a base object. >> >> The code looks as follows. Judging from the VBScript examples included >> with Surfer > Which VBScript examples? The one I looked at (CONTOURFILL.BAS) uses > Overlays to access Levels: > > Set MapFrame = Doc.Shapes.AddContourMap(GridFileName:=Path+"demogrid.grd") > 'Fill Contours > MapFrame.Overlays(1).FillContours = True > 'Set the colors to be gradational from green to blue > Set Levels = MapFrame.Overlays(1).Levels > >> , it should work. >> >> from win32com.client import constants, Dispatch >> srf = Dispatch("Surfer.Application") >> plot = srf.Documents.Add(constants.srfDocPlot) >> mapframe = plot.Shapes.AddContourMap(GridFileName=outGrid) >> contourmap = mapframe .Overlays.Item(1) >> # the next line breaks >> print contourMap.Levels As far as I can tell, the VBScript example you posted does the same thing as my Python code. Translating the CONTOURFILL.BAS to Python: from win32com.client import constants, Dispatch srf = Dispatch("Surfer.Application") doc = srf.Documents.Add(constants.srfDocPlot) mapFrame = doc.Shapes.AddContourMap(GridFileName=outGrid) mapFrame.Overlays(1).FillContours = True This fails with: Traceback (most recent call last): File "surfer.py", line 8, in <module> mapFrame.Overlays(1).FillContours = True File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 462, in __setattr__ raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) AttributeError: '<win32com.gen_py.Surfer 8 Type Library.IShape instance at 0x22543976>' object has no attribute 'FillContours' Looks like the same issue as with Levels. Cheers, Albert _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32