![]() |
Problems automating Sigmaplot via COM
Hi everybody,
I try to use python2.2 to automate Sigmaplot 8 via the COM interface. I can fill data into a worksheet, but have problems to create a graph :-( When I use the CreateGraphWizard method I always get the error message: "com_error: (-2147352567, 'Exception occurred.', (65535, 'SigmaPlot 8.0', 'Invalid error bar source argument.', None, 0, 0), None)" However, the type of graph I'm trying to create doesn't have error bars! Any idea what's going wrong? Many thanks, Axel Kowald ================================================== =================== #!/usr/bin/env python # # Simple example how to create a Sigmaplot diagram automatically. # 7.2003 A.Kowald # from win32com.client import Dispatch app = Dispatch("SigmaPlot.Application") app.Width = 800 # desired width & height of main window app.Height = 600 app.Visible = True # create notebook and automatically one section with worksheet app.Notebooks.Add # the NotebookItems of the "ActiveDocument" (Notebook) have now 3 items: print app.ActiveDocument.NotebookItems.Count # Item 0 (ItemType 7) = The notebook itself # Item 1 (ItemType 3) = Section 1 # Item 2 (ItemType 1) = Data 1 in Section 1 # Lets name them, so we can refer to them by name. app.ActiveDocument.NotebookItems(0).Name = "MyBook" app.ActiveDocument.NotebookItems(1).Name = "MySection" app.ActiveDocument.NotebookItems(2).Name = "MyData" app.ActiveDocument.NotebookItems.Add(2) # Add graphic page app.ActiveDocument.NotebookItems(3).Name = "MyGraph" dataTab = app.ActiveDocument.NotebookItems("MyData").DataTab le # 3 methods are available for data manipulation: # Cell(x,y,value) 0 based # PutData(1D/2Darray, left,top) # 1D/2Darray = GetData(left,top,right,bottom) dataTab.Cell(0,0,17) # puts 17 in the top left corner d = [[1,2,3],[2,4,6]] # col1 = 1,2,3 col2 = 2,4,6 dataTab.PutData(d,0,0) rect = dataTab.GetData(0,0,2,2) # Get 3x3 tuple # Adding column names (name,left,top,width,height=-1) dataTab.NamedRanges.Add('X',0,0,1,-1) dataTab.NamedRanges.Add('Y',1,0,1,-1) # Now lets plot the data graphPage = app.ActiveDocument.NotebookItems("MyGraph") graphPage.CreateWizardGraph("Vertical Bar Chart","Simple Bar","XY Pair",[0,1]) #app.Quit # stop COM server |
| All times are GMT. The time now is 08:47 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.