Emre CETIN via python-win32 wrote: > Hi, I've been looking for a solution to this question for some time > now. Hopefully you could help me out. There's a program (Golden > Software Surfer) that I have successfully automated using Python COM. > I normally am able to control every portion I need. The part I have > trouble accessing is under its "Property Manager". Even though I am > using the description provided in the software's documents & help > files I get an error saying: > > AttributeError: '<win32com.gen_py.Surfer 13 Type Library.IShape > instance at 0x2327715907232>' object has no attribute 'ShowColorScale' > > "ShowColorScale" is just an example of one property/method in the > Property Manager window. > > Here is the example code I have been working with: > |importwin32com.client srf > =win32com.client.gencache.EnsureDispatch('Surfer.Application')Plot=srf.Documents.Add(1)srf.Visible=TrueMapFrame1=Plot.Shapes.AddImageMap(GridFileName="C:/test.grd")ImageLayer1=MapFrame1.Overlays(1)ImageLayer1.ShowColorScale=True# > this is where i get the error|
The problem here, I think, is that ShowColorScale is a property of the IContourMap interface, but you've been given an IShape interface. One of the issues about COM is that some objects implement many different interfaces, and you have to know which interface to ask for to get the methods and properties you want. The answer, as the old poster suggested, is to query the IShape object for its IContourMap interface. It shouldn't be very much more complicated than this: ImageMap1 = ImageLayer1.CastTo( "IContourMap" ) ImageMap1.ShowColorScale = True -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32