thomasa88 / DirectName

Fusion 360 add-in for naming features directly after creation
MIT License
22 stars 0 forks source link

AttributeError: DirectName_py.thomasa88lib has no attribute 'win' #14

Open bandesz opened 1 week ago

bandesz commented 1 week ago

I get the following error after I create e.g. a sketch:

DirectName error: module '__main__%2FUsers%2F<user>%2FLibrary%2FContainers%2Fcom_autodesk_mas_fusion360%2FData%2FLibrary%2FApplication%20Support%2FAutodesk%2FApplicationPlugins%2FDirectName_bundle%2FContents%2FDirectName_py.thomasa88lib' has no attribute 'win'

Copy this message by taking a screenshot. Describe what you did to get this error or record a video.

--------------------------------------------------

Fusion 360 v. 2.0.20508
/Users/<user>/Library/Containers/com.autodesk.mas.fusion360/Data/Library/Application Support/Autodesk/ApplicationPlugins/DirectName.bundle/Contents/thomasa88lib/events.py failed: 

Traceback (most recent call last):
  File "/Users/<user>/Library/Containers/com.autodesk.mas.fusion360/Data/Library/Application Support/Autodesk/ApplicationPlugins/DirectName.bundle/Contents/thomasa88lib/events.py", line 142, in catcher
    func(args)
  File "/Users/<user>/Library/Containers/com.autodesk.mas.fusion360/Data/Library/Application Support/Autodesk/ApplicationPlugins/DirectName.bundle/Contents/DirectName.py", line 353, in rename_command_created_handler
    auto_focused = press_tab()
                  ^^^^^^^^^^^
  File "/Users/<user>/Library/Containers/com.autodesk.mas.fusion360/Data/Library/Application Support/Autodesk/ApplicationPlugins/DirectName.bundle/Contents/DirectName.py", line 394, in press_tab
    return press_key(thomasa88lib.win.input.VK_TAB, times)
                     ^^^^^^^^^^^^^^^^
AttributeError: module '__main__%2FUsers%2F<user>%2FLibrary%2FContainers%2Fcom_autodesk_mas_fusion360%2FData%2FLibrary%2FApplication%20Support%2FAutodesk%2FApplicationPlugins%2FDirectName_bundle%2FContents%2FDirectName_py.thomasa88lib' has no attribute 'win'

If it matters:

$ python3 --version
Python 3.13.0

OS: macOS Sonoma 14.6.1

bandesz commented 1 week ago

This is causing the issue, press_tab is called in rename_command_created_handler without checking the OS.

def press_tab(times=1):
    return press_key(thomasa88lib.win.input.VK_TAB, times)

E.g. this solves it:

def press_tab(times=1):
    if IS_WINDOWS:
        return press_key(thomasa88lib.win.input.VK_TAB, times)
    return False