Problems automating Sigmaplot via COM

Discussion in 'Python' started by Axel Kowald, Jul 27, 2003.

  1. Axel Kowald

    Axel Kowald Guest

    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").DataTable

    # 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
    Axel Kowald, Jul 27, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Domino

    Automating Word

    Domino, Dec 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    406
    Domino
    Dec 8, 2003
  2. Mills
    Replies:
    0
    Views:
    4,569
    Mills
    Jun 14, 2004
  3. Matthew MacDonald

    Automating Outlook 2000

    Matthew MacDonald, Aug 31, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    483
    Matthew MacDonald
    Oct 11, 2004
  4. Cliff

    Problems automating inVBA

    Cliff, Mar 14, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    1,137
    Cliff
    Mar 14, 2008
  5. Daniel Berger
    Replies:
    1
    Views:
    102
    Daniel Berger
    Jul 10, 2007
Loading...

Share This Page