Why does the view jump upon refresh when the camera position and orientation is not changed?

Why does the view jump upon refresh when the camera position and orientation is not changed?

mike46YZU
Contributor Contributor
482 Views
4 Replies
Message 1 of 5

Why does the view jump upon refresh when the camera position and orientation is not changed?

mike46YZU
Contributor
Contributor

Hi,

I'm working on a add-in that needs to control the view and ran into unexpected behavior. The test function below updates the view, but does not modify it. Yet, When you change the view manually to some arbitrary viewpoint and then run this function, the view jumps. The orientation remains the same but the view jumps in zoom and pans.

 

def test():
    
    app = adsk.core.Application.get()
    view = app.activeViewport
    camera = view.camera

    view.camera = camera
    view.refresh()

    print("test: view has been refreshed...\n")

 

I need to change the current view without this jump. What am I missing here? 

0 Likes
483 Views
4 Replies
Replies (4)
Message 2 of 5

kandennti
Mentor
Mentor

Hi @mike46YZU -San.

 

I tried it and nothing happened.
I knew it would not change anything before I tried it.

 

There may be a cause other than here, but I can't think of it either.

0 Likes
Message 3 of 5

mike46YZU
Contributor
Contributor

I have reproduced this on multiple PC's. Attached is a video. Below is the dedicated Add-In I wrote to demo the issue. Expected behavior is that nothing happens when you run the add-in. Observed behavior is that the view jumps. Note that the view should be changed to a random view from the default one before running the add-in.

 

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


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

    except:
        futil.handle_error('run')

def test():
    
    app = adsk.core.Application.get()
    view = app.activeViewport
    camera = view.camera

    view.camera = camera
    view.refresh()

    print("test: view has been refreshed...\n")


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')

 

0 Likes
Message 4 of 5

mike46YZU
Contributor
Contributor

Video also available here: https://youtu.be/hYu6UPhnGF8

0 Likes
Message 5 of 5

BrianEkins
Mentor
Mentor

I'm able to reproduce the problem. I found that it only happens when you have a orthographic (non-perspective) view. But it shouldn't happen then either. I'll see that a bug is logged.

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