Bug: No cameraChanged event when viewport size changes

Bug: No cameraChanged event when viewport size changes

axalea_thomas
Enthusiast Enthusiast
309 Views
1 Reply
Message 1 of 2

Bug: No cameraChanged event when viewport size changes

axalea_thomas
Enthusiast
Enthusiast

The description of the cameraChanged event states (emphasis mine):

 

The cameraChanged event fires immediately after a change in the camera has been made. Camera changes happen when user changes the view by rotating, zooming in or out, panning, changing from parallel to perspective, or when the extents of the viewport changes.

 

However, I have observed that no event is fired when the viewport is resized, by either resizing the main window or opening/closing the data panel. Selecting "Multiple views" sometimes fire cameraChanged (try toggling back and forth a few times).

 

I expect the cameraChanged event to fire every time the/a viewport changes size on the screen.

 

The meaning of "extents" is not fully clear to me. If it is intended to mean that the view changes the size of the opening "into" model space, the event should at least trigger if the view proportions are changed. If I draw a rectangle covering the view fully and resize the main window, I see that the rectangle does not continue to touch both the sides and top/bottom of the view port, as what is seen is scaled without changing its proportions.

 

Example code (create the sample add-in and replace the contents of the main file). It will log in the console every time a cameraChanged event is fired.

# Assuming you have not changed the general structure of the template no modification is needed in this file.
# from . import commands
from .lib import fusionAddInUtils as futil

import adsk.core
from datetime import datetime

app = adsk.core.Application.get()

def run(context):
    try:
        # This will run the start function in each of your commands as defined in commands/__init__.py
        # commands.start()

        futil.add_handler(app.cameraChanged, cameraChanged)

    except:
        futil.handle_error('run')

counter = 0
def cameraChanged(args: adsk.core.CameraEventArgs):
    global counter
    counter += 1
    app.log(f"{datetime.now()} Camera changed {counter}")

def stop(context):
    try:
        # Remove all of the event handlers your app has created
        futil.clear_handlers()

        # This will run the start function in each of your commands as defined in commands/__init__.py
        # commands.stop()

    except:
        futil.handle_error('stop')

 

Thomas @ Axalea

My Add-ins (Windows)
⌨️ Toolbar & Shortcuts Editor: Assign any key (and some mouse buttons) as keyboard shortcut!
⤴️ Extra Shortcuts: Assign shortcut to Front, Home view, Look At, Activate Component and more!
My Logo: Put your logo in the Fusion window (for presentations and streaming)
 Axalea Notes - Annotate your model with notes
0 Likes
Accepted solutions (1)
310 Views
1 Reply
Reply (1)
Message 2 of 2

BrianEkins
Mentor
Mentor
Accepted solution

I agree that this does seem like a bug. An argument could be made that the camera didn't change in this case, but I would include the extents with the camera, which is changing. I'll see that a bug is logged.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com