Establish connection between R and Aspen Plus

Got it!!!

# Package
library(RDCOMClient)

# 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$visible()
Aspen[["SuppressDialogs"]] <- 1
Aspen$SuppressDialogs()

# Reinitialize Simulation
Aspen$Reinit()

# Run Simulation
Aspen$Run2()

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

# Close Aspen Plus
Aspen$Close()
1 Like