Classes | |
class | _LTTMPOUTSTR |
Functions | |
def | lt_float (formula) |
def | lt_int (formula) |
def | get_lt_str (vname) |
def | set_lt_str (vname, value) |
def | lt_exec (labtalk) |
def | messagebox (msg, cancel=False) |
def | set_lt_var (name, value) |
def | attach () |
def | detach () |
def | exit () |
def | get_show () |
def | set_show (show=True) |
def | ocolor (rgb) |
def | to_rgb (orgb) |
def | get_file_ext (fname) |
def | get_file_parts (fname) |
def | last_backslash (fpath, action) |
def | path (type='u') |
def | wait (type='r', sec=0) |
def | file_dialog (type, title='') |
def | origin_class (name) |
def | active_obj (name) |
def | color_col (offset=1, type='m') |
def | modi_col (offset=1) |
def | org_ver () |
def | make_DataRange (*args, rows=None) |
def | attrib_key (name) |
def | lt_dict_to_tree (dd, treename, add_tree=False, check_attributes=False) |
def | lt_tree_to_dict (name, add_attributes=False) |
def | lt_empty_tree () |
def | lt_delete_tree (name) |
def | evaluate_FDF (ffname, indepvars, parameters) |
Variables | |
PATHSEP = os.path.sep | |
originpro A package for interacting with Origin software via Python. Copyright (c) 2020 OriginLab Corporation
def originpro.utils.attach | ( | ) |
Attach to exising Origin instance
def originpro.utils.color_col | ( | offset = 1 , |
|
type = 'm' |
|||
) |
Generate Origin's internal OColor to use in data plot's color setting Parameters: offset (int): worksheet column offset to the plot's Y column type (str): 'm' for Colormap, 'n' = Indexing, 'r' = RGB Returns: OColor Examples: plot.color = op.color_col()# use next column to Y as color map values plot.color = op.color_col(1,'n') #use index color, column needs to contain 1,2,3 etc plot.colormap="fire"
def originpro.utils.detach | ( | ) |
Detach Origin instance
def originpro.utils.evaluate_FDF | ( | ffname, | |
indepvars, | |||
parameters | |||
) |
Evaluate FDF function Parameters: ffname (str): Name of the Fitting Function indepvars(list): Independent Variables values, can be list of list if multiple independents parameters(list): Parameter values Returns: A list of Dependent Variable values Examples: vx = [1, 2, 3] vy = op.evaluate_FDF('Gauss', vx, [1, 2, 3, 4])
def originpro.utils.exit | ( | ) |
exit the application
def originpro.utils.file_dialog | ( | type, | |
title = '' |
|||
) |
open a file dialog to pick a single file Parameters: type (str): 'i' for image, 't' for text, 'o' for origin, or a file extension like '*.png' Returns: if user cancel, an empty str, otherwise the selected file path Examples: fn=op.file_dialog('o') fn=op.file_dialog('*.png;*.jpg;*.bmp')
def originpro.utils.get_file_ext | ( | fname | ) |
Given a full path file name, return the file extension. Parameters: fname (str): Full path file name Returns: (str) File extension Examples: ext = op.get_file_ext('C:\path\to\somefile.dat')
def originpro.utils.get_file_parts | ( | fname | ) |
Given a full path file name, return the path, file name, and extension as a Python list object. Parameters: fname (str): Full path file name Returns: (list) Contains path, file name, and extension Examples: parts = op.get_file_parts('C:\path\to\somefile.dat')
def originpro.utils.get_lt_str | ( | vname | ) |
return a LabTalk string variable value. To get LabTalk numeric values, use lt_int or lt_float Examples: #AppData path for the installed Origin >>> op.get_lt_str('%@Y') See Also: lt_int, lt_float
def originpro.utils.get_show | ( | ) |
If the Application is visible or not
def originpro.utils.last_backslash | ( | fpath, | |
action | |||
) |
Add or trim a backslash to/from a path string. Parameters: fpath (str): Path action (str): Either 'a' for add backslash or 't' for trim backslash Returns: (str) Path either with added backslash or without trimmed backslash Examples: >>>op.last_backslash(op.path(), 't')
def originpro.utils.lt_dict_to_tree | ( | dd, | |
treename, | |||
add_tree = False , |
|||
check_attributes = False |
|||
) |
Converts dictionary dd to an xml tree string and sets the value of a LabTalk tree variable to to the xml tree string. If bAddTreeVar is False and the tree variable does not already exist, the tree variable will not be added. Pass True as bAddTreeVar if you want to make sure that the tree variable is added first if it does not exist. Parameters: dd (dictionary) treevarname (str) the name of the tree variable bAddTreeVar If True, the tree variable will be added if it does not exist
def originpro.utils.lt_exec | ( | labtalk | ) |
run LabTalk script
def originpro.utils.lt_float | ( | formula | ) |
get the result of a LabTalk expression Parameters: formula (str): any LaTalk expression Examples: #Origin Julian days value >>>op.lt_float('date(1/2/2020)') #get Origin version number >>>op.lt_float('@V') See Also: get_lt_str, lt_int
def originpro.utils.lt_int | ( | formula | ) |
get the result of a LabTalk expression as int, see lt_float() Examples: >>> op.lt_int('color("green")') See Also: get_lt_str, lt_float
def originpro.utils.lt_tree_to_dict | ( | name, | |
add_attributes = False |
|||
) |
Get Labtalk tree as dict Parameters: name (str): Name of the Labtalk tree add_attributes(bool): add the attributes from the tree as nodes Returns: dict to hold Labtalk tree content Examples: wks = op.new_sheet() data = [1,2,3,4,5] wks.from_list(0, data) wks.from_list(1, data) op.lt_exec('fitlr (1,2)') dd = op.lt_tree_to_dict('fitlr')
def originpro.utils.messagebox | ( | msg, | |
cancel = False |
|||
) |
open a message box Parameters: msg(str): the text to prompt cancel(bool): True if OK Cancel, False if just OK Return: False if has cancel button and user click Cancel Examples: nn = op.messagebox('this is a test', True) if not nn: op.messagebox('you clicked cancel') else: op.messagebox('you click ok')
def originpro.utils.modi_col | ( | offset = 1 | ) |
Generate Origin's internal modifier (uint) value to use in data plot's various setting Parameters: offset (int): worksheet column offset to the plot's Y column Returns: uint Examples: plot.symbol_size = op.modi_col(1)# use next column to Y as symbol size plot.symbol_kind = op.modi_col(2)
def originpro.utils.ocolor | ( | rgb | ) |
convert color to Origin's internal OColor Parameters: rgb: names or index of colors supported in Origin. name index (Red, Green, Blue) 'Black' 1 000,000,000 'Red' 2 255,000,000 'Green' 3 000,255,000 'Blue' 4 000,000,255 'Cyan' 5 000,255,255 'Magenta' 6 255,000,255 'Yellow' 7 255,255,000 'Dark Yellow' 8 128,128,000 'Navy' 9 000,000,128 'Purple' 10 128,000,128 'Wine' 11 128,000,000 'Olive' 12 000,128,000 'Dark Cyan' 13 000,128,128 'Royal' 14 000,000,160 'Orange' 15 255,128,000 'Violet' 16 128,000,255 'Pink' 17 255,000,128 'White' 18 255,255,255 'LT Gray' 19 192,192,192 'Gray' 20 128,128,128 'LT Yellow' 21 255,255,128 'LT Cyan' 22 128,255,255 'LT Magenta' 23 255,128,255 'Dark Gray' 24 064,064,064 it can be in formmat as well, for example, '#f00' for red. when the input is a tuple, it should be if rgb is tuple of intergers between 0 and 255, the color is set by RGB (Red, Green, Blue). Returns: (int) OColor
def originpro.utils.path | ( | type = 'u' | ) |
Returns one of the Origin pre-defned paths: User Files folder, Origin EXe folder, project folder, Project attached file folder. Parameters: type (str): 'u'(User Files folder), 'e'(Origin Exe folder), 'p'(project folder), 'a'(Attached file folder), 'c'(Learning Center) Returns: (str) Contains folder path Examples: uff = op.path() op.open(op.path('c')+ r'Graphing\Trellis Plots - Box Charts.opju')
def originpro.utils.set_lt_str | ( | vname, | |
value | |||
) |
sets a LabTalk string variable value. Examples: fpath = op.file_dialog('*.log') op.set_lt_str('fname', fpath) tmp=op.get_lt_str('fname') print(tmp) See Also: get_lt_str
def originpro.utils.set_lt_var | ( | name, | |
value | |||
) |
sets a LabTalk numeric variable value. This is usually used for setting system variables Example: op.set_lt_var("@IAS",5)#set import using multi-thread for files 5M or larger See Also: lt_float, set_lt_str
def originpro.utils.set_show | ( | show = True | ) |
Show or Hide the Application
def originpro.utils.to_rgb | ( | orgb | ) |
convert an Origin OColor to r, g, b Parameters: orgb(int): OColor from Origin's internal value Returns: (tuple) r,g,b
def originpro.utils.wait | ( | type = 'r' , |
|
sec = 0 |
|||
) |
Wait for recalculation to finish or a specified number of seconds. Parameters: type (str): Either 'r' to wait for recalculation to finish or 's' to wait for specified seconds sec (float): Number of seconds to wait is 's' specified for type Returns: None Examples: op.wait()#wait for Origin to update all the recalculations op.wait('s', 0.2)#gives 0.2 sec for graphs to finish updating