Zoom and orbit same time

Zoom and orbit same time

amoldshelke
Participant Participant
656 Views
2 Replies
Message 1 of 3

Zoom and orbit same time

amoldshelke
Participant
Participant

I want to do zoom and orbit same time. Please help me to enable it.

I have managed to do zoom from the keyboard by using key mapping but there is an issue in Fusion360 that it doesn't allow me to zoom in while orbiting i.e. it stops orbiting while using the zoom-in command...

Or if possible let me know how to pitch yow and roll the model from buttons.

or help me to get how 3D connexion navigate my model...

 

0 Likes
657 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor

Hi @amoldshelke .

 

If you want to use the API to control it at the same time, you can do so by changing the Viewport.camera property.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-2005e69c-36cd-45a2-bb3d-8cf5b968ab9a 

 

This sample script also zooms while circling around from the state in which it was executed.

# Fusion360API Python script
import adsk.core, adsk.fusion, adsk.cam, traceback
import math, random

# Number of divisions during one revolution
COUNT = 11

def run(context):
    ui = None
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui  = app.userInterface

        # get state
        vi :adsk.core.Viewport = app.activeViewport
        camera :adsk.core.Camera = vi.camera #This is a deep copy.
        eye :adsk.core.Point3D = camera.eye
        tgt :adsk.core.Point3D = camera.target
        up :adsk.core.Vector3D = camera.upVector
        baseArea = camera.viewExtents

        # get matrix
        front :adsk.core.Vector3D = eye.vectorTo(tgt)
        right :adsk.core.Vector3D = up.copy()
        right.crossProduct(front)
        mat :adsk.core.Matrix3D = adsk.core.Matrix3D.create()
        mat.setWithCoordinateSystem(tgt, right, front, up)

        # get position & ratio
        unit = math.radians(360 // COUNT)
        rads = [unit] * COUNT
        ratios = [random.uniform(0.1, 5.0) for _ in range(COUNT)]
        if 360 % COUNT != 0:
            rads.append(math.radians(360 % COUNT))
            ratios.append(1)

        # show
        camera.isSmoothTransition = True
        for rad, ratio in zip(rads, ratios):
            mat.setToRotation(rad, up, tgt)
            eye.transformBy(mat)
            camera.eye = eye

            zoom = baseArea * ratio
            camera.viewExtents = zoom

            vi.camera = camera
            vi.refresh()
            adsk.doEvents()

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

However, I think it would be difficult to create an add-in to perform Zoom and orbit with GUI keystrokes.
The Fusion360 API also supports keyboard events, but it is not very responsive.
If you use the OS API, it may be possible.

 

If you simply want to create an animation, I recommend you to use the Animation Workspace.

 

0 Likes
Message 3 of 3

amoldshelke
Participant
Participant

Hello @kandennti 

Thanks for the script.

actually, this script is working but seems like video or recorded steps.

I want to do the same thing using my navigation inputs.

Sorry, I don't know regarding python programming.

if you click on the "Home" named view to "Top" named view which creates smooth transition movement of the camera inside the viewport. Same that way I want to navigate in Fusion360 by using my mouse or keyboard instead of recorded steps. likely I want to use orbit and zoom simultaneously and smoothly.

 

Btw the script is really good thanks for that

and Thanks for reply

 

0 Likes