Professional Documents
Culture Documents
Versions: V9.0
Article ID: 000044410
Primary Subject:
Add Favorite
Add Favorite
Applicable Version(s)
All versions
Problem Statement
How can I automate Aspen HYSYS from the Python language?
Solution
Regardless of which programming language you choose to automate Aspen HYSYS with, it is all
accomplished by creating and interacting with a HYSYS COM object. Unlike languages such as VBA,
VB.NET, and C#, Python does not automatically create a wrapper to interact with COM interfaces.
You can download and install a third-party extension known as "pywin32" to act as the additional
layer to facilitate communication between Python code and COM interfaces. Note that AspenTech
does not endorse the use of third-party openly-sourced modules, although Python owes its popularity
to the open-source implementation and the community of developers that this fosters.
Aside from the code to create the HYSYS COM object, the interaction with HYSYS interfaces
https://esupport.aspentech.com/S_Article?id=000044410[03.11.2017 14:54:00]
AspenTech: Knowledge Base
through COM is the same as with any other language. For more information on HYSYS interfaces,
you can browse the HYSYS type library with another program (such as Microsoft Excel or Visual
Studio). The knowledge base contains sample code for performing certain tasks via automation, and
most of these examples can be translated into Python code. However, since Python is a dynamically-
typed language that does not support static object declaration, Python does not support the creation
of BackDoor objects, so certain tasks that require you to create and access BackDoor objects cannot
be accomplished in Python.
# Requires the "pywin32" extension. You can get it from the Internet.
# Note: AspenTech does not condone the use of external openly-sourced modules.
# But then again, Python owes its popularity to the open-source implementation and the community that t
his fosters.
# Use at your own discretion and consult online resources for support with this extension.
from win32com.client import Dispatch
hysysCase.Solver.CanSolve = False
# Output
Keywords
HYSYS, Automation, COM, Python, ActiveX
https://esupport.aspentech.com/S_Article?id=000044410[03.11.2017 14:54:00]
AspenTech: Knowledge Base
Comments
Submit Comment
© 1994- 2017, Aspen Technology, Inc. All rights reserved Privacy Policy
https://esupport.aspentech.com/S_Article?id=000044410[03.11.2017 14:54:00]