thomasa88 / DirectName

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

Directname causes delay when switching between Pan and Orbit tools with the mouse #12

Closed skylatian closed 2 weeks ago

skylatian commented 2 months ago

I have a very odd issue - when using pan/orbit tools with mouse middle/right click buttons, switching between the tools in a complex design has a significant delay. I enabled show pointer clicks in the attached screen recording - red is left click, green is left, middle is blue.

It's almost like DirectName is iterating through every component or something and checking if it needs to be named, any idea what may be going on here? I love the extension but it makes working with complex models a nightmare. Happy to provide any logs or test as needed, if possible!

https://github.com/user-attachments/assets/b2e451eb-7a2f-409b-b92e-f7964584b19a

thomasa88 commented 1 month ago

It's almost like DirectName is iterating through every component or something and checking if it needs to be named,

I looked at the code and it seems that's basically what's happening. I think the reason is that there are too many commands that result in an edit to list them all.

Please edit DirectAdmin.py (e.g. Shift+S -> Add-ins -> DirectName -> Edit. Or expand the + to see the install directory and use your favorite editor), find the following code and add the last line below:

    # Heavy traffic commands
    if args.commandId in ['SelectCommand', 'CommitCommand']:
        return
    app_.log(f"Terminated command: {args.commandId}", adsk.core.LogLevels.ErrorLogLevel, adsk.core.LogTypes.ConsoleLogType) # <------------------- add this line

Stop and start the add-in.

Take note of all commands that are output in the console (Ctrl+Alt+C) when doing the navigation actions. Then try adding them to the line with the if just below the line you just added.

Scott216 commented 1 month ago

I don't see a file called DirectAdmin.py. Did you mean DirectName.py?

thomasa88 commented 1 month ago

Yes, exactly! My mistake :man_facepalming:

I had some time to do a quick test now.

 Terminated command: ScriptsManagerCommand
 Terminated command: FreeOrbitCommand
 Terminated command: PanCommand
 Terminated command: PanCommand
 Terminated command: PanCommand
 Terminated command: FreeOrbitCommand

Looks like this: image

So it looks like extending the list of ignored commands like this should help for pan and orbit:

    if args.commandId in ['SelectCommand', 'CommitCommand', 'PanCommand', 'FreeOrbitCommand']:

but it is interesting to see if your navigation usage triggers some other command as well.

thomasa88 commented 2 weeks ago

Hi, I just published version 1.4.1 on Github, where I have added these and some more commands to the filtering. A new installer will hopefully appear in the Autodesk app store in 1-2 weeks.