0

I'm trying to make a connection between python and UniSim Design, using jupyter-notebook. But I'm stucked with an error. The error follows below:

C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py in __getattr__(self, attr)
    626             )
    627             try:
--> 628                 ret = self._oleobj_.Invoke(retEntry.dispid, 0, invoke_type, 1)
    629             except pythoncom.com_error as details:
    630                 if details.hresult in ERRORS_BAD_CONTEXT:

com_error: (-2147352567, 'Exceção.', (0, None, None, None, 0, -2147467259), None)

I made a connection using the code as follows:

def abresim():
    parent = os.path.dirname(os.getcwd()) 
    unisim = win32.Dispatch('UniSimDesign.Application')
    unisim.visible=True                                                                                  
    simulation = unisim.SimulationCases.Open(os.path.join(os.path.dirname(os.getcwd()), 'directory with the UniSim file'))
    simulation.Activate()
    sheet = simulation.Flowsheet.Operations['Entradas'] # spreadsheet in my UniSim file
    return unisim,simulation,sheet

After that, I'm trying to access some cell values from that spreadsheet with command sheet.Cell(0,13).CellValue, because it is at the A14 cell in UniSim.

The value in UniSim simulator is <empty>.

So when I run the sheet.Cell(0,13).CellValue command, it returns me the error I mentioned here.

What I need is to import this value from UniSim to Python without error, changing that value to zero, for instance.

2
  • The value in UniSim simulator is '<empty>'. Correcting th nonsense phrase in the description kkkkkk Commented Aug 21, 2024 at 15:00
  • 1
    Thanks Wayne, I rewrote the question. Commented Aug 21, 2024 at 17:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.