OriginPro
 
Loading...
Searching...
No Matches
originpro.project Namespace Reference

Functions

Union[WBook, MBooknew_book (type=_WBOOK_TYPE, lname='', template='', hidden=False)
 
GPage new_graph (lname='', template='', hidden=False)
 
IPage new_image (lname='', hidden=False)
 
Notes new_notes (name='')
 
Union[WSheet, MSheetnew_sheet (type=_WBOOK_TYPE, lname='', template='', hidden=False)
 
Union[WBook, MBook, GPage, IPageget_page (type, index=0)
 
Union[WSheet, MSheetfind_sheet (type=_WBOOK_TYPE, ref='')
 
Union[WBook, MBookfind_book (type=_WBOOK_TYPE, name='')
 
GPage find_graph (name='')
 
IPage find_image (name='')
 
Notes find_notes (name='')
 
Union[WBook, MBookload_book (fname)
 
List[GPagegraph_list (select='f', inc_embed=False)
 
Union[WBook, MBook, GPage, IPagepages (type_='')
 
def open (file, readonly=False, asksave=False)
 
def new (asksave=False)
 
def save (file='')
 

Detailed Description

originpro
A package for interacting with Origin software via Python.
Copyright (c) 2020 OriginLab Corporation

Function Documentation

◆ find_book()

Union[WBook, MBook] originpro.project.find_book (   type = _WBOOK_TYPE,
  name = '' 
)
Find the work or matrixbook by name (short name) and return a WBook or MBook object.

Parameters:
    type (str): Specify 'w' for WBook object or 'm' for MBook object
    name (str or int): Name of book. If empty, then active book. If int, then from the collection of books by index

Returns:
    (WBook or MBook or None)

Examples:
    wb = op.find_book()#if active book is a workbook
    mb = op.find_book('m', 'MBook2')

◆ find_graph()

GPage originpro.project.find_graph (   name = '')
Find the named graph (short name) and return a GPage object.

Parameters:
    name (str or int) Name of graph. If empty, then active graph, if int, then index into graph page collection

Returns:
    (GPage or None)

Examples:
    g = op.find_graph('Graph2')
    glayer=op.find_graph()[0]

◆ find_image()

IPage originpro.project.find_image (   name = '')
Find the named Image Window and return a IPage object.

Parameters:
    name (str or int) Name of Image Window. If empty, then active Image Page, int, then index into Image Page collection

Returns:
    (IPage or None)

Examples:
    import numpy as np
    im = op.find_image('Image1')
    data = im.to_np()
    dataUpsideDown = np.flip(data, 1)
    im.from_np(dataUpsideDown)

◆ find_notes()

Notes originpro.project.find_notes (   name = '')
Find the named Notes Window and return a Notes object.

Parameters:
    name (str) Name of Image window. If empty, then active Notes window.

Returns:
    (Notes or None)

Examples:
    nt1 = op.find_notes('Notes')
    nt2 = op.find_notes()

◆ find_sheet()

Union[WSheet, MSheet] originpro.project.find_sheet (   type = _WBOOK_TYPE,
  ref = '' 
)
Find the Sheet referenced by ref (an Origin range string). Default will return active worksheet.

Parameters:
    type (str): Specify 'w' for WBook object or 'm' for MBook object
    ref (str or int): [book]sheet, an Origin range specification. Can also be just book name to assume active sheet,
                so the following are the same if book has only one sheet
                '[book1]1', '[book1]1!', 'book1'

                You may also pass in an integer for the book index, like 0 for the first book

Returns:
    (WSheet or MSheet or None)

Examples:
    wks1 = op.find_sheet()   #when active book that is a workbook
    wks2 = op.find_sheet('w', '[Book1]Sheet2')   #when you need a specific sheet
    m1 = op.find_sheet('m')   #when active is a matrix book
    m2 = op.find_sheet('m','MBook1')   #when there is only one sheet, use simpler notation
    wks3 = op.find_sheet('w',0)# see if there is any workbook at all

◆ get_page()

Union[WBook, MBook, GPage, IPage] originpro.project.get_page (   type,
  index = 0 
)
get WBook, MBook, GPage, IPage by index
Parameters:
    none
Returns:
    WBook or MBook or GPage or IPage None
Examples:
    w=op.get_page('w', 0)//there should a workbook exist

◆ graph_list()

List[GPage] originpro.project.graph_list (   select = 'f',
  inc_embed = False 
)
Returns a list object of GPages representing graphs in the current folder, graphs open in current folder, or graphs in project.

 Parameters:
    select (str): Specify 'f' for current folder, 'o' for graphs open in current folder, or 'p' for graphs in project
    inc_embed (bool): Include embedded graphs in the list, this is supported for 'p' only

Returns:
    (list) list of GPage objects

Examples:
    graphs1 = op.graph_list('p', True)
    graphs2 = op.graph_list('f')

◆ load_book()

Union[WBook, MBook] originpro.project.load_book (   fname)
Loads a work or matrixbook from file and returns a WBook or MBook object.

Parameters:
    fname (str): File path and name. If file name only, the load from UFF

Returns:
    (WBook or MBook or None)

Examples:
    wb1 = op.load_book('My Analysis Template.ogwu')#from user file folder
    wb2 = op.load_book(op.path('e')+r'Samples\Batch Processing\Peak Analysis.ogw')

◆ new()

def originpro.project.new (   asksave = False)
Starts a new project.

Parameters:
    asksave (bool)P: If True, prompt user to save current project is it is modified

Returns:
    None

Examples:
    op.new()
    op.new(True)

◆ new_book()

Union[WBook, MBook] originpro.project.new_book (   type = _WBOOK_TYPE,
  lname = '',
  template = '',
  hidden = False 
)
Create a new workbook or matrixbook.

Parameters:
    type(str): Specify 'w' for WBook object or 'm' for MBook object
    lname (str): Long Name of the book
    template (str): Template name. May exclude extension. Does not support OGWU files (e.g. analysis templates). In that case, use load_book.
    hidden (bool): True makes newly created book hidden

Returns:
    (WBook or MBook or None)

Examples:
    wb1 = op.new_book()
    wb2 = op.new_book('w', 'My Template')
    mb = op.new_book('m', hidden=True)

See Also:
    load_book

◆ new_graph()

GPage originpro.project.new_graph (   lname = '',
  template = '',
  hidden = False 
)
Create a new empty graph optionally from a template.

Parameters:
    lname (str): Long Name of the graph
    template (str): Template name. May exclude extension. If not specified, use origin.otp.
    hidden (bool): True makes newly created graph hidden

Returns:
    (GPage or None)

Examples:
    g1 = op.new_graph()
    g2 = op.new_graph('My Graph')
    g3 = op.new_graph(template=op.path('e') + '3Ys_Y-Y-Y.otp')

◆ new_image()

IPage originpro.project.new_image (   lname = '',
  hidden = False 
)
Create a new image window

Parameters:
    lname (str): Long Name of the new window
    hidden (bool): True makes newly created window hidden
Returns:
    IPage or None
Examples:
    im = op.new_image()

◆ new_notes()

Notes originpro.project.new_notes (   name = '')
Create a new Notes window

Parameters:
    lname (str): Name of the new window
Returns:
    Notes or None
Examples:
    nt = op.new_notes()

◆ new_sheet()

Union[WSheet, MSheet] originpro.project.new_sheet (   type = _WBOOK_TYPE,
  lname = '',
  template = '',
  hidden = False 
)
Create a new work or matrixbook and return the first sheet as a WSheet or MSheet.

Parameters:
    type (str): Specify 'w' for WBook object or 'm' for MBook object
    lname (str): Long Name of the book
    template (str): Template name. May exclude extension
    hidden (bool): True makes newly created book hidden

Returns:
    (WSheet or MSheet or None)

Examples:
    wks1 = op.new_sheet()
    wks2 = op.new_sheet('w', 'My Template.otwu')
    mxs = op.new_sheet('m', hidden=True)

◆ open()

def originpro.project.open (   file,
  readonly = False,
  asksave = False 
)
Opens an Origin project file.

Parameters:
    file (str): File path and name
    readonly (bool): Opern the file as read-only
    asksave (bool): If True, prompt user to save current project is it is modified

Returns:
    (bool) True if project is successfully loaded

Examples:
    op.open('C:\path\to\My Project.opju')

◆ pages()

Union[WBook, MBook, GPage, IPage] originpro.project.pages (   type_ = '')
All pages in project.
Parameters:
    type_ (str): Page type, can be 'w', 'm', 'g', 'i'
Returns:
    Page Objects
Examples:
    wps=op.pages('w')
    w1=next(wps)
    wshet=w1[0]

◆ save()

def originpro.project.save (   file = '')
Saves the current project. If no file name given, then save to current project file.

Parameters:
    file (str): Path and file name to save the project as. Save to current project file if blank.

Returns:
    (bool) True if project is successfully saved

Examples
    op.save('C:\path\to\My Project.opju')
    op.save()