mhammond / pywin32

Python for Windows (pywin32) Extensions
4.9k stars 783 forks source link

Unable to set value in in connection to application #2243

Closed pvalle6 closed 1 month ago

pvalle6 commented 2 months ago

For all bugs, please provide the following information:

Expected behavior and actual behavior

It should change the value (which can be confirmed in the connected program) and confirmed by simulation.flow_sheet.Operations.Item("TIC-100").SP.Value

The actual behavior is an error. Which is literally littered all over the internet and no good solutions are posted in 99.9% of stackoverflow and the solutions that do exist are often not working.

Steps to reproduce the problem

  1. Load Aspen HYSYS File using Aspen_HYSYS_Python
  2. import win32com.client as win32
    simulation_name = aspen_hysys_file
    aspen = win32.DispatchEx('Hysys.Application')
    simulation = self.aspen.SimulationCases.Open(os.path.abspath(simulation_name))
    self.act_doc = self.aspen.activeDocument
    self.flow_sheet = self.act_doc.Flowsheet
    simulation.flow_sheet.Operations.Item("TIC-100").SP.setValue(-32, "C")

    System information

Python version and distribution: Python 3.10

pywin32 version: v306

Installed from PyPI or exe installer: Yes

Windows Version: Version 10.0.19045 Build 19045

DLL locations:

C:\Users\username\PyCharm Projects\project_directory.venv\lib\site-packages\pywin32_system32\pywintypes310.dll

mhammond commented 1 month ago

You probably need help from the Aspen_HYSYS team