OriginExt
OriginExt is a Python package that enables you to access Origin functionality from Python. OriginExt is built on Origin’s COM/Automation interface that Python functions as the client application that connects with Origin. It allows exchange data back and forth between Python and Origin and can also send commands from Python to be executed by Origin.
To obtain OriginExt, go to this pypi.org page.
Follow the steps below to generate and connect to an Origin instance from external Python.
pip install OriginExt
import OriginExt as O app = O.Application() app.Visible = 1
Here is an example on how to create an Origin project with some data
import OriginExt as O Oapp = O.Application() name = Oapp.CreatePage(Oapp.OPT_WORKSHEET,"MyBook","Origin") wbook = Oapp.Pages(name) wks = wbook.Layers(0) for ii in range(0,wks.Columns.Count,1): tmp = range(0,10) tmp = [x + ii for x in tmp] col = wks.Columns(ii) col.SetData(tmp) Oapp.Save(r'c:\test\junk.opju') Oapp.Exit() #need to do this to make sure Origin is closed del Oapp
For more examples on communicating with Origin from external Python, please refer to our Automation Server documentation.
If you are using an earlier version of Origin, you might see a MS DLL error at Origin startup, such as the error "ModuleNotFoundError: No module named 'originext'". In this case, we suggest you to download and install the MS redistributable package. The needed MS redistributable packages are listed in this web page, you can download the suitable package(s) according to the version of Origin you are using.