rpakishore / ak_sap

Python Wrapper for SAP2000. Generate/Analyze/Extract complex structural models using python.
Mozilla Public License 2.0
14 stars 1 forks source link

unable connect to sap2000 #7

Open seyed121 opened 2 months ago

seyed121 commented 2 months ago

Hi, I want to connect to sap2000 and read the table 'Joint Displacements' from a open file. but when I use code

from ak_sap import debug, Sap2000Wrapper
debug(status=False)
sap = Sap2000Wrapper(attach_to_exist=True)

this error occured

Traceback (most recent call last):
  File "C:\Users\Seyed\AppData\Local\Programs\Python\Python312\Lib\site-packages\comtypes\__init__.py", line 345, in __getattr__
    fixed_name = self.__map_case__[name.lower()]
KeyError: 'databasetables'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\code\soole\final 2\tirvaragh - Copy.py", line 113, in <module>
    sap = Sap2000Wrapper(attach_to_exist=True)
  File "C:\Users\Seyed\ak_sap\src\ak_sap\wrapper.py", line 27, in __init__
    self.Table = Table(mySapObject=self.mySapObject, Model=self.Model)
  File "C:\Users\Seyed\ak_sap\src\ak_sap\Database\tables.py", line 15, in __init__
    self.DatabaseTables = self.SapModel.DatabaseTables
  File "C:\Users\Seyed\AppData\Local\Programs\Python\Python312\Lib\site-packages\comtypes\__init__.py", line 347, in __getattr__
    raise AttributeError(name)
AttributeError: DatabaseTables
rpakishore commented 2 months ago

Hey @seyed121, I am unable to replicate this error on my end. Can you confirm you are using the latest version of the ak_sap module?

You can confirm that you are using the latest version by running pip install ak_sap --upgrade

seyed121 commented 2 months ago

it's the latest version but it's still not working. I try Pypi package and install from git, but none of them don't work.

rpakishore commented 2 months ago

Hey Seyed, Can I get you to run the following debugging steps

  1. Please set debug(status=True) at the top of your py file for more explicit debug messages

    from ak_sap import debug
    debug(status=True)
  2. It looks like you are installing the package in your base environment, instead can you run the app in a new virtual environment using the venv package in python? It should help us figure out if you are running into any dependency conflicts.

  3. What version of SAP2000 and Python are you using?

If you are still running into issues, maybe it's specific to your environment. Hit me up at ak_sap@rpakishore.co.in, I can help you debug the error and patch the code to address it.