Aspen Plus variables access through Active X

조회 수: 25 (최근 30일)
Muhammad Tauha Ali
Muhammad Tauha Ali 2024년 4월 16일
댓글: Muhammad Tauha Ali 2024년 9월 24일
I am trying to access stream results of Aspen Plus simulation through active x but can't access the fields within the results tables although the variables call is available on the 'variable explorer'. My access method is:
Aspen.Tree.FindNode("\Data\Results Summary\Stream-Sum\Stream-Sum\Table")
i get an interface object which contains a 'elements' field which is also an interface object. However, the findnode function doesn't work on that COM object.
I found a python code on "kitchingroup" under aspen tag that shows how to access all the variables:
import os
import win32com.client as win32
aspen = win32.Dispatch('Apwn.Document')
aspen.InitFromArchive2(os.path.abspath('data\Flash_Example.bkp'))
def print_elements(obj, level=0):
if hasattr(obj, 'Elements'):
print ' '*level + obj.Name
for o in obj.Elements:
print_elements(o, level + 1)
else:
print ' '*level, obj.Name, ' = ', obj.Value
print_elements(aspen.Tree)
aspen.Close
can somebody provide a MATLAB equivalent for this code? the AI translated code didn't work.

답변 (1개)

Sivsankar
Sivsankar 2024년 9월 13일
Hi Muhammed,
To access the stream results of an Aspen Plus simulation using ActiveX in MATLAB, you'll need to use COM automation like the Python script you provided.
There is a file exchange that helps to outline the Aspen Plus and Matlab connection through COM Technology. Leverage the following file exchange from below:
I believe that the MATLAB file provided in the file exchange has the python equivalent of your code.
Hope this helps!
  댓글 수: 1
Muhammad Tauha Ali
Muhammad Tauha Ali 2024년 9월 24일
Hi,
Thanks for taking the time to reply. However, the question still remains about a way to do accomplish a sort of recursion on COM objects as demonstrated in the Python code.
I am already using COM/ActiveX interface for establishing Aspen Plus-MATLAB link as you identified. The problem is that i can't access the output streams table data, as an example, as it is one or two levels down in the COM objects hierarchy.

댓글을 달려면 로그인하십시오.

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by