Establish connection between R and Aspen Plus

I am trying to establish a connection between R and Aspen Plus (a chemical process simulator). I have succeeded in making the connection between MATLAB and Aspen Plus (, but not with R.

I believe the problem is related to creating and invoking a COM server. I would like to be able to perform the same simulation as at, only using R instead of MATLAB.

I have asked this same question to the Aspen Tech Suport Center. Here is there answer: The Aspen Plus Windows user interface is an ActiveX Automation Server. The ActiveX technology (also called OLE Automation) enables an external Windows application to interact with Aspen Plus through a programming interface using a language such as Microsoft's Visual Basic. The server exposes objects through the COM object model. If the R programming language can interact with the COM interface, then it should work. Any ideas?

I have no clue what the status of this project is, but:

Thank you Mara. I'm using the RDCOMClient package, but still without much success. In matlab I would use the actxserver() function (to create a COM server) and the invoke() function (to invoke a method in the COM object). I'm just not being able to do the same in R;

Assuming you are on Windows, one option would be to try and use VBScript (see this). So all your COM automation codes are in the script, which you simply execute using R.

I have successfully used this technique to open an Excel file, write to a cell which itself triggers a proprietary API available only as an Excel add-in, get the results in Excel, write those to a file and finally read this file in R.

Got it!!!

# Package

# COM Object
Aspen <- RDCOMClient::COMCreate("Apwn.Document")

# Path to .bkp simulation file
Path <- "C:/Path to simulation file.bkp"

# Invoke COM Object
RDCOMClient::.COM(obj = Aspen, name = "InitFromFile2", Path)

Aspen[["Visible"]] <- TRUE
Aspen[["SuppressDialogs"]] <- 1

# Reinitialize Simulation

# Run Simulation

# Calling variable result from simulation  
Aspen$Application()$Tree()$FindNode('Variable Explorer Call')$Value()

# Close Aspen Plus
1 Like

If your question's been answered (even if by you), would you mind choosing a solution? (See FAQ below for how).

Having questions checked as resolved makes it a bit easier to navigate the site visually and see which threads still need help.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.