Python: Failed to connect to Motor-CAD instance

Dear forum,

we have been using Motor-CAD 2024.1.3 with Python scripts in the last months.
On the same PC (Windows) Motor-CAD 2024.2.3.1 has now been installed. This seems to lead to some unexpected behavior: when opening the same models and scripts in the same older 2024.1.3 version, the Python scripts suddenly fail at the second line:

Python script Exception: An error occurred in user script.
User Script, line 6, in
mcApp = pymotorcad.MotorCAD()
^^^^^^^^^^^^^^^^^^^^^
Exception: Failed to connect to Motor-CAD instance: port=58016, Url=http://localhost:58016/jsonrpc

We also tried to open everything in the new 2024.2.3.1 but the behavior is the same.
We also checked the menu "Defaults -> Automation" and tried different “registered” versions. Nothing worked.

As soon as we switch to another PC, where Motor-CAD 2024.2.3.1 has not been installed yet, everything works as before. So we are pretty sure that the new Motor-CAD installation causes this and not any change in our environment.

Is there any workaround to make the scripts running again on all machines?

Thank you!

Tagged:

Answers

  • James Derrick
    James Derrick Administrator, Employee Posts: 292
    Ancient Membership 100 Comments 100 Likes 25 Answers
    admin

    Hi @mathias thanks for your post. Hopefully @PyMotorCAD-Team will be able to help you!

  • PyMotorCAD-Team
    PyMotorCAD-Team Member, Employee Posts: 3
    First Comment Name Dropper
    ✭✭✭

    Hi @mathias thanks for your message. There should be no compatibility issues with the Motor-CAD v2024.2.3 installation and PyMotorCAD. I have a few questions:
    1. Are you using a virtual environment?
    2. If so, which Python version are you using?
    3. If not using a virtual environment, can you please go to the Sripting -> Settings tab in Motor-CAD and click Display Version and report which version of PyMotorCAD is installed?

    Thanks. The answers to the questions above should help us to determine what issue might be occurring here.

  • mathias
    mathias Member Posts: 2
    First Comment
    **

    Hello!
    Thanks for answering. We have no virtual environment.
    The requested output is: "Python script output: PyMotorCAD version: 0.5.5"

    However, we have tried it on another PC meanwhile. The same issue occurs there as well, as soon as we install v2024.2.3, Python scripts stop working in all installed MotorCAD versions. :(
    On this second machine I have updated PyMotorCAD to the latest release to give it a try. The output there now is: "Python script output: PyMotorCAD version: 0.6.3"

    Nothing has helped yet.

  • PyMotorCAD-Team
    PyMotorCAD-Team Member, Employee Posts: 3
    First Comment Name Dropper
    ✭✭✭

    Hi @mathias , it's difficult to understand what is causing this issue. Have you tried uninstalling Motor-CAD v2024.2.3 to see whether everything returns to how it was before?

    I recommend:

    • Uninstalling Motor-CAD v2024.2.3
    • Open Motor-CAD v2024.1.3 and try the script

    • If everything works again, we can try to reinstall Motor-CAD v2024.2.3

    • Test whether the problem reappears

    • If the problem persists after uninstalling Motor-CAD v2024.2.3 we need to figure out what the problem is.