Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin problem #497

Closed
Asseelhij opened this issue Oct 17, 2023 · 9 comments
Closed

plugin problem #497

Asseelhij opened this issue Oct 17, 2023 · 9 comments
Labels
3rd-party issue related to specific windows stuffs or python packages

Comments

@Asseelhij
Copy link

Hello,
I am trying the Pyaxis connection. I wrote a code that runs successfully on my laptop, but it has some issues when I try to run it on my PC (I need it to work on my PC because my AxisVM model is too heavy to run on my laptop).
So, on my PC, some code snippets work fine. For example, I could open Axisvm via Python and create a new load case, but some code snippets like (patchlines = axm.ObjectCreator.NewLines3d()) give an attribute error:

(KeyError Traceback (most recent call last)
File ~\anaconda3\Lib\site-packages\comtypes_init_.py:274, in _cominterface_meta.new..CaseInsensitive.getattr(self, name)
273 try:
--> 274 fixed_name = self.map_case[name.lower()]
275 except KeyError:

KeyError: 'objectcreator'

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
Cell In[22], line 2
1 # origo is located at the left bottom corner
----> 2 patchlines = axm.ObjectCreator.NewLines3d()

File ~\anaconda3\Lib\site-packages\comtypes_init_.py:276, in _cominterface_meta.new..CaseInsensitive.getattr(self, name)
274 fixed_name = self.map_case[name.lower()]
275 except KeyError:
--> 276 raise AttributeError(name)
277 if fixed_name != name: # prevent unbounded recursion
278 return getattr(self, fixed_name)

AttributeError: ObjectCreator)

Can you help me fix this? I tried to uninstall axisvm and comtypes modules and reinstall them, but it was still not working.

thank you in advance.

@junkmd
Copy link
Collaborator

junkmd commented Oct 17, 2023

Hello.

First, I haven't fully grasped your situation, so please provide the following information:

  1. Is 'Pyaxis' a library? If so, could you provide the source code repository?
  2. Please tell me the version of Python you used.
  3. Share the code that worked successfully on both your laptop and PC.

Additionally, if you can provide the results in a code block format as shown here: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks, it would be greatly appreciated.

@Asseelhij
Copy link
Author

Thank you for your reply,

Pyaxis is a Python package for AxisVM. you can find more here (https://github.com/AxisVM/pyaxisvm).

I'm using Python 3.11.4 on my laptop and 3.12.0 on my PC.

I will write the code here then point out the code blocks that don't work on my pc.

import axisvm
import comtypes
import comtypes.client as cc
import sys
from time import sleep
# Define AX_APP_PROGID for the AxisVM application
AX_APP_PROGID = 'AxisVM.AxisVMApplication'

#Define AX_APP_PROGID for the AxisVM application
AX_APP_PROGID = 'AxisVM.AxisVMApplication'

# Import the 'ax' module for AxisVM
try:
    import comtypes.gen._0AA46C32_04EF_46E3_B0E4_D2DA28D0AB08_0_17_200 as ax
    print("AxisVM module imported!")
except:
    print("AxisVM module import error !")


# Define the StartAxisVM() function as in the first code snippet
def StartAxisVM(): 
    axApp = None
    try:
        axApp = cc.CreateObject(AX_APP_PROGID, comtypes.CLSCTX_ALL, None, ax.IAxisVMApplication)
        print("AxisVM object created")
    except:
        print("error creating the object!")
        sys.exit()
    if not axApp is None:
        if WaitForAxisVM_loaded(axApp):
            axApp.Visible = ax.lbTrue
            axApp.CloseOnLastReleased = ax.lbFalse
            axApp.AskCloseOnLastReleased = ax.lbTrue
            axApp.AskSaveOnLastReleased = ax.lbTrue
            axApp.ApplicationClose = ax.acEnableNoWarning
            return axApp
    if axApp is None:
        print("AxisVM start error !")
        exit()

# Define the WaitForAxisVM_loaded() function as in the first code snippet
def WaitForAxisVM_loaded(aAxApp):
    try:
        while not (aAxApp.Loaded == ax.lbTrue):
            sleep(0.1)
            print("waiting")
        return True
    except:
        return False

# Rest of the code for loading the model from file
model_file_path = "C:/Users/user/Downloads/OLD BRIDGE - TENDONS INSIDE CONCRETE - successfull analysis.axe"

try:
    axApp = StartAxisVM()
    axModel = axApp.Models[1]
    
    axModel.LoadFromFile(model_file_path)
    
    print(f"Model '{model_file_path}' loaded successfully.")
except Exception as e:
    print(f"Error loading model: {str(e)}")
# Define the AxisVM model
axm = axModel
#Load Case 1 - Constant distributed vertical load on the whole domain
lcid1 = 1
axm.LoadCases.Name[1] = 'LC1'

the next code block only works on my laptop and on my PC gives an error.

qz = -1.0  # load intensity

LoadDomainConstant = axtlb.RLoadDomainConstant(
    LoadCaseId=lcid1,
    DomainId=121,
    qx=0,
    qy=0,
    qz=qz,
    DistributionType=axtlb.sddtSurface,
    SystemGLR=axtlb.sysGlobal
)
_ = axm.Loads.AddDomainConstant(LoadDomainConstant)

The result of the code is to open a file (model on AxisVM) and define a load case.

@junkmd
Copy link
Collaborator

junkmd commented Oct 17, 2023

Thank you for the information. Please try the following:

  1. Since the Python version differs between your laptop and PC, try running it on your PC with Python 3.11.4.
    (comtypes hasn't been tested on Python 3.12 in CI yet. We are waiting for the support for Python 3.12 to be added on Appveyor.)

  2. comtypes generates Python modules based on the COM library contents in the execution environment. Check the contents of comtypes.gen._0AA46C32_04EF_46E3_B0E4_D2DA28D0AB08_0_17_200.

  3. I checked requirements.txt in pyaxisvm, and it's locked to comtypes==1.1.11. Try it with the latest version, 1.2.0.

@junkmd junkmd added the 3rd-party issue related to specific windows stuffs or python packages label Oct 17, 2023
@Asseelhij
Copy link
Author

Asseelhij commented Oct 19, 2023 via email

@junkmd
Copy link
Collaborator

junkmd commented Oct 19, 2023

Did you find any differences in the codebase of comtypes.gen._0AA46C32_04EF_46E3_B0E4_D2DA28D0AB08_0_17_200 on your laptop and PC?

Are there any differences in the contents of _methods_ and _disp_methods_ for each class defined within the module?

@EwoutH
Copy link

EwoutH commented Oct 31, 2023

  1. Since the Python version differs between your laptop and PC, try running it on your PC with Python 3.11.4.
    (comtypes hasn't been tested on Python 3.12 in CI yet. We are waiting for the support for Python 3.12 to be added on Appveyor.)

AppVeyor updated their images with Python 3.12 (appveyor/ci#3879).

@junkmd
Copy link
Collaborator

junkmd commented Mar 4, 2024

@Asseelhij
Is there an update on this issue?

@Asseelhij
Copy link
Author

@junkmd I am using Python 3.11.5 and comtypes 1.1.11 and it works perfectly.

@junkmd
Copy link
Collaborator

junkmd commented Mar 4, 2024

I suspect that the generated module under comtypes.gen was a partial file, as mentioned in #114.

Since comtypes==1.1.11 does not support Python==3.11, I think that pyaxisvm will not work with Python>=3.11 as long as pyaxisvm requires comtypes==1.1.11.

@junkmd junkmd closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd-party issue related to specific windows stuffs or python packages
Projects
None yet
Development

No branches or pull requests

3 participants