LukeAnger1 / SWPyMacros

Solidworks Python Macro List
MIT License
0 stars 0 forks source link

Document isnt opening correctly #1

Open LukeAnger1 opened 1 month ago

LukeAnger1 commented 1 month ago

The current test in main testing rotating is unable to open solidworks and only runs correctly if there is a document actively open.

LukeAnger1 commented 1 month ago

PS C:\Users\\Desktop\fortCounter\woodAndScrewCounter\testing\SWPyMacros> python3 .\hello_python_world.py Traceback (most recent call last): File "C:\Users\\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\win32com\client\dynamic.py", line 84, in _GetGoodDispatch IDispatch = pythoncom.connect(IDispatch) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\\Desktop\fortCounter\woodAndScrewCounter\testing\SWPyMacros\hello_python_world.py", line 67, in asyncio.run(main()) ^^^^^^ File "C:\Users\\Desktop\fortCounter\woodAndScrewCounter\testing\SWPyMacros\hello_python_world.py", line 17, in main sw = win32com.client.Dispatch("SldWorks.Application.{}".format(SWAV)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\win32com\client__init__.py", line 118, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\win32com\client\dynamic.py", line 104, in _GetGoodDispatchAndUserName ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\win32com\client\dynamic.py", line 86, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) PS C:\Users\\Desktop\fortCounter\woodAndScrewCounter\testing\SWPyMacros> python3 .\hello_python_world.py Solidworks API Version : 31 Solidworks Version : 2023 Traceback (most recent call last): asyncio.run(test_rotating_CAD()) ^^^^^^^^^^^^^^^^^^^ File "C:\Users\\Desktop\fortCounter\woodAndScrewCounter\testing\SWPyMacros\hello_python_world.py", line 78, in test_rotating_CAD ck = Model.Extension.SelectByID2("Front", "PLANE", 0, 0, 0, False, 0, ARG_NULL, 0) ^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'Extension' PS C:\Users\\Desktop\fortCounter\woodAndScrewCounter\testing\SWPyMacros> python3 .\hello_python_world.py Solidworks API Version : 31 Solidworks Version : 2023 C:\Users\\Desktop\fortCounter\woodAndScrewCounter\testing\SWPyMacros\hello_python_world.py executed in 0.00 seconds until while-loop

LukeAnger1 commented 1 month ago

This is terminal output. The first run was with solidworks closed. The second was with solidworks open but no CAD open. The third was with a CAD open.

LukeAnger1 commented 1 month ago

There is also an issue with it crashing with multiple instances open. This is the line that needs fixed swApp = win32com.client.Dispatch("SldWorks.Application.{}".format(SWAV))